From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
To: 43699@debbugs.gnu.org
Subject: [bug#43699] [PATCH] guix: Fix argument order of fxbit-set?
Date: Tue, 29 Sep 2020 10:29:23 +0200 [thread overview]
Message-ID: <20200929082923.GA7294@zpidnp36> (raw)
[-- Attachment #1: Type: text/plain, Size: 4257 bytes --]
* guix/openpgp.scm (port-ascii-armored?): Fix it here…
(get-packet*): …and here…
(parse-subpackets): …and also here.
* tests/openpgp.scm (%binary-sample): New test vector.
("port-ascii-armored?, #t"): Add test.
("port-ascii-armored?, #f"): Add another test.
---
guix/openpgp.scm | 14 +++++++-------
tests/openpgp.scm | 12 ++++++++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/guix/openpgp.scm b/guix/openpgp.scm
index 33c851255b..f6c9f8ac78 100644
--- a/guix/openpgp.scm
+++ b/guix/openpgp.scm
@@ -239,7 +239,7 @@ writes to PORT the value 42 as an 8-bit integer and the value #x7777 as a
(let ((idx (fxarithmetic-shift-right i 3))
(bit (fxand i #b111)))
(and (< idx (bytevector-length bv))
- (fxbit-set? (bytevector-u8-ref bv idx) bit))))
+ (fxbit-set? bit (bytevector-u8-ref bv idx)))))
(do ((names names (cdr names))
(i 0 (fx+ i 1))
(bits '()
@@ -410,9 +410,9 @@ hexadecimal format for fingerprints."
(define (port-ascii-armored? p)
(let ((tag (lookahead-u8 p)))
(cond ((eof-object? tag) #f)
- ((not (fxbit-set? tag 7)) #t)
+ ((not (fxbit-set? 7 tag)) #t)
(else
- (let ((type (if (fxbit-set? tag 6)
+ (let ((type (if (fxbit-set? 6 tag)
(fxbit-field tag 0 6)
(fxbit-field tag 2 6))))
(not (<= PACKET-SESSION-KEY type PACKET-MDC)))))))
@@ -444,7 +444,7 @@ hexadecimal format for fingerprints."
(define (get-packet* p get-data)
(let ((tag (get-u8 p)))
;; (unless (fxbit-set? tag 7) (error 'get-packet "Invalid tag" tag))
- (cond ((fxbit-set? tag 6) ;New packet format
+ (cond ((fxbit-set? 6 tag) ;New packet format
(let ((tag (fxbit-field tag 0 6))
(len (get-v4-length p)))
(get-data p tag len)))
@@ -726,7 +726,7 @@ FINGERPRINT, a bytevector."
(define (parse-subpackets bv signature-port)
(define (parse tag data)
(let ((type (fxbit-field tag 0 7))
- (critical? (fxbit-set? tag 7)))
+ (critical? (fxbit-set? 7 tag)))
(cond
((= type SUBPACKET-SIGNATURE-CTIME)
(cons 'signature-ctime
@@ -764,7 +764,7 @@ FINGERPRINT, a bytevector."
(value (get-bytevector-n p vlen)))
(cons 'notation-data
(list (utf8->string name)
- (if (fxbit-set? f1 7)
+ (if (fxbit-set? 7 f1)
(utf8->string value)
value)))))))
((= type SUBPACKET-PREFERRED-HASH-ALGORITHMS)
@@ -777,7 +777,7 @@ FINGERPRINT, a bytevector."
((= type SUBPACKET-KEY-SERVER-PREFERENCES)
(cons 'key-server-preferences
(if (and (>= (bytevector-length data) 1)
- (fxbit-set? (bytevector-u8-ref data 0) 7))
+ (fxbit-set? 7 (bytevector-u8-ref data 0)))
(list 'no-modify)
(list))))
((= type SUBPACKET-PREFERRED-KEY-SERVER)
diff --git a/tests/openpgp.scm b/tests/openpgp.scm
index 0beab6f88b..c2be26fa49 100644
--- a/tests/openpgp.scm
+++ b/tests/openpgp.scm
@@ -50,6 +50,12 @@ vBSFjNSiVHsuAA==
=AAAA
-----END PGP MESSAGE-----\n")
+(define %binary-sample
+ ;; Same message as %radix-64-sample, decoded into bytevector.
+ (base16-string->bytevector
+ "c838013b6d96c411efecef17ecefe3ca0004ce8979ea250a897995f979a9\
+0ad9a9a9050a890ac5a9c945a940c1a2fcd2bc14858cd4a2547b2e00"))
+
(define %civodul-fingerprint
"3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5")
@@ -155,6 +161,12 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
read-radix-64))
list))
+(test-assert "port-ascii-armored?, #t"
+ (call-with-input-string %radix-64-sample port-ascii-armored?))
+
+(test-assert "port-ascii-armored?, #f"
+ (not (port-ascii-armored? (open-bytevector-input-port %binary-sample))))
+
(test-assert "get-openpgp-keyring"
(let* ((key (search-path %load-path "tests/civodul.key"))
(keyring (get-openpgp-keyring
--
2.26.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next reply other threads:[~2020-09-29 8:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 8:29 Lars-Dominik Braun [this message]
2020-09-29 20:56 ` bug#43699: [PATCH] guix: Fix argument order of fxbit-set? Ludovic Courtès
2020-09-30 6:30 ` [bug#43699] " Lars-Dominik Braun
2020-09-30 9:34 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200929082923.GA7294@zpidnp36 \
--to=ldb@leibniz-psychology.org \
--cc=43699@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).