From 2be0f1a1a40438370ea321a1c59bd0f31d6c5ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 13 Dec 2011 21:52:05 -0800 Subject: [PATCH] check that we don't use negative size for arrays --- lib/asn1/asn1parse.y | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/asn1/asn1parse.y b/lib/asn1/asn1parse.y index b419676d3..11681ed09 100644 --- a/lib/asn1/asn1parse.y +++ b/lib/asn1/asn1parse.y @@ -47,8 +47,6 @@ #include "gen_locl.h" #include "der.h" -RCSID("$Id$"); - static Type *new_type (Typetype t); static struct constraint_spec *new_constraint_spec(enum ctype); static Type *new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype); @@ -474,6 +472,11 @@ OctetStringType : kw_OCTET kw_STRING size { Type *t = new_type(TOctetString); t->range = $3; + if (t->range) { + if (t->range->min < 0) + lex_error_message("can't use a negative SIZE range " + "length for OCTET STRING"); + } $$ = new_tag(ASN1_C_UNIV, UT_OctetString, TE_EXPLICIT, t); } @@ -511,6 +514,11 @@ SequenceOfType : kw_SEQUENCE size kw_OF Type { $$ = new_type(TSequenceOf); $$->range = $2; + if ($2) { + if ($2->min < 0) + lex_error_message("can't use a negative SIZE range " + "length for SEQUENCE OF"); + } $$->subtype = $4; $$ = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, $$); }