]> the.earth.li Git - onak.git/blobdiff - parsekey.c
Add sanity check for PGP packet version
[onak.git] / 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) {