From patchwork Tue Nov 5 23:14:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 69895 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id AD5F327BBEA; Tue, 5 Nov 2024 23:16:59 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D2C9727BBE2 for ; Tue, 5 Nov 2024 23:16:58 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8SmN-00035m-49; Tue, 05 Nov 2024 18:16:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8SmK-00034P-Bh for guix-patches@gnu.org; Tue, 05 Nov 2024 18:16:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8SmJ-0002E0-SY for guix-patches@gnu.org; Tue, 05 Nov 2024 18:16:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=o+aNOHwor4w/78FVVpabUQ55R4vA6/sjokfUG1wCy6g=; b=ktjxCequdO1eICotHV3bLxvr4/hUlTW8A+Zl19S4v/TOZ1jf9+FXGvSohjVEuq7mbFwV7HCzRoUwi7YYZjRHvur8YOT9KFFxIrWa/K0t8rEvmjwvHvdmoOfYGbUwSE1eaj+6+/ryUEFtG2Xm4U233G2Q4RXiXefZ03H+oUctZmA3Y6otiM1UKVYOlOY4QhLeFa3nZhLNY1ZptWSkCRmvtgb1YCIzEV62o08FaiUxqk84ISzNE6xCvW1MMILTaX4O9yW1vBEhU7/g3EGqvlR2zDHc6lLjGFqNFsDFKjQuncbkCFn6pHewgAGDbaMUQC/qbc1YZB7NV2h5o+z3PsGjJQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t8SmJ-0004Kz-Mj for guix-patches@gnu.org; Tue, 05 Nov 2024 18:16:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#73896] [PATCH v4 04/20] gnu: Add rust-onenote-parser-for-clamav. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 05 Nov 2024 23:16:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73896 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73896@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 73896-submit@debbugs.gnu.org id=B73896.173084855016593 (code B ref 73896); Tue, 05 Nov 2024 23:16:03 +0000 Received: (at 73896) by debbugs.gnu.org; 5 Nov 2024 23:15:50 +0000 Received: from localhost ([127.0.0.1]:38410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8Sm5-0004JX-2w for submit@debbugs.gnu.org; Tue, 05 Nov 2024 18:15:49 -0500 Received: from 11.mo581.mail-out.ovh.net ([87.98.173.157]:37609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8Sm0-0004JG-Lq for 73896@debbugs.gnu.org; Tue, 05 Nov 2024 18:15:48 -0500 Received: from director11.ghost.mail-out.ovh.net (unknown [10.108.25.16]) by mo581.mail-out.ovh.net (Postfix) with ESMTP id 4Xjkhv4Bmvz1MFj for <73896@debbugs.gnu.org>; Tue, 5 Nov 2024 23:15:43 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-2gkmb (unknown [10.110.168.38]) by director11.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 54D8E1FE7D; Tue, 5 Nov 2024 23:15:43 +0000 (UTC) Received: from ngraves.fr ([37.59.142.99]) by ghost-submission-5b5ff79f4f-2gkmb with ESMTPSA id 0Bq2Nx6nKmdDcBkALo/peQ (envelope-from ); Tue, 05 Nov 2024 23:15:43 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-99G003f89c94ec-ed69-4d74-bd3d-397ec89fb4b1, 7DA11F85E05AC71F4B07BAB71687C1137F5318AF) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 86.246.19.221 Date: Wed, 6 Nov 2024 00:14:52 +0100 Message-ID: <20241105231519.22378-4-ngraves@ngraves.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241105231519.22378-1-ngraves@ngraves.fr> References: <20241105231519.22378-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 12042343932894372578 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 5 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefuddrtddugddtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecufghrlhcuvffnffculdehmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepueevjeduheeftedvuedtgfeghfeuhffhfeeggfejudelgfeihfekgffhvdfhtddvnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpohhnvghnohhtvgdrrhhspdhgvghnthhoohdrohhrghenucfkphepuddvjedrtddrtddruddpkeeirddvgeeirdduledrvddvuddpfeejrdehledrudegvddrleelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopeejfeekleeiseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkedumgdpmhhouggvpehsmhhtphhouhht DKIM-Signature: a=rsa-sha256; bh=o+aNOHwor4w/78FVVpabUQ55R4vA6/sjokfUG1wCy6g=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1730848543; v=1; b=WfDsGbGhb26O/JbCHx1MUtuacL+M46Uaxx5CucTpxddVWVL2tIuiLiUGJp/H7ksvRi5k8XOw 6NJ4qmbeorIT5lfNexiazoYznv33DB4hPJyoQeWg1Ejbbrd1AD3vJRrbo968VCTN6IpTYa+jerH jM8BHkdqphY6sQToNomtGOoG5BVBgNt7aLr3KqyBvCTeuFBAvOWWoqag22yvYhYvQeNCeq1h7jb m99xG3sxU1UtonZjby6l2PkpJHuum87kRVaDvjx6H9/G1zOJrFBF7n4by0UvXbHeL0tWXjpax3R w86XyBgy+oFlgWvIg+PykyAuicqF07+OCJCKQbMOlfn+A== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/crates-io.scm (rust-onenote-parser-for-clamav): New variable. * gnu/packages/patches/rust-onenote-parser-for-clamav-deps.patch * gnu/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch * gnu/packages/patches/rust-onenote-parser-for-clamav-property-type.patch Add patches here... * gnu/local.mk: ...and here. --- gnu/local.mk | 3 + gnu/packages/crates-io.scm | 27 ++++++ .../rust-onenote-parser-for-clamav-deps.patch | 88 +++++++++++++++++++ ...er-for-clamav-parse-in-memory-buffer.patch | 52 +++++++++++ ...note-parser-for-clamav-property-type.patch | 30 +++++++ 5 files changed, 200 insertions(+) create mode 100644 gnu/packages/patches/rust-onenote-parser-for-clamav-deps.patch create mode 100644 gnu/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch create mode 100644 gnu/packages/patches/rust-onenote-parser-for-clamav-property-type.patch diff --git a/gnu/local.mk b/gnu/local.mk index 6eb01ca466..8bb2b41e2f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2136,6 +2136,9 @@ dist_patch_DATA = \ %D%/packages/patches/rust-ndarray-0.13-remove-blas-src.patch \ %D%/packages/patches/rust-ndarray-0.14-remove-blas-src.patch \ %D%/packages/patches/rust-nettle-disable-vendor.patch \ + %D%/packages/patches/rust-onenote-parser-for-clamav-deps.patch \ + %D%/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch \ + %D%/packages/patches/rust-onenote-parser-for-clamav-property-type.patch \ %D%/packages/patches/rust-poem-1-fewer-deps.patch \ %D%/packages/patches/rust-rspec-1-remove-clippy.patch \ %D%/packages/patches/rust-trash-2-update-windows.patch \ diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm index 2ba9ca3bf0..e7124b088d 100644 --- a/gnu/packages/crates-io.scm +++ b/gnu/packages/crates-io.scm @@ -49347,6 +49347,33 @@ (define-public rust-onenote-parser-0.3 "This package provides a parser for Microsoft OneNote files.") (license license:mpl2.0))) +(define-public rust-onenote-parser-for-clamav + (package + (inherit rust-onenote-parser-0.3) + (name "rust-onenote-parser-for-clamav") + (source (origin + (inherit (package-source rust-onenote-parser-0.3)) + (patches + (search-patches + "rust-onenote-parser-for-clamav-deps.patch" + "rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch" + "rust-onenote-parser-for-clamav-property-type.patch")) + (snippet #~(begin + (delete-file "Cargo.toml") + (rename-file "Cargo.toml.orig" "Cargo.toml"))))) + (arguments + `(#:cargo-inputs + (("rust-bytes" ,rust-bytes-1) + ("rust-encoding-rs" ,rust-encoding-rs-0.8) + ("rust-enum-primitive-derive" ,rust-enum-primitive-derive-0.2) + ("rust-itertools" ,rust-itertools-0.10) + ("rust-num-traits" ,rust-num-traits-0.2) + ("rust-paste" ,rust-paste-1) + ("rust-thiserror" ,rust-thiserror-1) + ("rust-uuid" ,rust-uuid-1) + ("rust-widestring" ,rust-widestring-1)) + #:cargo-development-inputs (("rust-insta" ,rust-insta-1)))))) + (define-public rust-onig-6 (package (name "rust-onig") diff --git a/gnu/packages/patches/rust-onenote-parser-for-clamav-deps.patch b/gnu/packages/patches/rust-onenote-parser-for-clamav-deps.patch new file mode 100644 index 0000000000..24d5692573 --- /dev/null +++ b/gnu/packages/patches/rust-onenote-parser-for-clamav-deps.patch @@ -0,0 +1,88 @@ +From f940d8c8fa087554583158d50df071af89c516db Mon Sep 17 00:00:00 2001 +From: Simon Lamon <32477463+silamon@users.noreply.github.com> +Date: Sat, 19 Nov 2022 20:32:07 +0100 +Subject: [PATCH] chore: upgrade dependencies (#9) + +Co-authored-by: Markus Siemens +--- + Cargo.toml.orig | 8 ++++---- + src/errors.rs | 6 +++--- + src/reader.rs | 2 +- + src/utils.rs | 5 ++--- + 4 files changed, 10 insertions(+), 11 deletions(-) + +diff --git a/Cargo.toml.orig b/Cargo.toml.orig +index 9afddd0..e302436 100644 +--- a/Cargo.toml.orig ++++ b/Cargo.toml.orig +@@ -14,15 +14,15 @@ categories = ["parser-implementations"] + backtrace = [] + + [dependencies] +-bytes = "0.5" ++bytes = "1.2.0" + encoding_rs = "0.8.31" + enum-primitive-derive = "0.2.2" +-itertools = "0.9.0" ++itertools = "0.10.3" + num-traits = "0.2" + paste = "1.0" + thiserror = "1.0" +-uuid = "0.8" +-widestring = "0.4.3" ++uuid = "1.1.2" ++widestring = "1.0.2" + + [dev-dependencies] + insta = "1.21.1" +diff --git a/src/errors.rs b/src/errors.rs +index 91477b3..50079a3 100644 +--- a/src/errors.rs ++++ b/src/errors.rs +@@ -51,8 +51,8 @@ impl From for Error { + } + } + +-impl From> for Error { +- fn from(err: widestring::MissingNulError) -> Self { ++impl From for Error { ++ fn from(err: widestring::error::MissingNulTerminator) -> Self { + ErrorKind::from(err).into() + } + } +@@ -128,6 +128,6 @@ pub enum ErrorKind { + #[error("UTF-16 string is missing null terminator: {err}")] + Utf16MissingNull { + #[from] +- err: widestring::MissingNulError, ++ err: widestring::error::MissingNulTerminator, + }, + } +diff --git a/src/reader.rs b/src/reader.rs +index 64730d0..318c280 100644 +--- a/src/reader.rs ++++ b/src/reader.rs +@@ -40,7 +40,7 @@ impl<'a> Reader<'a> { + } + + pub(crate) fn bytes(&self) -> &[u8] { +- self.0.bytes() ++ self.0.chunk() + } + + pub(crate) fn remaining(&self) -> usize { +diff --git a/src/utils.rs b/src/utils.rs +index fd77181..074ff50 100644 +--- a/src/utils.rs ++++ b/src/utils.rs +@@ -12,8 +12,7 @@ impl Utf16ToString for &[u8] { + .map(|v| u16::from_le_bytes([v[0], v[1]])) + .collect(); + +- let value = U16CString::from_vec_with_nul(data)?; +- +- Ok(value.to_string()?) ++ let value = U16CString::from_vec_truncate(data); ++ Ok(value.to_string().unwrap()) + } + } diff --git a/gnu/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch b/gnu/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch new file mode 100644 index 0000000000..77adc550ca --- /dev/null +++ b/gnu/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch @@ -0,0 +1,52 @@ +From 8b450447e58143004b68dd21c11b710fdb79be92 Mon Sep 17 00:00:00 2001 +From: Micah Snyder +Date: Mon, 3 Jul 2023 21:44:57 -0700 +Subject: [PATCH] Add ability to parse section from in memory buffer + +Resolves: https://github.com/msiemens/onenote.rs/issues/12 +--- + src/onenote/mod.rs | 23 ++++++++++++++++++++++- + 1 file changed, 22 insertions(+), 1 deletion(-) + +diff --git a/src/onenote/mod.rs b/src/onenote/mod.rs +index de172c9..8bcb62b 100644 +--- a/src/onenote/mod.rs ++++ b/src/onenote/mod.rs +@@ -6,8 +6,9 @@ use crate::onestore::parse_store; + use crate::reader::Reader; + use std::ffi::OsStr; + use std::fs::File; +-use std::io::{BufReader, Read}; ++use std::io::{BufReader, Read, Cursor}; + use std::path::Path; ++use std::str::FromStr; + + pub(crate) mod content; + pub(crate) mod embedded_file; +@@ -76,6 +77,26 @@ impl Parser { + Ok(Notebook { entries: sections }) + } + ++ /// Parse a OneNote section buffer. ++ /// ++ /// The `data` argument must contain a OneNote section. ++ pub fn parse_section_buffer(&mut self, data: &[u8], file_name: &Path) -> Result
{ ++ let packaging = OneStorePackaging::parse(&mut Reader::new(data))?; ++ let store = parse_store(&packaging)?; ++ ++ if store.schema_guid() != guid!({1F937CB4-B26F-445F-B9F8-17E20160E461}) { ++ return Err(ErrorKind::NotASectionFile { ++ file: file_name.to_string_lossy().into_owned(), ++ } ++ .into()); ++ } ++ ++ section::parse_section( ++ store, ++ file_name.to_string_lossy().into_owned(), ++ ) ++ } ++ + /// Parse a OneNote section file. + /// + /// The `path` argument must point to a `.one` file that contains a diff --git a/gnu/packages/patches/rust-onenote-parser-for-clamav-property-type.patch b/gnu/packages/patches/rust-onenote-parser-for-clamav-property-type.patch new file mode 100644 index 0000000000..ff94fa2630 --- /dev/null +++ b/gnu/packages/patches/rust-onenote-parser-for-clamav-property-type.patch @@ -0,0 +1,30 @@ +From 29c08532252b917543ff268284f926f30876bb79 Mon Sep 17 00:00:00 2001 +From: Matt Jolly +Date: Mon, 24 Jun 2024 17:34:05 +1000 +Subject: [PATCH] PropertType: Specify type for custom discriminant values + +We use custom discriminant values for enum variants for "PropertType" without specifying the type. +This causes it to default to "isize" which on 64bit platforms is big enough to hold the 32bit constants, +but causes overflow when isize is 32bit. + +This issue was uncovered due to build failures on arm for Gentoo Linux as a dependency of ClamAV. + +Bug: https://bugs.gentoo.org/927214 +Signed-off-by: Matt Jolly +Co-authored-by: Steven Newbury +--- + src/one/property/mod.rs | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/one/property/mod.rs b/src/one/property/mod.rs +index 42841c6..fcc0481 100644 +--- a/src/one/property/mod.rs ++++ b/src/one/property/mod.rs +@@ -23,6 +23,7 @@ mod references; + pub(crate) mod simple; + pub(crate) mod time; + ++#[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq)] + #[allow(dead_code)] + #[allow(clippy::enum_clike_unportable_variant)]