]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
pki: Don't remove zero bytes in CRL serials anymore
authorTobias Brunner <tobias@strongswan.org>
Mon, 3 Oct 2016 10:15:10 +0000 (12:15 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 11 Oct 2016 15:18:22 +0000 (17:18 +0200)
This was added a few years ago because pki --signcrl once encoded serials
incorrectly as eight byte blobs.  But still ensure we have can handle
overflows in case the serial is encoded incorrectly without zero-prefix.

src/pki/commands/signcrl.c

index 6d873d326f507608bfea6d1b1da3de9bafe74770..b9cf9c4666a863abd3e06b08ba1b9b7d3b5fc369 100644 (file)
@@ -376,14 +376,15 @@ static int sign_crl()
                lastenum = enumerator_create_empty();
        }
 
-       /* remove superfluous leading zeros */
-       while (crl_serial.len > 1 && crl_serial.ptr[0] == 0x00 &&
-                 (crl_serial.ptr[1] & 0x80) == 0x00)
+       if (!crl_serial.len || crl_serial.ptr[0] & 0x80)
+       {       /* add leading 0x00 to handle potential overflow if serial is encoded
+                * incorrectly */
+               crl_serial = chunk_cat("cc", chunk_from_chars(0x00), crl_serial);
+       }
+       else
        {
-               crl_serial = chunk_skip_zero(crl_serial);
+               crl_serial = chunk_clone(crl_serial);
        }
-       crl_serial = chunk_clone(crl_serial);
-
        /* increment the serial number by one */
        chunk_increment(crl_serial);