]> the.earth.li Git - onak.git/commitdiff
Add sanity check for PGP packet version
authorJonathan McDowell <noodles@earth.li>
Mon, 22 Aug 2016 22:14:24 +0000 (23:14 +0100)
committerJonathan McDowell <noodles@earth.li>
Mon, 22 Aug 2016 22:14:24 +0000 (23:14 +0100)
At present only PGP packet versions up to 4 are supported. There's no
indication version 5+ will be backwards compatible, so if we see
anything higher it indicates something unsupported. Fixes some issues
found using American Fuzzy Lop.

parsekey.c

index 008248e005633f0563d9bdcd409c61130cfc1423..f9b1465b78dece1a18c2cde309cfb937d69bcab6 100644 (file)
@@ -354,6 +354,12 @@ onak_status_t read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count,
                } else {
                        rc = ONAK_E_INVALID_PKT;
                }
+               if (rc == ONAK_E_OK) {
+                       /* Make sure the packet version is sane */
+                       if (curpacket->packet->data[0] > 4) {
+                               rc = ONAK_E_INVALID_PKT;
+                       }
+               }
        }
 
        if (packetend != NULL) {