double check that parsing a list consumes all bytes
authorMartin Willi <martin@strongswan.org>
Wed, 17 Jun 2009 11:38:05 +0000 (13:38 +0200)
committerMartin Willi <martin@strongswan.org>
Wed, 17 Jun 2009 11:38:05 +0000 (13:38 +0200)
src/charon/encoding/parser.c

index 3e333f7..76ae32f 100644 (file)
@@ -329,6 +329,12 @@ static bool parse_list(private_parser_t *this, int rule_number,
                list->insert_last(list, payload);
                length -= this->byte_pos - pos_before;
        }
+       if (length != 0)
+       {       /* must yield exactly to zero */
+               DBG1(DBG_ENC, "  length of %N substructure list invalid",
+                        payload_type_names, payload_type);
+               return FALSE;
+       }
        *output_pos = list;
        return TRUE;
 }