summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/asn1')
-rw-r--r--source4/heimdal/lib/asn1/asn1parse.y5
-rw-r--r--source4/heimdal/lib/asn1/der_get.c34
-rw-r--r--source4/heimdal/lib/asn1/gen.c7
-rw-r--r--source4/heimdal/lib/asn1/gen_copy.c3
-rw-r--r--source4/heimdal/lib/asn1/gen_decode.c14
-rw-r--r--source4/heimdal/lib/asn1/gen_encode.c5
-rw-r--r--source4/heimdal/lib/asn1/gen_free.c3
-rw-r--r--source4/heimdal/lib/asn1/gen_length.c3
-rw-r--r--source4/heimdal/lib/asn1/rfc2459.asn14
-rw-r--r--source4/heimdal/lib/asn1/symbol.h1
10 files changed, 58 insertions, 21 deletions
diff --git a/source4/heimdal/lib/asn1/asn1parse.y b/source4/heimdal/lib/asn1/asn1parse.y
index 7975fe4f6b..3835744bbd 100644
--- a/source4/heimdal/lib/asn1/asn1parse.y
+++ b/source4/heimdal/lib/asn1/asn1parse.y
@@ -687,6 +687,11 @@ RestrictedCharactedStringType: kw_GeneralString
$$ = new_tag(ASN1_C_UNIV, UT_GeneralString,
TE_EXPLICIT, new_type(TGeneralString));
}
+ | kw_TeletexString
+ {
+ $$ = new_tag(ASN1_C_UNIV, UT_TeletexString,
+ TE_EXPLICIT, new_type(TTeletexString));
+ }
| kw_UTF8String
{
$$ = new_tag(ASN1_C_UNIV, UT_UTF8String,
diff --git a/source4/heimdal/lib/asn1/der_get.c b/source4/heimdal/lib/asn1/der_get.c
index aee565040f..5a062fb339 100644
--- a/source4/heimdal/lib/asn1/der_get.c
+++ b/source4/heimdal/lib/asn1/der_get.c
@@ -305,7 +305,7 @@ der_get_octet_string_ber (const unsigned char *p, size_t len,
void *ptr;
ptr = realloc(data->data, data->length + datalen);
- if (ptr == NULL) {
+ if (ptr == NULL && data->length + datalen != 0) {
e = ENOMEM;
goto out;
}
@@ -354,21 +354,23 @@ der_get_heim_integer (const unsigned char *p, size_t len,
p++;
data->length--;
}
- data->data = malloc(data->length);
- if (data->data == NULL) {
- data->length = 0;
- if (size)
- *size = 0;
- return ENOMEM;
- }
- q = &((unsigned char*)data->data)[data->length - 1];
- p += data->length - 1;
- while (q >= (unsigned char*)data->data) {
- *q = *p ^ 0xff;
- if (carry)
- carry = !++*q;
- p--;
- q--;
+ if (data->length) {
+ data->data = malloc(data->length);
+ if (data->data == NULL) {
+ data->length = 0;
+ if (size)
+ *size = 0;
+ return ENOMEM;
+ }
+ q = &((unsigned char*)data->data)[data->length - 1];
+ p += data->length - 1;
+ while (q >= (unsigned char*)data->data) {
+ *q = *p ^ 0xff;
+ if (carry)
+ carry = !++*q;
+ p--;
+ q--;
+ }
}
} else {
data->negative = 0;
diff --git a/source4/heimdal/lib/asn1/gen.c b/source4/heimdal/lib/asn1/gen.c
index e156c7cefb..780c18b36f 100644
--- a/source4/heimdal/lib/asn1/gen.c
+++ b/source4/heimdal/lib/asn1/gen.c
@@ -494,6 +494,9 @@ define_asn1 (int level, Type *t)
case TGeneralString:
fprintf (headerfile, "GeneralString");
break;
+ case TTeletexString:
+ fprintf (headerfile, "TeletexString");
+ break;
case TTag: {
const char *classnames[] = { "UNIVERSAL ", "APPLICATION ",
"" /* CONTEXT */, "PRIVATE " };
@@ -685,6 +688,10 @@ define_type (int level, const char *name, Type *t, int typedefp, int preservep)
space(level);
fprintf (headerfile, "heim_general_string %s;\n", name);
break;
+ case TTeletexString:
+ space(level);
+ fprintf (headerfile, "heim_general_string %s;\n", name);
+ break;
case TTag:
define_type (level, name, t->subtype, typedefp, preservep);
break;
diff --git a/source4/heimdal/lib/asn1/gen_copy.c b/source4/heimdal/lib/asn1/gen_copy.c
index 5042ed64ed..f28647d19a 100644
--- a/source4/heimdal/lib/asn1/gen_copy.c
+++ b/source4/heimdal/lib/asn1/gen_copy.c
@@ -184,6 +184,9 @@ copy_type (const char *from, const char *to, const Type *t, int preserve)
case TGeneralString:
copy_primitive ("general_string", from, to);
break;
+ case TTeletexString:
+ copy_primitive ("general_string", from, to);
+ break;
case TUTCTime:
fprintf(codefile, "*(%s) = *(%s);\n", to, from);
break;
diff --git a/source4/heimdal/lib/asn1/gen_decode.c b/source4/heimdal/lib/asn1/gen_decode.c
index cf7f0b05dc..327de4c98c 100644
--- a/source4/heimdal/lib/asn1/gen_decode.c
+++ b/source4/heimdal/lib/asn1/gen_decode.c
@@ -67,6 +67,7 @@ is_primitive_type(int type)
case TEnumerated:
case TGeneralizedTime:
case TGeneralString:
+ case TTeletexString:
case TOID:
case TUTCTime:
case TUTF8String:
@@ -109,6 +110,11 @@ find_tag (const Type *t,
*ty = PRIM;
*tag = UT_GeneralString;
break;
+ case TTeletexString:
+ *cl = ASN1_C_UNIV;
+ *ty = PRIM;
+ *tag = UT_TeletexString;
+ break;
case TGeneralizedTime:
*cl = ASN1_C_UNIV;
*ty = PRIM;
@@ -489,6 +495,9 @@ decode_type (const char *name, const Type *t, int optional,
case TGeneralString:
decode_primitive ("general_string", name, forwstr);
break;
+ case TTeletexString:
+ decode_primitive ("general_string", name, forwstr);
+ break;
case TTag:{
char *tname, *typestring;
char *ide = NULL;
@@ -621,7 +630,7 @@ decode_type (const char *name, const Type *t, int optional,
fprintf(codefile,
"else {\n"
"(%s)->u.%s.data = calloc(1, len);\n"
- "if ((%s)->u.%s.data == NULL) {\n"
+ "if ((%s)->u.%s.data == NULL && len != 0) {\n"
"e = ENOMEM; %s;\n"
"}\n"
"(%s)->u.%s.length = len;\n"
@@ -703,6 +712,7 @@ generate_type_decode (const Symbol *s)
case TOID:
case TGeneralizedTime:
case TGeneralString:
+ case TTeletexString:
case TUTF8String:
case TPrintableString:
case TIA5String:
@@ -734,7 +744,7 @@ generate_type_decode (const Symbol *s)
if (preserve)
fprintf (codefile,
"data->_save.data = calloc(1, ret);\n"
- "if (data->_save.data == NULL) { \n"
+ "if (data->_save.data == NULL && ret != 0) { \n"
"e = ENOMEM; goto fail; \n"
"}\n"
"data->_save.length = ret;\n"
diff --git a/source4/heimdal/lib/asn1/gen_encode.c b/source4/heimdal/lib/asn1/gen_encode.c
index 1f8078a0ee..012d4677f4 100644
--- a/source4/heimdal/lib/asn1/gen_encode.c
+++ b/source4/heimdal/lib/asn1/gen_encode.c
@@ -383,6 +383,10 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
encode_primitive ("general_string", name);
constructed = 0;
break;
+ case TTeletexString:
+ encode_primitive ("general_string", name);
+ constructed = 0;
+ break;
case TTag: {
char *tname;
int c;
@@ -521,6 +525,7 @@ generate_type_encode (const Symbol *s)
case TOctetString:
case TGeneralizedTime:
case TGeneralString:
+ case TTeletexString:
case TUTCTime:
case TUTF8String:
case TPrintableString:
diff --git a/source4/heimdal/lib/asn1/gen_free.c b/source4/heimdal/lib/asn1/gen_free.c
index fac1f6da5d..48fe8cd787 100644
--- a/source4/heimdal/lib/asn1/gen_free.c
+++ b/source4/heimdal/lib/asn1/gen_free.c
@@ -145,6 +145,9 @@ free_type (const char *name, const Type *t, int preserve)
case TGeneralString:
free_primitive ("general_string", name);
break;
+ case TTeletexString:
+ free_primitive ("general_string", name);
+ break;
case TUTF8String:
free_primitive ("utf8string", name);
break;
diff --git a/source4/heimdal/lib/asn1/gen_length.c b/source4/heimdal/lib/asn1/gen_length.c
index 7f9755e2da..e1f045c4c5 100644
--- a/source4/heimdal/lib/asn1/gen_length.c
+++ b/source4/heimdal/lib/asn1/gen_length.c
@@ -219,6 +219,9 @@ length_type (const char *name, const Type *t,
case TGeneralString:
length_primitive ("general_string", name, variable);
break;
+ case TTeletexString:
+ length_primitive ("general_string", name, variable);
+ break;
case TUTCTime:
length_primitive ("utctime", name, variable);
break;
diff --git a/source4/heimdal/lib/asn1/rfc2459.asn1 b/source4/heimdal/lib/asn1/rfc2459.asn1
index 51cac55cc0..9794ca1514 100644
--- a/source4/heimdal/lib/asn1/rfc2459.asn1
+++ b/source4/heimdal/lib/asn1/rfc2459.asn1
@@ -150,11 +150,9 @@ AttributeType ::= OBJECT IDENTIFIER
AttributeValue ::= heim_any
-TeletexStringx ::= [UNIVERSAL 20] IMPLICIT OCTET STRING
-
DirectoryString ::= CHOICE {
ia5String IA5String,
- teletexString TeletexStringx,
+ teletexString TeletexString,
printableString PrintableString,
universalString UniversalString,
utf8String UTF8String,
diff --git a/source4/heimdal/lib/asn1/symbol.h b/source4/heimdal/lib/asn1/symbol.h
index 3a0f807980..a39c8f4651 100644
--- a/source4/heimdal/lib/asn1/symbol.h
+++ b/source4/heimdal/lib/asn1/symbol.h
@@ -44,6 +44,7 @@ enum typetype {
TChoice,
TEnumerated,
TGeneralString,
+ TTeletexString,
TGeneralizedTime,
TIA5String,
TInteger,