Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addpkg: libredefender #384

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions libredefender/fix_ptrace_enum.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/linux.rs b/linux.rs
index ba0e614..662425a 100644
--- a/linux.rs
+++ b/linux.rs
@@ -46,7 +46,6 @@ libc_enum!{
target_arch = "mips",
target_arch = "mips64",
target_arch = "x86_64",
- target_arch = "riscv64",
target_pointer_width = "32"))))]
PTRACE_GETREGS,
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
@@ -54,7 +53,6 @@ libc_enum!{
target_arch = "mips",
target_arch = "mips64",
target_arch = "x86_64",
- target_arch = "riscv64",
target_pointer_width = "32"))))]
PTRACE_SETREGS,
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
@@ -62,7 +60,6 @@ libc_enum!{
target_arch = "mips",
target_arch = "mips64",
target_arch = "x86_64",
- target_arch = "riscv64",
target_pointer_width = "32"))))]
PTRACE_GETFPREGS,
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
@@ -70,7 +67,6 @@ libc_enum!{
target_arch = "mips",
target_arch = "mips64",
target_arch = "x86_64",
- target_arch = "riscv64",
target_pointer_width = "32"))))]
PTRACE_SETFPREGS,
PTRACE_ATTACH,
@@ -79,15 +75,13 @@ libc_enum!{
target_arch = "mips",
target_arch = "mips64",
target_arch = "x86",
- target_arch = "x86_64",
- target_arch = "riscv64")))]
+ target_arch = "x86_64")))]
PTRACE_GETFPXREGS,
#[cfg(all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips64",
target_arch = "x86",
- target_arch = "x86_64",
- target_arch = "riscv64")))]
+ target_arch = "x86_64")))]
PTRACE_SETFPXREGS,
PTRACE_SYSCALL,
PTRACE_SETOPTIONS,
40 changes: 40 additions & 0 deletions libredefender/fix_type.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/engine.rs b/engine.rs
index 5f2fe24..e26bc58 100644
--- a/engine.rs
+++ b/engine.rs
@@ -78,7 +78,7 @@ pub struct Engine {
unsafe impl Send for Engine {}
unsafe impl Sync for Engine {}

-fn map_scan_result(result: cl_error_t, virname: *const i8) -> Result<ScanResult, ClamError> {
+fn map_scan_result(result: cl_error_t, virname: *const u8) -> Result<ScanResult, ClamError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes compatible with x86_64? I really don't think that it's the source of the problem, could you please explain the reasons for this patch further?

match result {
cl_error_t::CL_CLEAN => Ok(ScanResult::Clean),
cl_error_t::CL_BREAK => Ok(ScanResult::Whitelisted),
@@ -231,7 +231,7 @@ impl Engine {
pub fn scan_file(&self, path: &str, settings: &mut ScanSettings) -> Result<ScanResult, ClamError> {
let raw_path = CString::new(path).unwrap();
unsafe {
- let mut virname: *const i8 = ptr::null();
+ let mut virname: *const u8 = ptr::null();
let result = clamav_sys::cl_scanfile(
raw_path.as_ptr(),
&mut virname,
@@ -249,7 +249,7 @@ impl Engine {
/// loaded and compiled.
pub fn scan_descriptor(&self, descriptor: i32, settings: &mut ScanSettings, filename: Option< &str >) -> Result<ScanResult, ClamError> {
unsafe {
- let mut virname: *const i8 = ptr::null();
+ let mut virname: *const u8 = ptr::null();
let filename_cstr = filename.map(|x| CString::new(x).expect("CString::new failed"));
let mut scanned : c_ulong = 0;
let result = clamav_sys::cl_scandesc(
@@ -283,7 +283,7 @@ impl Engine {
/// @param engine The scanning engine.
/// @param scanoptions The scanning options.
pub fn scan_map(&self, map : & Fmap, filename: Option<&str>, settings: &mut ScanSettings) -> Result<ScanResult, ClamError> {
- let mut virname: *const i8 = ptr::null();
+ let mut virname: *const u8 = ptr::null();
let c_filename = filename.map(|n| CString::new(n).expect("CString::new failed"));
let result = unsafe {
clamav_sys::cl_scanmap_callback(
31 changes: 31 additions & 0 deletions libredefender/riscv64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git PKGBUILD PKGBUILD
index b090525a..ac8da04d 100644
--- PKGBUILD
+++ PKGBUILD
@@ -10,15 +10,23 @@ license=('GPL2')
depends=('libclamav.so' 'hicolor-icon-theme')
makedepends=('cargo' 'clang')
source=(https://github.com/kpcyrd/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
- https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc)
+ https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc
+ fix_ptrace_enum.patch
+ fix_type.patch)
b2sums=('ae67c49a464d33249f1d11bd32eaa827c0f1410021ce5638eda8a522d0ec70100b07d817559bbda6ba6e90cb6c3f55824b763076e8b7cf5c81f25a29dee95d9a'
- 'SKIP')
+ 'SKIP'
+ 'cf82f590fcdf3b98c62a8494e685d8e1e53a7009e5361be91e8c480a55af7040dbbdf2ede22f49a5cbb027be37b75e225a7da37a4110d2c4d3165bb51ef75ddd'
+ '9226d72280a7b408575cb6789193ed61f1861e5c465510a7b1bf555e238f482e73b645d50d3b5d03dd6d7afe96fb975ba73ef6fd5accca3df0d2204c0ea75a6d')

validpgpkeys=("64B13F7117D6E07D661BBCE0FE763A64F5E54FD6")

prepare() {
cd "${pkgname}-${pkgver}"
- cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
+ cargo fetch --locked --target "riscv64gc-unknown-linux-gnu"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to substitute the variables with specific values, which reduces the generality of PKGBUILD.

+ cd ~/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.17.0/src/sys/ptrace
+ patch -Np1 -i "${srcdir}/fix_ptrace_enum.patch"
Comment on lines +25 to +26
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix-0.23.0is available and compatible with RISC-V, please remove the patch and bump the dependency instead.

+ cd ~/.cargo/registry/src/github.com-1ecc6299db9ec823/clamav-rs-0.5.5/src
+ patch -Np1 -i "${srcdir}/fix_type.patch"
}

build() {