diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-07-15 09:10:30 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-07-15 11:15:05 +0200 |
commit | 255e3e18e00f717d99f3bc57c8a8895ff624f3c3 (patch) | |
tree | a2933c88f38e8dd7fe612be8dd458d05918b1f15 /source4/heimdal/lib/asn1 | |
parent | 70da27838bb3f6ed9c36add06ce0ccdf467ab1c3 (diff) | |
download | samba-255e3e18e00f717d99f3bc57c8a8895ff624f3c3.tar.gz samba-255e3e18e00f717d99f3bc57c8a8895ff624f3c3.tar.bz2 samba-255e3e18e00f717d99f3bc57c8a8895ff624f3c3.zip |
s4:heimdal: import lorikeet-heimdal-201107150856 (commit 48936803fae4a2fb362c79365d31f420c917b85b)
Diffstat (limited to 'source4/heimdal/lib/asn1')
-rw-r--r-- | source4/heimdal/lib/asn1/asn1-common.h | 2 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/asn1parse.c | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/asn1parse.y | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/der_cmp.c | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/der_format.c | 2 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/der_get.c | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/der_length.c | 2 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/der_put.c | 3 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/extra.c | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/gen.c | 6 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/gen_decode.c | 38 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/gen_encode.c | 19 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/gen_free.c | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/gen_template.c | 22 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/krb5.asn1 | 50 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/lex.c | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/lex.l | 4 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/main.c | 2 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/test.asn1 | 3 | ||||
-rw-r--r-- | source4/heimdal/lib/asn1/timegm.c | 21 |
20 files changed, 112 insertions, 90 deletions
diff --git a/source4/heimdal/lib/asn1/asn1-common.h b/source4/heimdal/lib/asn1/asn1-common.h index 9c8793e0cc..4083ebc23d 100644 --- a/source4/heimdal/lib/asn1/asn1-common.h +++ b/source4/heimdal/lib/asn1/asn1-common.h @@ -75,5 +75,5 @@ typedef struct heim_octet_string heim_any_set; #define ASN1EXP #define ASN1CALL #endif - + #endif diff --git a/source4/heimdal/lib/asn1/asn1parse.c b/source4/heimdal/lib/asn1/asn1parse.c index 08d068b6a4..8c64a35fca 100644 --- a/source4/heimdal/lib/asn1/asn1parse.c +++ b/source4/heimdal/lib/asn1/asn1parse.c @@ -1905,7 +1905,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 368 "asn1parse.c" - { + { if((yyvsp[(2) - (5)].value)->type != integervalue) lex_error_message("Non-integer in first part of range"); (yyval.range) = ecalloc(1, sizeof(*(yyval.range))); @@ -1918,7 +1918,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 376 "asn1parse.c" - { + { if((yyvsp[(4) - (5)].value)->type != integervalue) lex_error_message("Non-integer in second part of range"); (yyval.range) = ecalloc(1, sizeof(*(yyval.range))); diff --git a/source4/heimdal/lib/asn1/asn1parse.y b/source4/heimdal/lib/asn1/asn1parse.y index a7a8f31827..e3bea6ce0a 100644 --- a/source4/heimdal/lib/asn1/asn1parse.y +++ b/source4/heimdal/lib/asn1/asn1parse.y @@ -365,7 +365,7 @@ range : '(' Value RANGE Value ')' $$->max = $4->u.integervalue; } | '(' Value RANGE kw_MAX ')' - { + { if($2->type != integervalue) lex_error_message("Non-integer in first part of range"); $$ = ecalloc(1, sizeof(*$$)); @@ -373,7 +373,7 @@ range : '(' Value RANGE Value ')' $$->max = $2->u.integervalue - 1; } | '(' kw_MIN RANGE Value ')' - { + { if($4->type != integervalue) lex_error_message("Non-integer in second part of range"); $$ = ecalloc(1, sizeof(*$$)); diff --git a/source4/heimdal/lib/asn1/der_cmp.c b/source4/heimdal/lib/asn1/der_cmp.c index 84aee4cce0..468ccb2d04 100644 --- a/source4/heimdal/lib/asn1/der_cmp.c +++ b/source4/heimdal/lib/asn1/der_cmp.c @@ -53,14 +53,14 @@ der_heim_octet_string_cmp(const heim_octet_string *p, } int -der_printable_string_cmp(const heim_printable_string *p, +der_printable_string_cmp(const heim_printable_string *p, const heim_printable_string *q) { return der_heim_octet_string_cmp(p, q); } int -der_ia5_string_cmp(const heim_ia5_string *p, +der_ia5_string_cmp(const heim_ia5_string *p, const heim_ia5_string *q) { return der_heim_octet_string_cmp(p, q); diff --git a/source4/heimdal/lib/asn1/der_format.c b/source4/heimdal/lib/asn1/der_format.c index fc79a30b56..4f06c1b01f 100644 --- a/source4/heimdal/lib/asn1/der_format.c +++ b/source4/heimdal/lib/asn1/der_format.c @@ -108,7 +108,7 @@ int der_print_heim_oid (const heim_oid *oid, char delim, char **str) { struct rk_strpool *p = NULL; - int i; + size_t i; if (oid->length == 0) return EINVAL; diff --git a/source4/heimdal/lib/asn1/der_get.c b/source4/heimdal/lib/asn1/der_get.c index 3ea0d5ea18..3112da86f9 100644 --- a/source4/heimdal/lib/asn1/der_get.c +++ b/source4/heimdal/lib/asn1/der_get.c @@ -141,9 +141,9 @@ der_get_general_string (const unsigned char *p, size_t len, * an strings in the NEED_PREAUTH case that includes a * trailing NUL. */ - while (p1 - p < len && *p1 == '\0') + while ((size_t)(p1 - p) < len && *p1 == '\0') p1++; - if (p1 - p != len) + if ((size_t)(p1 - p) != len) return ASN1_BAD_CHARACTER; } if (len > len + 1) diff --git a/source4/heimdal/lib/asn1/der_length.c b/source4/heimdal/lib/asn1/der_length.c index 7a41de9d22..db82025861 100644 --- a/source4/heimdal/lib/asn1/der_length.c +++ b/source4/heimdal/lib/asn1/der_length.c @@ -86,7 +86,7 @@ static size_t len_oid (const heim_oid *oid) { size_t ret = 1; - int n; + size_t n; for (n = 2; n < oid->length; ++n) { unsigned u = oid->components[n]; diff --git a/source4/heimdal/lib/asn1/der_put.c b/source4/heimdal/lib/asn1/der_put.c index b8101458ad..0b276d1ebd 100644 --- a/source4/heimdal/lib/asn1/der_put.c +++ b/source4/heimdal/lib/asn1/der_put.c @@ -433,7 +433,8 @@ _heim_time2generalizedtime (time_t t, heim_octet_string *s, int gtimep) if (s->data == NULL) return ENOMEM; s->length = len; - _der_gmtime(t, &tm); + if (_der_gmtime(t, &tm) == NULL) + return ASN1_BAD_TIMEFORMAT; if (gtimep) snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, diff --git a/source4/heimdal/lib/asn1/extra.c b/source4/heimdal/lib/asn1/extra.c index 95780a7898..a18797ec25 100644 --- a/source4/heimdal/lib/asn1/extra.c +++ b/source4/heimdal/lib/asn1/extra.c @@ -71,13 +71,13 @@ decode_heim_any(const unsigned char *p, size_t len, if (len < length + len_len + l) return ASN1_OVERFLOW; } - + data->data = malloc(length + len_len + l); if (data->data == NULL) return ENOMEM; data->length = length + len_len + l; memcpy(data->data, p, length + len_len + l); - + if (size) *size = length + len_len + l; diff --git a/source4/heimdal/lib/asn1/gen.c b/source4/heimdal/lib/asn1/gen.c index d59f3bfa47..2194b329ce 100644 --- a/source4/heimdal/lib/asn1/gen.c +++ b/source4/heimdal/lib/asn1/gen.c @@ -761,7 +761,7 @@ define_type (int level, const char *name, const char *basename, Type *t, int typ fprintf (headerfile, "struct %s {\n", newbasename); ASN1_TAILQ_FOREACH(m, t->members, members) { char *n = NULL; - + /* pad unused */ while (pos < m->val) { if (asprintf (&n, "_unused%d:1", pos) < 0 || n == NULL) @@ -1021,7 +1021,7 @@ generate_type (const Symbol *s) h = privheaderfile; exp = ""; } - + fprintf (h, "%sint ASN1CALL " "decode_%s(const unsigned char *, size_t, %s *, size_t *);\n", @@ -1044,7 +1044,7 @@ generate_type (const Symbol *s) "%svoid ASN1CALL free_%s (%s *);\n", exp, s->gen_name, s->gen_name); - + fprintf(h, "\n\n"); if (!one_code_file) { diff --git a/source4/heimdal/lib/asn1/gen_decode.c b/source4/heimdal/lib/asn1/gen_decode.c index 002a471e96..9d816d5400 100644 --- a/source4/heimdal/lib/asn1/gen_decode.c +++ b/source4/heimdal/lib/asn1/gen_decode.c @@ -209,7 +209,8 @@ range_check(const char *name, static int decode_type (const char *name, const Type *t, int optional, - const char *forwstr, const char *tmpstr, const char *dertype) + const char *forwstr, const char *tmpstr, const char *dertype, + unsigned int depth) { switch (t->type) { case TType: { @@ -328,7 +329,8 @@ decode_type (const char *name, const Type *t, int optional, if (asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name) < 0 || s == NULL) errx(1, "malloc"); - decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL); + decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL, + depth + 1); free (s); } @@ -369,7 +371,7 @@ decode_type (const char *name, const Type *t, int optional, "%s = calloc(1, sizeof(*%s));\n" "if (%s == NULL) { e = ENOMEM; %s; }\n", s, s, s, forwstr); - decode_type (s, m->type, 0, forwstr, m->gen_name, NULL); + decode_type (s, m->type, 0, forwstr, m->gen_name, NULL, depth + 1); free (s); fprintf(codefile, "members |= (1 << %d);\n", memno); @@ -442,7 +444,7 @@ decode_type (const char *name, const Type *t, int optional, errx(1, "malloc"); if (asprintf (&sname, "%s_s_of", tmpstr) < 0 || sname == NULL) errx(1, "malloc"); - decode_type (n, t->subtype, 0, forwstr, sname, NULL); + decode_type (n, t->subtype, 0, forwstr, sname, NULL, depth + 1); fprintf (codefile, "(%s)->len++;\n" "len = %s_origlen - ret;\n" @@ -480,7 +482,7 @@ decode_type (const char *name, const Type *t, int optional, tmpstr, tmpstr, typestring); if(support_ber) fprintf(codefile, - "int is_indefinite;\n"); + "int is_indefinite%u;\n", depth); fprintf(codefile, "e = der_match_tag_and_length(p, len, %s, &%s, %s, " "&%s_datalen, &l);\n", @@ -516,20 +518,20 @@ decode_type (const char *name, const Type *t, int optional, tmpstr); if(support_ber) fprintf (codefile, - "if((is_indefinite = _heim_fix_dce(%s_datalen, &len)) < 0)\n" + "if((is_indefinite%u = _heim_fix_dce(%s_datalen, &len)) < 0)\n" "{ e = ASN1_BAD_FORMAT; %s; }\n" - "if (is_indefinite) { if (len < 2) { e = ASN1_OVERRUN; %s; } len -= 2; }", - tmpstr, forwstr, forwstr); + "if (is_indefinite%u) { if (len < 2) { e = ASN1_OVERRUN; %s; } len -= 2; }", + depth, tmpstr, forwstr, depth, forwstr); else fprintf(codefile, "if (%s_datalen > len) { e = ASN1_OVERRUN; %s; }\n" "len = %s_datalen;\n", tmpstr, forwstr, tmpstr); if (asprintf (&tname, "%s_Tag", tmpstr) < 0 || tname == NULL) errx(1, "malloc"); - decode_type (name, t->subtype, 0, forwstr, tname, ide); + decode_type (name, t->subtype, 0, forwstr, tname, ide, depth + 1); if(support_ber) fprintf(codefile, - "if(is_indefinite){\n" + "if(is_indefinite%u){\n" "len += 2;\n" "e = der_match_tag_and_length(p, len, " "(Der_class)0, &%s, UT_EndOfContent, " @@ -538,6 +540,7 @@ decode_type (const char *name, const Type *t, int optional, "p += l; len -= l; ret += l;\n" "if (%s != (Der_type)0) { e = ASN1_BAD_ID; %s; }\n" "} else \n", + depth, typestring, tmpstr, forwstr, @@ -584,7 +587,8 @@ decode_type (const char *name, const Type *t, int optional, if (asprintf (&s, "%s(%s)->u.%s", m->optional ? "" : "&", name, m->gen_name) < 0 || s == NULL) errx(1, "malloc"); - decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL); + decode_type (s, m->type, m->optional, forwstr, m->gen_name, NULL, + depth + 1); fprintf(codefile, "(%s)->element = %s;\n", name, m->label); @@ -605,7 +609,7 @@ decode_type (const char *name, const Type *t, int optional, "(%s)->element = %s;\n" "p += len;\n" "ret += len;\n" - "len -= len;\n" + "len = 0;\n" "}\n", name, have_ellipsis->gen_name, name, have_ellipsis->gen_name, @@ -662,8 +666,8 @@ generate_type_decode (const Symbol *s) int preserve = preserve_type(s->name) ? TRUE : FALSE; fprintf (codefile, "int ASN1CALL\n" - "decode_%s(const unsigned char *p," - " size_t len, %s *data, size_t *size)\n" + "decode_%s(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE," + " size_t len HEIMDAL_UNUSED_ATTRIBUTE, %s *data, size_t *size)\n" "{\n", s->gen_name, s->gen_name); @@ -694,15 +698,15 @@ generate_type_decode (const Symbol *s) case TChoice: fprintf (codefile, "size_t ret = 0;\n" - "size_t l;\n" - "int e;\n"); + "size_t l HEIMDAL_UNUSED_ATTRIBUTE;\n" + "int e HEIMDAL_UNUSED_ATTRIBUTE;\n"); if (preserve) fprintf (codefile, "const unsigned char *begin = p;\n"); fprintf (codefile, "\n"); fprintf (codefile, "memset(data, 0, sizeof(*data));\n"); /* hack to avoid `unused variable' */ - decode_type ("data", s->type, 0, "goto fail", "Top", NULL); + decode_type ("data", s->type, 0, "goto fail", "Top", NULL, 1); if (preserve) fprintf (codefile, "data->_save.data = calloc(1, ret);\n" diff --git a/source4/heimdal/lib/asn1/gen_encode.c b/source4/heimdal/lib/asn1/gen_encode.c index 43f29c1fe1..1bd47484d8 100644 --- a/source4/heimdal/lib/asn1/gen_encode.c +++ b/source4/heimdal/lib/asn1/gen_encode.c @@ -274,7 +274,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr) else if(m->defval) gen_compare_defval(s + 1, m->defval); fprintf (codefile, "{\n"); - fprintf (codefile, "size_t %s_oldret = ret;\n", tmpstr); + fprintf (codefile, "size_t %s_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;\n", tmpstr); fprintf (codefile, "ret = 0;\n"); encode_type (s, m->type, m->gen_name); fprintf (codefile, "ret += %s_oldret;\n", tmpstr); @@ -302,7 +302,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr) name, name); fprintf(codefile, - "for(i = 0; i < (%s)->len; i++) {\n", + "for(i = 0; i < (int)(%s)->len; i++) {\n", name); fprintf(codefile, @@ -326,7 +326,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr) fprintf(codefile, "if (totallen > len) {\n" - "for (i = 0; i < (%s)->len; i++) {\n" + "for (i = 0; i < (int)(%s)->len; i++) {\n" "free(val[i].data);\n" "}\n" "free(val);\n" @@ -339,7 +339,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr) name); fprintf (codefile, - "for(i = (%s)->len - 1; i >= 0; --i) {\n" + "for(i = (int)(%s)->len - 1; i >= 0; --i) {\n" "p -= val[i].length;\n" "ret += val[i].length;\n" "memcpy(p + 1, val[i].data, val[i].length);\n" @@ -355,7 +355,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr) char *n = NULL; fprintf (codefile, - "for(i = (%s)->len - 1; i >= 0; --i) {\n" + "for(i = (int)(%s)->len - 1; i >= 0; --i) {\n" "size_t %s_for_oldret = ret;\n" "ret = 0;\n", name, tmpstr); @@ -503,7 +503,7 @@ void generate_type_encode (const Symbol *s) { fprintf (codefile, "int ASN1CALL\n" - "encode_%s(unsigned char *p, size_t len," + "encode_%s(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE," " const %s *data, size_t *size)\n" "{\n", s->gen_name, s->gen_name); @@ -534,10 +534,9 @@ generate_type_encode (const Symbol *s) case TType: case TChoice: fprintf (codefile, - "size_t ret = 0;\n" - "size_t l;\n" - "int i, e;\n\n"); - fprintf(codefile, "i = 0;\n"); /* hack to avoid `unused variable' */ + "size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;\n" + "size_t l HEIMDAL_UNUSED_ATTRIBUTE;\n" + "int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;\n\n"); encode_type("data", s->type, "Top"); diff --git a/source4/heimdal/lib/asn1/gen_free.c b/source4/heimdal/lib/asn1/gen_free.c index 7c88751c32..b9cae7533b 100644 --- a/source4/heimdal/lib/asn1/gen_free.c +++ b/source4/heimdal/lib/asn1/gen_free.c @@ -179,12 +179,12 @@ void generate_type_free (const Symbol *s) { int preserve = preserve_type(s->name) ? TRUE : FALSE; - + fprintf (codefile, "void ASN1CALL\n" "free_%s(%s *data)\n" "{\n", s->gen_name, s->gen_name); - + free_type ("data", s->type, preserve); fprintf (codefile, "}\n\n"); } diff --git a/source4/heimdal/lib/asn1/gen_template.c b/source4/heimdal/lib/asn1/gen_template.c index 791fb910f9..edd68e1223 100644 --- a/source4/heimdal/lib/asn1/gen_template.c +++ b/source4/heimdal/lib/asn1/gen_template.c @@ -342,7 +342,7 @@ tlist_cmp(const struct tlist *tl, const struct tlist *ql) ret = strcmp(tl->header, ql->header); if (ret) return ret; - + q = ASN1_TAILQ_FIRST(&ql->template); ASN1_TAILQ_FOREACH(t, &tl->template, members) { if (q == NULL) return 1; @@ -353,7 +353,7 @@ tlist_cmp(const struct tlist *tl, const struct tlist *ql) } else { ret = strcmp(t->tt, q->tt); if (ret) return ret; - + ret = strcmp(t->offset, q->offset); if (ret) return ret; @@ -479,12 +479,12 @@ template_members(struct templatehead *temp, const char *basetype, const char *na optional ? "|A1_FLAG_OPTIONAL" : "", poffset, t->symbol->gen_name); } else { - add_line_pointer(temp, t->symbol->gen_name, poffset, + add_line_pointer(temp, t->symbol->gen_name, poffset, "A1_OP_TYPE %s", optional ? "|A1_FLAG_OPTIONAL" : ""); } break; case TInteger: { - char *itype; + char *itype = NULL; if (t->members) itype = "IMEMBER"; @@ -499,7 +499,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na else errx(1, "%s: unsupported range %d -> %d", name, t->range->min, t->range->max); - + add_line(temp, "{ A1_PARSE_T(A1T_%s), %s, NULL }", itype, poffset); break; } @@ -557,7 +557,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na break; } - if (asprintf(&bname, "bmember_%s_%lu", name ? name : "", (unsigned long)t) < 0 || bname == NULL) + if (asprintf(&bname, "bmember_%s_%p", name ? name : "", t) < 0 || bname == NULL) errx(1, "malloc"); output_name(bname); @@ -591,7 +591,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na ASN1_TAILQ_FOREACH(m, t->members, members) { char *newbasename = NULL; - + if (m->ellipsis) continue; @@ -620,7 +620,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na else sename = symbol_name(basetype, t->subtype); - if (asprintf(&tname, "tag_%s_%lu", name ? name : "", (unsigned long)t) < 0 || tname == NULL) + if (asprintf(&tname, "tag_%s_%p", name ? name : "", t) < 0 || tname == NULL) errx(1, "malloc"); output_name(tname); @@ -644,7 +644,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na } case TSetOf: case TSequenceOf: { - const char *type, *tname, *dupname; + const char *type = NULL, *tname, *dupname; char *sename = NULL, *elname = NULL; int subtype_is_struct = is_struct(t->subtype, 0); @@ -670,7 +670,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na else if (t->type == TSequenceOf) type = "A1_OP_SEQOF"; else abort(); - if (asprintf(&elname, "%s_%s_%lu", basetype, tname, (unsigned long)t) < 0 || elname == NULL) + if (asprintf(&elname, "%s_%s_%p", basetype, tname, t) < 0 || elname == NULL) errx(1, "malloc"); generate_template_type(elname, &dupname, NULL, sename, NULL, t->subtype, @@ -699,7 +699,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na char *elname = NULL; char *newbasename = NULL; int subtype_is_struct; - + if (m->ellipsis) { ellipsis = 1; continue; diff --git a/source4/heimdal/lib/asn1/krb5.asn1 b/source4/heimdal/lib/asn1/krb5.asn1 index 78cb5a3b84..02fab7a3a6 100644 --- a/source4/heimdal/lib/asn1/krb5.asn1 +++ b/source4/heimdal/lib/asn1/krb5.asn1 @@ -221,32 +221,32 @@ CKSUMTYPE ::= INTEGER { --enctypes ENCTYPE ::= INTEGER { - ETYPE_NULL(0), - ETYPE_DES_CBC_CRC(1), - ETYPE_DES_CBC_MD4(2), - ETYPE_DES_CBC_MD5(3), - ETYPE_DES3_CBC_MD5(5), - ETYPE_OLD_DES3_CBC_SHA1(7), - ETYPE_SIGN_DSA_GENERATE(8), - ETYPE_ENCRYPT_RSA_PRIV(9), - ETYPE_ENCRYPT_RSA_PUB(10), - ETYPE_DES3_CBC_SHA1(16), -- with key derivation - ETYPE_AES128_CTS_HMAC_SHA1_96(17), - ETYPE_AES256_CTS_HMAC_SHA1_96(18), - ETYPE_ARCFOUR_HMAC_MD5(23), - ETYPE_ARCFOUR_HMAC_MD5_56(24), - ETYPE_ENCTYPE_PK_CROSS(48), + KRB5_ENCTYPE_NULL(0), + KRB5_ENCTYPE_DES_CBC_CRC(1), + KRB5_ENCTYPE_DES_CBC_MD4(2), + KRB5_ENCTYPE_DES_CBC_MD5(3), + KRB5_ENCTYPE_DES3_CBC_MD5(5), + KRB5_ENCTYPE_OLD_DES3_CBC_SHA1(7), + KRB5_ENCTYPE_SIGN_DSA_GENERATE(8), + KRB5_ENCTYPE_ENCRYPT_RSA_PRIV(9), + KRB5_ENCTYPE_ENCRYPT_RSA_PUB(10), + KRB5_ENCTYPE_DES3_CBC_SHA1(16), -- with key derivation + KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96(17), + KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96(18), + KRB5_ENCTYPE_ARCFOUR_HMAC_MD5(23), + KRB5_ENCTYPE_ARCFOUR_HMAC_MD5_56(24), + KRB5_ENCTYPE_ENCTYPE_PK_CROSS(48), -- some "old" windows types - ETYPE_ARCFOUR_MD4(-128), - ETYPE_ARCFOUR_HMAC_OLD(-133), - ETYPE_ARCFOUR_HMAC_OLD_EXP(-135), + KRB5_ENCTYPE_ARCFOUR_MD4(-128), + KRB5_ENCTYPE_ARCFOUR_HMAC_OLD(-133), + KRB5_ENCTYPE_ARCFOUR_HMAC_OLD_EXP(-135), -- these are for Heimdal internal use - ETYPE_DES_CBC_NONE(-0x1000), - ETYPE_DES3_CBC_NONE(-0x1001), - ETYPE_DES_CFB64_NONE(-0x1002), - ETYPE_DES_PCBC_NONE(-0x1003), - ETYPE_DIGEST_MD5_NONE(-0x1004), -- private use, lukeh@padl.com - ETYPE_CRAM_MD5_NONE(-0x1005) -- private use, lukeh@padl.com + KRB5_ENCTYPE_DES_CBC_NONE(-0x1000), + KRB5_ENCTYPE_DES3_CBC_NONE(-0x1001), + KRB5_ENCTYPE_DES_CFB64_NONE(-0x1002), + KRB5_ENCTYPE_DES_PCBC_NONE(-0x1003), + KRB5_ENCTYPE_DIGEST_MD5_NONE(-0x1004), -- private use, lukeh@padl.com + KRB5_ENCTYPE_CRAM_MD5_NONE(-0x1005) -- private use, lukeh@padl.com } @@ -625,7 +625,7 @@ ChangePasswdDataMS ::= SEQUENCE { targrealm[2] Realm OPTIONAL } -EtypeList ::= SEQUENCE OF krb5int32 +EtypeList ::= SEQUENCE OF ENCTYPE -- the client's proposed enctype list in -- decreasing preference order, favorite choice first diff --git a/source4/heimdal/lib/asn1/lex.c b/source4/heimdal/lib/asn1/lex.c index 12c71b7e2e..e8d9f38eaa 100644 --- a/source4/heimdal/lib/asn1/lex.c +++ b/source4/heimdal/lib/asn1/lex.c @@ -1626,7 +1626,7 @@ YY_RULE_SETUP char *p = buf; int f = 0; int skip_ws = 0; - + while((c = input()) != EOF) { if(isspace(c) && skip_ws) { if(c == '\n') @@ -1634,7 +1634,7 @@ YY_RULE_SETUP continue; } skip_ws = 0; - + if(c == '"') { if(f) { *p++ = '"'; diff --git a/source4/heimdal/lib/asn1/lex.l b/source4/heimdal/lib/asn1/lex.l index dece096164..2d32020266 100644 --- a/source4/heimdal/lib/asn1/lex.l +++ b/source4/heimdal/lib/asn1/lex.l @@ -216,7 +216,7 @@ WITH { return kw_WITH; } char *p = buf; int f = 0; int skip_ws = 0; - + while((c = input()) != EOF) { if(isspace(c) && skip_ws) { if(c == '\n') @@ -224,7 +224,7 @@ WITH { return kw_WITH; } continue; } skip_ws = 0; - + if(c == '"') { if(f) { *p++ = '"'; diff --git a/source4/heimdal/lib/asn1/main.c b/source4/heimdal/lib/asn1/main.c index a99e69d0f9..f22dc8792c 100644 --- a/source4/heimdal/lib/asn1/main.c +++ b/source4/heimdal/lib/asn1/main.c @@ -202,6 +202,6 @@ main(int argc, char **argv) free(arg[i]); free(arg); } - + return 0; } diff --git a/source4/heimdal/lib/asn1/test.asn1 b/source4/heimdal/lib/asn1/test.asn1 index e3c72ac76e..89154e337c 100644 --- a/source4/heimdal/lib/asn1/test.asn1 +++ b/source4/heimdal/lib/asn1/test.asn1 @@ -132,4 +132,7 @@ TESTBitString ::= BIT STRING { thirtyone(31) } +TESTMechType::= OBJECT IDENTIFIER +TESTMechTypeList ::= SEQUENCE OF TESTMechType + END diff --git a/source4/heimdal/lib/asn1/timegm.c b/source4/heimdal/lib/asn1/timegm.c index b569478413..d9f4adbd55 100644 --- a/source4/heimdal/lib/asn1/timegm.c +++ b/source4/heimdal/lib/asn1/timegm.c @@ -33,7 +33,7 @@ #include "der_locl.h" -RCSID("$Id$"); +#define ASN1_MAX_YEAR 2000 static int is_leap(unsigned y) @@ -56,13 +56,19 @@ time_t _der_timegm (struct tm *tm) { time_t res = 0; - unsigned i; + int i; + + /* + * See comment in _der_gmtime + */ + if (tm->tm_year > ASN1_MAX_YEAR) + return 0; if (tm->tm_year < 0) return -1; if (tm->tm_mon < 0 || tm->tm_mon > 11) return -1; - if (tm->tm_mday < 1 || tm->tm_mday > ndays[is_leap(tm->tm_year)][tm->tm_mon]) + if (tm->tm_mday < 1 || tm->tm_mday > (int)ndays[is_leap(tm->tm_year)][tm->tm_mon]) return -1; if (tm->tm_hour < 0 || tm->tm_hour > 23) return -1; @@ -98,6 +104,15 @@ _der_gmtime(time_t t, struct tm *tm) tm->tm_min = (secday % 3600) / 60; tm->tm_hour = secday / 3600; + /* + * Refuse to calculate time ~ 2000 years into the future, this is + * not possible for systems where time_t is a int32_t, however, + * when time_t is a int64_t, that can happen, and this becomes a + * denial of sevice. + */ + if (days > (ASN1_MAX_YEAR * 365)) + return NULL; + tm->tm_year = 70; while(1) { unsigned dayinyear = (is_leap(tm->tm_year) ? 366 : 365); |