asn1: Better handling of >63 named bits/ints

First, we enlarge Member's val field to int64_t.

Then we warn about skipping 2int, int2, and parse units glue for such
things with too-large members.

And we error out when generating the template for such things with
>UINT32_MAX members.

What about too-negative members?  That could be a thing for INTEGER /
ENUMERATED.  We'll look at that later.
This commit is contained in:
Nicolas Williams
2022-01-17 12:39:19 -06:00
parent bf243c1f41
commit 9fb444983e
6 changed files with 38 additions and 27 deletions

View File

@@ -962,9 +962,12 @@ template_members(struct templatehead *temp,
*/
HEIM_TAILQ_FOREACH(m, t->members, members) {
if (m->val > UINT32_MAX)
continue; /* Wouldn't fit in the offset field */
errx(1, "Cannot handle %s type %s with named bit %s "
"larger than 63",
t->type == TEnumerated ? "ENUMERATED" : "INTEGER",
name, m->gen_name);
add_line(&tl->template,
"{ A1_OP_NAME, %d, \"%s\" }", m->val, m->name);
"{ A1_OP_NAME, %d, \"%s\" }", (int)m->val, m->name);
nmemb++;
}
tlist_header(tl, "{ 0, 0, ((void *)(uintptr_t)%lu) }", nmemb);
@@ -1041,7 +1044,10 @@ template_members(struct templatehead *temp,
output_name(bname);
HEIM_TAILQ_FOREACH(m, t->members, members) {
add_line(&template, "{ 0, %d, \"%s\" }", m->val, m->gen_name);
if (m->val > UINT32_MAX)
errx(1, "Cannot handle BIT STRING type %s with named bit %s "
"larger than 63", name, m->gen_name);
add_line(&template, "{ 0, %d, \"%s\" }", (int)m->val, m->gen_name);
}
HEIM_TAILQ_FOREACH(q, &template, members) {