GNU bug report logs - #43699
[PATCH] guix: Fix argument order of fxbit-set?

Previous Next

Package: guix-patches;

Reported by: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>

Date: Tue, 29 Sep 2020 08:30:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43699 in the body.
You can then email your comments to 43699 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#43699; Package guix-patches. (Tue, 29 Sep 2020 08:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lars-Dominik Braun <ldb <at> leibniz-psychology.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 29 Sep 2020 08:30:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>
To: guix-patches <at> gnu.org
Subject: [PATCH] guix: Fix argument order of fxbit-set?
Date: Tue, 29 Sep 2020 10:29:23 +0200
[Message part 1 (text/plain, inline)]
* 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

[signature.asc (application/pgp-signature, inline)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 29 Sep 2020 20:57:01 GMT) Full text and rfc822 format available.

Notification sent to Lars-Dominik Braun <ldb <at> leibniz-psychology.org>:
bug acknowledged by developer. (Tue, 29 Sep 2020 20:57:01 GMT) Full text and rfc822 format available.

Message #10 received at 43699-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>
Cc: 43699-done <at> debbugs.gnu.org
Subject: Re: [bug#43699] [PATCH] guix: Fix argument order of fxbit-set?
Date: Tue, 29 Sep 2020 22:56:08 +0200
Hello!

Lars-Dominik Braun <ldb <at> leibniz-psychology.org> skribis:

> * 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.

Good catch!

The root problem is that the ‘fxbit-set?’ alias defined at the top of
openpgp.scm had the arguments swapped compared to ‘bit-set?’.  So I
changed that alias instead of changing its users (‘fxbit-set?’ is
defined in R6RS).

Pushed as 680b80e37453d4e23ad8188d60894916e1c07162 along with the new
tests.

Thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#43699; Package guix-patches. (Wed, 30 Sep 2020 06:31:01 GMT) Full text and rfc822 format available.

Message #13 received at 43699-done <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 43699-done <at> debbugs.gnu.org
Subject: Re: [bug#43699] [PATCH] guix: Fix argument order of fxbit-set?
Date: Wed, 30 Sep 2020 08:30:51 +0200
[Message part 1 (text/plain, inline)]
Hi Ludo,

> The root problem is that the ‘fxbit-set?’ alias defined at the top of
> openpgp.scm had the arguments swapped compared to ‘bit-set?’.  So I
> changed that alias instead of changing its users (‘fxbit-set?’ is
> defined in R6RS).
oh, okay. I looked at SRFI 143 which also has a fxbit-set? with the same
argument order as bit-set?, so I thought the alias was mimicking that API. But
this works too I guess.

Thanks,
Lars

[1] https://srfi.schemers.org/srfi-143/srfi-143.html
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#43699; Package guix-patches. (Wed, 30 Sep 2020 09:35:02 GMT) Full text and rfc822 format available.

Message #16 received at 43699-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars-Dominik Braun <ldb <at> leibniz-psychology.org>
Cc: 43699-done <at> debbugs.gnu.org
Subject: Re: [bug#43699] [PATCH] guix: Fix argument order of fxbit-set?
Date: Wed, 30 Sep 2020 11:34:44 +0200
Hi,

Lars-Dominik Braun <ldb <at> leibniz-psychology.org> skribis:

>> The root problem is that the ‘fxbit-set?’ alias defined at the top of
>> openpgp.scm had the arguments swapped compared to ‘bit-set?’.  So I
>> changed that alias instead of changing its users (‘fxbit-set?’ is
>> defined in R6RS).
> oh, okay. I looked at SRFI 143 which also has a fxbit-set? with the same
> argument order as bit-set?, so I thought the alias was mimicking that API. But
> this works too I guess.

Oh, didn’t know about that SRFI; that’s the beauty of Scheme: 10
“standard” interfaces for the same thing.  :-)

This OpenPGP code originates from R6RS (Göran Weinholt’s Industria
library and related code) so I think that was right.

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 28 Oct 2020 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 233 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.