Check range on SEQ OF and OCTET STRING.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21395 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -202,6 +202,32 @@ find_tag (const Type *t,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
range_check(const char *name,
|
||||||
|
const char *length,
|
||||||
|
const char *forwstr,
|
||||||
|
struct range *r)
|
||||||
|
{
|
||||||
|
if (r->min == r->max + 2 || r->min < r->max)
|
||||||
|
fprintf (codefile,
|
||||||
|
"if ((%s)->%s > %d) {\n"
|
||||||
|
"e = ASN1_MAX_CONSTRAINT; %s;\n"
|
||||||
|
"}\n",
|
||||||
|
name, length, r->max, forwstr);
|
||||||
|
if (r->min - 1 == r->max || r->min < r->max)
|
||||||
|
fprintf (codefile,
|
||||||
|
"if ((%s)->%s < %d) {\n"
|
||||||
|
"e = ASN1_MIN_CONSTRAINT; %s;\n"
|
||||||
|
"}\n",
|
||||||
|
name, length, r->min, forwstr);
|
||||||
|
if (r->max == r->min)
|
||||||
|
fprintf (codefile,
|
||||||
|
"if ((%s)->%s != %d) {\n"
|
||||||
|
"e = ASN1_EXACT_CONSTRAINT; %s;\n"
|
||||||
|
"}\n",
|
||||||
|
name, length, r->min, forwstr);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
decode_type (const char *name, const Type *t, int optional,
|
decode_type (const char *name, const Type *t, int optional,
|
||||||
const char *forwstr, const char *tmpstr)
|
const char *forwstr, const char *tmpstr)
|
||||||
@@ -262,6 +288,8 @@ decode_type (const char *name, const Type *t, int optional,
|
|||||||
break;
|
break;
|
||||||
case TOctetString:
|
case TOctetString:
|
||||||
decode_primitive ("octet_string", name, forwstr);
|
decode_primitive ("octet_string", name, forwstr);
|
||||||
|
if (t->range)
|
||||||
|
range_check(name, "length", forwstr, t->range);
|
||||||
break;
|
break;
|
||||||
case TBitString: {
|
case TBitString: {
|
||||||
Member *m;
|
Member *m;
|
||||||
@@ -437,6 +465,8 @@ decode_type (const char *name, const Type *t, int optional,
|
|||||||
"}\n",
|
"}\n",
|
||||||
name,
|
name,
|
||||||
tmpstr, tmpstr);
|
tmpstr, tmpstr);
|
||||||
|
if (t->range)
|
||||||
|
range_check(name, "len", forwstr, t->range);
|
||||||
free (n);
|
free (n);
|
||||||
free (sname);
|
free (sname);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user