poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [COMMITTED] pickles: openpgp: add constraint to check for a packet


From: apache2
Subject: Re: [COMMITTED] pickles: openpgp: add constraint to check for a packet payload size
Date: Thu, 14 Apr 2022 22:55:47 +0200
User-agent: Mutt/1.9.3 (2018-01-21)

I pushed a fix for a typo in PGP_Packet_Header, and added alignto() in the MPI 
decoding

commit d8577d508ddde6027c9f8c6ff2e1f5fb2e36f678
Author: apache2 <apache2+poke-devel@ageinghacker.net>
Date:   Thu Apr 14 20:24:21 2022 +0200

    pickles/openpgp.pk: MPI lengths are bit, we need to round up to nearest 
byte when using the length as byte array indices. Also fixes a typo in the 
length; field where the union would use PGP_V3_Packet_Length no matter what.

diff --git a/pickles/openpgp.pk b/pickles/openpgp.pk
index 72f5a190..c1ecef9a 100644
--- a/pickles/openpgp.pk
+++ b/pickles/openpgp.pk
@@ -120,7 +120,7 @@ type PGP_Packet_Header =
 
     union
     {
-      PGP_V3_Packet_Length v4_length : v4_format;
+      PGP_V4_Packet_Length v4_length : v4_format;
       PGP_V3_Packet_Length v3_length;
     } length;
 
@@ -150,7 +150,7 @@ type PGP_MPI =
   struct
   {
     big offset<uint<16>,b> len;
-    byte[len] num; /* Bytes are stored in big-endian.  */
+    byte[len + alignto(len,1#B) ] num; /* Bytes are stored in big-endian.  */
 
     method _print = void:
     {
@@ -273,7 +273,6 @@ type PGP_Signature =
     uint<8> hash_algo;
     offset<uint<16>,B> hashed_subpacket_len;
     byte[hashed_subpacket_len] hashed_subpackets;
-    byte[hashed_subpacket_len - hashed_subpackets'size] what_the_fuck;
     uint<16> unhashed_subpacket_len;
     byte[unhashed_subpacket_len] unhashed_subpackets;
 
@@ -327,7 +326,7 @@ type PGP_Packet =
       PGP_Public_Key public   : header.get_tag == 6;
       UID uid                 : header.get_tag == 13;
       byte[header.get_length] unknown;
-    } payload : payload'size == header.get_length;
+    } payload ; //: payload'size == header.get_length; // TODO commented out 
because "extraneous" catches it below.
 
     var extraneous = header.get_length - payload'size;
     byte[extraneous] extra if payload'size'magnitude;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]