aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/gen_encode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/gen_encode.c')
-rw-r--r--lib/asn1/gen_encode.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/asn1/gen_encode.c b/lib/asn1/gen_encode.c
index 1bd47484d83a..60433a00e705 100644
--- a/lib/asn1/gen_encode.c
+++ b/lib/asn1/gen_encode.c
@@ -33,8 +33,6 @@
#include "gen_locl.h"
-RCSID("$Id$");
-
static void
encode_primitive (const char *typename, const char *name)
{
@@ -50,7 +48,7 @@ classname(Der_class class)
{
const char *cn[] = { "ASN1_C_UNIV", "ASN1_C_APPL",
"ASN1_C_CONTEXT", "ASN1_C_PRIV" };
- if(class < ASN1_C_UNIV || class > ASN1_C_PRIVATE)
+ if ((int)class >= sizeof(cn) / sizeof(cn[0]))
return "???";
return cn[class];
}
@@ -129,15 +127,18 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
fprintf(codefile, "}\n;");
} else if (t->range == NULL) {
encode_primitive ("heim_integer", name);
- } else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {
+ } else if (t->range->min < INT_MIN && t->range->max <= INT64_MAX) {
+ encode_primitive ("integer64", name);
+ } else if (t->range->min >= 0 && t->range->max > UINT_MAX) {
+ encode_primitive ("unsigned64", name);
+ } else if (t->range->min >= INT_MIN && t->range->max <= INT_MAX) {
encode_primitive ("integer", name);
- } else if (t->range->min == 0 && t->range->max == UINT_MAX) {
- encode_primitive ("unsigned", name);
- } else if (t->range->min == 0 && t->range->max == INT_MAX) {
+ } else if (t->range->min >= 0 && t->range->max <= UINT_MAX) {
encode_primitive ("unsigned", name);
} else
- errx(1, "%s: unsupported range %d -> %d",
- name, t->range->min, t->range->max);
+ errx(1, "%s: unsupported range %lld -> %lld",
+ name, (long long)t->range->min, (long long)t->range->max);
+
constructed = 0;
break;
case TBoolean:
@@ -287,7 +288,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
fprintf(codefile,
"{\n"
- "struct heim_octet_string *val;\n"
+ "heim_octet_string *val;\n"
"size_t elen = 0, totallen = 0;\n"
"int eret = 0;\n");