summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/asn1
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2010-08-15 18:31:28 +0400
committerAndrew Bartlett <abartlet@samba.org>2010-10-03 01:15:04 +0000
commitab6e3fce040f9ad27cbce44e9038a24f15b601c8 (patch)
treeab99a431c9610927b5d0d26335d2712b509fd6dc /source4/heimdal/lib/asn1
parent197a1514d62494cc8b862d169c841a26e04b8925 (diff)
downloadsamba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.gz
samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.bz2
samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.zip
s4:heimdal: import lorikeet-heimdal-201009250123 (commit 42cabfb5b683dbcb97d583c397b897507689e382)
I based this on Matthieu's import of lorikeet-heimdal, and then updated it to this commit. Andrew Bartlett
Diffstat (limited to 'source4/heimdal/lib/asn1')
-rw-r--r--source4/heimdal/lib/asn1/asn1-common.h16
-rw-r--r--source4/heimdal/lib/asn1/asn1_gen.c5
-rw-r--r--source4/heimdal/lib/asn1/asn1parse.c8
-rw-r--r--source4/heimdal/lib/asn1/asn1parse.y8
-rw-r--r--source4/heimdal/lib/asn1/cms.opt1
-rw-r--r--source4/heimdal/lib/asn1/der_cmp.c14
-rw-r--r--source4/heimdal/lib/asn1/der_copy.c14
-rw-r--r--source4/heimdal/lib/asn1/der_free.c6
-rw-r--r--source4/heimdal/lib/asn1/der_get.c19
-rw-r--r--source4/heimdal/lib/asn1/der_length.c4
-rw-r--r--source4/heimdal/lib/asn1/der_put.c4
-rw-r--r--source4/heimdal/lib/asn1/gen.c122
-rw-r--r--source4/heimdal/lib/asn1/gen_copy.c25
-rw-r--r--source4/heimdal/lib/asn1/gen_decode.c40
-rw-r--r--source4/heimdal/lib/asn1/gen_encode.c38
-rw-r--r--source4/heimdal/lib/asn1/gen_free.c12
-rw-r--r--source4/heimdal/lib/asn1/gen_glue.c2
-rw-r--r--source4/heimdal/lib/asn1/gen_length.c28
-rw-r--r--source4/heimdal/lib/asn1/gen_seq.c12
-rw-r--r--source4/heimdal/lib/asn1/gen_template.c88
-rw-r--r--source4/heimdal/lib/asn1/rfc2459.asn110
21 files changed, 280 insertions, 196 deletions
diff --git a/source4/heimdal/lib/asn1/asn1-common.h b/source4/heimdal/lib/asn1/asn1-common.h
index 8ab97761db..9c8793e0cc 100644
--- a/source4/heimdal/lib/asn1/asn1-common.h
+++ b/source4/heimdal/lib/asn1/asn1-common.h
@@ -20,8 +20,8 @@ typedef struct heim_octet_string {
typedef char *heim_general_string;
typedef char *heim_utf8_string;
-typedef char *heim_printable_string;
-typedef char *heim_ia5_string;
+typedef struct heim_octet_string heim_printable_string;
+typedef struct heim_octet_string heim_ia5_string;
typedef struct heim_bmp_string {
size_t length;
@@ -64,4 +64,16 @@ typedef struct heim_octet_string heim_any_set;
} \
} while (0)
+#ifdef _WIN32
+#ifndef ASN1_LIB
+#define ASN1EXP __declspec(dllimport)
+#else
+#define ASN1EXP
+#endif
+#define ASN1CALL __stdcall
+#else
+#define ASN1EXP
+#define ASN1CALL
+#endif
+
#endif
diff --git a/source4/heimdal/lib/asn1/asn1_gen.c b/source4/heimdal/lib/asn1/asn1_gen.c
index 925cc72cb4..01dc680516 100644
--- a/source4/heimdal/lib/asn1/asn1_gen.c
+++ b/source4/heimdal/lib/asn1/asn1_gen.c
@@ -46,7 +46,7 @@ static int
doit(const char *fn)
{
char buf[2048];
- char *fnout;
+ char *fnout = NULL;
const char *bname;
unsigned long line = 0;
FILE *f, *fout;
@@ -62,8 +62,7 @@ doit(const char *fn)
else
bname = fn;
- asprintf(&fnout, "%s.out", bname);
- if (fnout == NULL)
+ if (asprintf(&fnout, "%s.out", bname) < 0 || fnout == NULL)
errx(1, "malloc");
fout = fopen(fnout, "w");
diff --git a/source4/heimdal/lib/asn1/asn1parse.c b/source4/heimdal/lib/asn1/asn1parse.c
index 545e0f6922..7fa937a49d 100644
--- a/source4/heimdal/lib/asn1/asn1parse.c
+++ b/source4/heimdal/lib/asn1/asn1parse.c
@@ -3015,7 +3015,8 @@ static void fix_labels1(struct memhead *members, const char *prefix)
if(members == NULL)
return;
ASN1_TAILQ_FOREACH(m, members, members) {
- asprintf(&m->label, "%s_%s", prefix, m->gen_name);
+ if (asprintf(&m->label, "%s_%s", prefix, m->gen_name) < 0)
+ errx(1, "malloc");
if (m->label == NULL)
errx(1, "malloc");
if(m->type != NULL)
@@ -3032,9 +3033,8 @@ static void fix_labels2(Type *t, const char *prefix)
static void
fix_labels(Symbol *s)
{
- char *p;
- asprintf(&p, "choice_%s", s->gen_name);
- if (p == NULL)
+ char *p = NULL;
+ if (asprintf(&p, "choice_%s", s->gen_name) < 0 || p == NULL)
errx(1, "malloc");
fix_labels2(s->type, p);
free(p);
diff --git a/source4/heimdal/lib/asn1/asn1parse.y b/source4/heimdal/lib/asn1/asn1parse.y
index 13b86b17c1..611c5b521a 100644
--- a/source4/heimdal/lib/asn1/asn1parse.y
+++ b/source4/heimdal/lib/asn1/asn1parse.y
@@ -1007,7 +1007,8 @@ static void fix_labels1(struct memhead *members, const char *prefix)
if(members == NULL)
return;
ASN1_TAILQ_FOREACH(m, members, members) {
- asprintf(&m->label, "%s_%s", prefix, m->gen_name);
+ if (asprintf(&m->label, "%s_%s", prefix, m->gen_name) < 0)
+ errx(1, "malloc");
if (m->label == NULL)
errx(1, "malloc");
if(m->type != NULL)
@@ -1024,9 +1025,8 @@ static void fix_labels2(Type *t, const char *prefix)
static void
fix_labels(Symbol *s)
{
- char *p;
- asprintf(&p, "choice_%s", s->gen_name);
- if (p == NULL)
+ char *p = NULL;
+ if (asprintf(&p, "choice_%s", s->gen_name) < 0 || p == NULL)
errx(1, "malloc");
fix_labels2(s->type, p);
free(p);
diff --git a/source4/heimdal/lib/asn1/cms.opt b/source4/heimdal/lib/asn1/cms.opt
index bf7d396529..49333e53a7 100644
--- a/source4/heimdal/lib/asn1/cms.opt
+++ b/source4/heimdal/lib/asn1/cms.opt
@@ -1 +1,2 @@
--decode-dce-ber
+--sequence=DigestAlgorithmIdentifiers
diff --git a/source4/heimdal/lib/asn1/der_cmp.c b/source4/heimdal/lib/asn1/der_cmp.c
index 7329c5867f..84aee4cce0 100644
--- a/source4/heimdal/lib/asn1/der_cmp.c
+++ b/source4/heimdal/lib/asn1/der_cmp.c
@@ -53,6 +53,20 @@ der_heim_octet_string_cmp(const heim_octet_string *p,
}
int
+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,
+ const heim_ia5_string *q)
+{
+ return der_heim_octet_string_cmp(p, q);
+}
+
+int
der_heim_bit_string_cmp(const heim_bit_string *p,
const heim_bit_string *q)
{
diff --git a/source4/heimdal/lib/asn1/der_copy.c b/source4/heimdal/lib/asn1/der_copy.c
index a80c851f96..3a0a8c5ffa 100644
--- a/source4/heimdal/lib/asn1/der_copy.c
+++ b/source4/heimdal/lib/asn1/der_copy.c
@@ -85,14 +85,20 @@ int
der_copy_printable_string (const heim_printable_string *from,
heim_printable_string *to)
{
- return der_copy_general_string(from, to);
+ to->length = from->length;
+ to->data = malloc(to->length + 1);
+ if(to->data == NULL)
+ return ENOMEM;
+ memcpy(to->data, from->data, to->length);
+ ((char *)to->data)[to->length] = '\0';
+ return 0;
}
int
-der_copy_ia5_string (const heim_printable_string *from,
- heim_printable_string *to)
+der_copy_ia5_string (const heim_ia5_string *from,
+ heim_ia5_string *to)
{
- return der_copy_general_string(from, to);
+ return der_copy_printable_string(from, to);
}
int
diff --git a/source4/heimdal/lib/asn1/der_free.c b/source4/heimdal/lib/asn1/der_free.c
index a16ddaed1c..4bae5fc233 100644
--- a/source4/heimdal/lib/asn1/der_free.c
+++ b/source4/heimdal/lib/asn1/der_free.c
@@ -79,15 +79,13 @@ der_free_utf8string (heim_utf8_string *str)
void
der_free_printable_string (heim_printable_string *str)
{
- free(*str);
- *str = NULL;
+ der_free_octet_string(str);
}
void
der_free_ia5_string (heim_ia5_string *str)
{
- free(*str);
- *str = NULL;
+ der_free_octet_string(str);
}
void
diff --git a/source4/heimdal/lib/asn1/der_get.c b/source4/heimdal/lib/asn1/der_get.c
index aee565040f..3ea0d5ea18 100644
--- a/source4/heimdal/lib/asn1/der_get.c
+++ b/source4/heimdal/lib/asn1/der_get.c
@@ -167,17 +167,24 @@ der_get_utf8string (const unsigned char *p, size_t len,
}
int
-der_get_printable_string (const unsigned char *p, size_t len,
- heim_printable_string *str, size_t *size)
+der_get_printable_string(const unsigned char *p, size_t len,
+ heim_printable_string *str, size_t *size)
{
- return der_get_general_string(p, len, str, size);
+ str->length = len;
+ str->data = malloc(len + 1);
+ if (str->data == NULL)
+ return ENOMEM;
+ memcpy(str->data, p, len);
+ ((char *)str->data)[len] = '\0';
+ if(size) *size = len;
+ return 0;
}
int
-der_get_ia5_string (const unsigned char *p, size_t len,
- heim_ia5_string *str, size_t *size)
+der_get_ia5_string(const unsigned char *p, size_t len,
+ heim_ia5_string *str, size_t *size)
{
- return der_get_general_string(p, len, str, size);
+ return der_get_printable_string(p, len, str, size);
}
int
diff --git a/source4/heimdal/lib/asn1/der_length.c b/source4/heimdal/lib/asn1/der_length.c
index 688e6ba817..7a41de9d22 100644
--- a/source4/heimdal/lib/asn1/der_length.c
+++ b/source4/heimdal/lib/asn1/der_length.c
@@ -161,13 +161,13 @@ der_length_utf8string (const heim_utf8_string *data)
size_t
der_length_printable_string (const heim_printable_string *data)
{
- return strlen(*data);
+ return data->length;
}
size_t
der_length_ia5_string (const heim_ia5_string *data)
{
- return strlen(*data);
+ return data->length;
}
size_t
diff --git a/source4/heimdal/lib/asn1/der_put.c b/source4/heimdal/lib/asn1/der_put.c
index 10fc002334..c8192f25fe 100644
--- a/source4/heimdal/lib/asn1/der_put.c
+++ b/source4/heimdal/lib/asn1/der_put.c
@@ -181,14 +181,14 @@ int
der_put_printable_string (unsigned char *p, size_t len,
const heim_printable_string *str, size_t *size)
{
- return der_put_general_string(p, len, str, size);
+ return der_put_octet_string(p, len, str, size);
}
int
der_put_ia5_string (unsigned char *p, size_t len,
const heim_ia5_string *str, size_t *size)
{
- return der_put_general_string(p, len, str, size);
+ return der_put_octet_string(p, len, str, size);
}
int
diff --git a/source4/heimdal/lib/asn1/gen.c b/source4/heimdal/lib/asn1/gen.c
index 8c13434203..d59f3bfa47 100644
--- a/source4/heimdal/lib/asn1/gen.c
+++ b/source4/heimdal/lib/asn1/gen.c
@@ -116,7 +116,7 @@ get_filename (void)
void
init_generate (const char *filename, const char *base)
{
- char *fn;
+ char *fn = NULL;
orig_filename = filename;
if (base != NULL) {
@@ -126,34 +126,30 @@ init_generate (const char *filename, const char *base)
}
/* public header file */
- asprintf(&header, "%s.h", headerbase);
- if (header == NULL)
+ if (asprintf(&header, "%s.h", headerbase) < 0 || header == NULL)
errx(1, "malloc");
- asprintf(&fn, "%s.hx", headerbase);
- if (fn == NULL)
+ if (asprintf(&fn, "%s.hx", headerbase) < 0 || fn == NULL)
errx(1, "malloc");
headerfile = fopen (fn, "w");
if (headerfile == NULL)
err (1, "open %s", fn);
free(fn);
+ fn = NULL;
/* private header file */
- asprintf(&privheader, "%s-priv.h", headerbase);
- if (privheader == NULL)
+ if (asprintf(&privheader, "%s-priv.h", headerbase) < 0 || privheader == NULL)
errx(1, "malloc");
- asprintf(&fn, "%s-priv.hx", headerbase);
- if (fn == NULL)
+ if (asprintf(&fn, "%s-priv.hx", headerbase) < 0 || fn == NULL)
errx(1, "malloc");
privheaderfile = fopen (fn, "w");
if (privheaderfile == NULL)
err (1, "open %s", fn);
free(fn);
+ fn = NULL;
/* template file */
- asprintf(&template, "%s-template.c", headerbase);
- if (template == NULL)
+ if (asprintf(&template, "%s-template.c", headerbase) < 0 || template == NULL)
errx(1, "malloc");
-
fprintf (headerfile,
"/* Generated from %s */\n"
"/* Do not edit */\n\n",
@@ -185,10 +181,10 @@ init_generate (const char *filename, const char *base)
"typedef char *heim_utf8_string;\n\n"
);
fprintf (headerfile,
- "typedef char *heim_printable_string;\n\n"
+ "typedef struct heim_octet_string heim_printable_string;\n\n"
);
fprintf (headerfile,
- "typedef char *heim_ia5_string;\n\n"
+ "typedef struct heim_octet_string heim_ia5_string;\n\n"
);
fprintf (headerfile,
"typedef struct heim_bmp_string {\n"
@@ -232,10 +228,21 @@ init_generate (const char *filename, const char *base)
" } \\\n"
" } while (0)\n\n",
headerfile);
+ fputs("#ifdef _WIN32\n"
+ "#ifndef ASN1_LIB\n"
+ "#define ASN1EXP __declspec(dllimport)\n"
+ "#else\n"
+ "#define ASN1EXP\n"
+ "#endif\n"
+ "#define ASN1CALL __stdcall\n"
+ "#else\n"
+ "#define ASN1EXP\n"
+ "#define ASN1CALL\n"
+ "#endif\n",
+ headerfile);
fprintf (headerfile, "struct units;\n\n");
fprintf (headerfile, "#endif\n\n");
- asprintf(&fn, "%s_files", base);
- if (fn == NULL)
+ if (asprintf(&fn, "%s_files", base) < 0 || fn == NULL)
errx(1, "malloc");
logfile = fopen(fn, "w");
if (logfile == NULL)
@@ -333,22 +340,23 @@ gen_compare_defval(const char *var, struct value *val)
void
generate_header_of_codefile(const char *name)
{
- char *filename;
+ char *filename = NULL;
if (codefile != NULL)
abort();
- asprintf (&filename, "%s_%s.x", STEM, name);
- if (filename == NULL)
+ if (asprintf (&filename, "%s_%s.x", STEM, name) < 0 || filename == NULL)
errx(1, "malloc");
codefile = fopen (filename, "w");
if (codefile == NULL)
err (1, "fopen %s", filename);
fprintf(logfile, "%s ", filename);
free(filename);
+ filename = NULL;
fprintf (codefile,
"/* Generated from %s */\n"
"/* Do not edit */\n\n"
+ "#define ASN1_LIB\n\n"
"#include <stdio.h>\n"
"#include <stdlib.h>\n"
"#include <time.h>\n"
@@ -399,6 +407,7 @@ generate_constant (const Symbol *s)
case objectidentifiervalue: {
struct objid *o, **list;
unsigned int i, len;
+ char *gen_upper;
if (!one_code_file)
generate_header_of_codefile(s->gen_name);
@@ -424,12 +433,6 @@ generate_constant (const Symbol *s)
o->label ? o->label : "label-less", o->value);
}
- fprintf (headerfile, "} */\n");
- fprintf (headerfile,
- "extern const heim_oid asn1_oid_%s;\n\n",
- s->gen_name);
-
-
fprintf (codefile, "static unsigned oid_%s_variable_num[%d] = {",
s->gen_name, len);
for (i = len ; i > 0; i--) {
@@ -443,6 +446,23 @@ generate_constant (const Symbol *s)
free(list);
+ /* header file */
+
+ gen_upper = strdup(s->gen_name);
+ len = strlen(gen_upper);
+ for (i = 0; i < len; i++)
+ gen_upper[i] = toupper((int)s->gen_name[i]);
+
+ fprintf (headerfile, "} */\n");
+ fprintf (headerfile,
+ "extern ASN1EXP const heim_oid asn1_oid_%s;\n"
+ "#define ASN1_OID_%s (&asn1_oid_%s)\n\n",
+ s->gen_name,
+ gen_upper,
+ s->gen_name);
+
+ free(gen_upper);
+
if (!one_code_file)
close_codefile();
@@ -673,7 +693,8 @@ getnewbasename(char **newbasename, int typedefp, const char *basename, const cha
else {
if (name[0] == '*')
name++;
- asprintf(newbasename, "%s_%s", basename, name);
+ if (asprintf(newbasename, "%s_%s", basename, name) < 0)
+ errx(1, "malloc");
}
if (*newbasename == NULL)
err(1, "malloc");
@@ -739,27 +760,30 @@ 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;
+ char *n = NULL;
/* pad unused */
while (pos < m->val) {
- asprintf (&n, "_unused%d:1", pos);
+ if (asprintf (&n, "_unused%d:1", pos) < 0 || n == NULL)
+ errx(1, "malloc");
define_type (level + 1, n, newbasename, &i, FALSE, FALSE);
free(n);
pos++;
}
- asprintf (&n, "%s:1", m->gen_name);
- if (n == NULL)
+ n = NULL;
+ if (asprintf (&n, "%s:1", m->gen_name) < 0 || n == NULL)
errx(1, "malloc");
define_type (level + 1, n, newbasename, &i, FALSE, FALSE);
free (n);
+ n = NULL;
pos++;
}
/* pad to 32 elements */
while (pos < 32) {
- char *n;
- asprintf (&n, "_unused%d:1", pos);
+ char *n = NULL;
+ if (asprintf (&n, "_unused%d:1", pos) < 0 || n == NULL)
+ errx(1, "malloc");
define_type (level + 1, n, newbasename, &i, FALSE, FALSE);
free(n);
pos++;
@@ -803,10 +827,9 @@ define_type (int level, const char *name, const char *basename, Type *t, int typ
if (m->ellipsis) {
;
} else if (m->optional) {
- char *n;
+ char *n = NULL;
- asprintf (&n, "*%s", m->gen_name);
- if (n == NULL)
+ if (asprintf (&n, "*%s", m->gen_name) < 0 || n == NULL)
errx(1, "malloc");
define_type (level + 1, n, newbasename, m->type, FALSE, FALSE);
free (n);
@@ -891,10 +914,9 @@ define_type (int level, const char *name, const char *basename, Type *t, int typ
space(level + 2);
fprintf(headerfile, "heim_octet_string asn1_ellipsis;\n");
} else if (m->optional) {
- char *n;
+ char *n = NULL;
- asprintf (&n, "*%s", m->gen_name);
- if (n == NULL)
+ if (asprintf (&n, "*%s", m->gen_name) < 0 || n == NULL)
errx(1, "malloc");
define_type (level + 2, n, newbasename, m->type, FALSE, FALSE);
free (n);
@@ -970,6 +992,7 @@ void
generate_type (const Symbol *s)
{
FILE *h;
+ const char * exp;
if (!one_code_file)
generate_header_of_codefile(s->gen_name);
@@ -991,30 +1014,37 @@ generate_type (const Symbol *s)
/* generate prototypes */
- if (is_export(s->name))
+ if (is_export(s->name)) {
h = headerfile;
- else
+ exp = "ASN1EXP ";
+ } else {
h = privheaderfile;
+ exp = "";
+ }
fprintf (h,
- "int "
+ "%sint ASN1CALL "
"decode_%s(const unsigned char *, size_t, %s *, size_t *);\n",
+ exp,
s->gen_name, s->gen_name);
fprintf (h,
- "int "
+ "%sint ASN1CALL "
"encode_%s(unsigned char *, size_t, const %s *, size_t *);\n",
+ exp,
s->gen_name, s->gen_name);
fprintf (h,
- "size_t length_%s(const %s *);\n",
+ "%ssize_t ASN1CALL length_%s(const %s *);\n",
+ exp,
s->gen_name, s->gen_name);
fprintf (h,
- "int copy_%s (const %s *, %s *);\n",
+ "%sint ASN1CALL copy_%s (const %s *, %s *);\n",
+ exp,
s->gen_name, s->gen_name, s->gen_name);
fprintf (h,
- "void free_%s (%s *);\n",
+ "%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_copy.c b/source4/heimdal/lib/asn1/gen_copy.c
index 5e228d0e64..36f68ee5d9 100644
--- a/source4/heimdal/lib/asn1/gen_copy.c
+++ b/source4/heimdal/lib/asn1/gen_copy.c
@@ -110,14 +110,16 @@ copy_type (const char *from, const char *to, const Type *t, int preserve)
if(t->type == TChoice)
fprintf(codefile, "case %s:\n", m->label);
- asprintf (&fs, "%s(%s)->%s%s",
- m->optional ? "" : "&", from,
- t->type == TChoice ? "u." : "", m->gen_name);
+ if (asprintf (&fs, "%s(%s)->%s%s",
+ m->optional ? "" : "&", from,
+ t->type == TChoice ? "u." : "", m->gen_name) < 0)
+ errx(1, "malloc");
if (fs == NULL)
errx(1, "malloc");
- asprintf (&ts, "%s(%s)->%s%s",
- m->optional ? "" : "&", to,
- t->type == TChoice ? "u." : "", m->gen_name);
+ if (asprintf (&ts, "%s(%s)->%s%s",
+ m->optional ? "" : "&", to,
+ t->type == TChoice ? "u." : "", m->gen_name) < 0)
+ errx(1, "malloc");
if (ts == NULL)
errx(1, "malloc");
if(m->optional){
@@ -155,8 +157,7 @@ copy_type (const char *from, const char *to, const Type *t, int preserve)
}
case TSetOf:
case TSequenceOf: {
- char *f;
- char *T;
+ char *f = NULL, *T = NULL;
fprintf (codefile, "if(((%s)->val = "
"malloc((%s)->len * sizeof(*(%s)->val))) == NULL && (%s)->len != 0)\n",
@@ -166,10 +167,12 @@ copy_type (const char *from, const char *to, const Type *t, int preserve)
fprintf(codefile,
"for((%s)->len = 0; (%s)->len < (%s)->len; (%s)->len++){\n",
to, to, from, to);
- asprintf(&f, "&(%s)->val[(%s)->len]", from, to);
+ if (asprintf(&f, "&(%s)->val[(%s)->len]", from, to) < 0)
+ errx(1, "malloc");
if (f == NULL)
errx(1, "malloc");
- asprintf(&T, "&(%s)->val[(%s)->len]", to, to);
+ if (asprintf(&T, "&(%s)->val[(%s)->len]", to, to) < 0)
+ errx(1, "malloc");
if (T == NULL)
errx(1, "malloc");
copy_type(f, T, t->subtype, FALSE);
@@ -228,7 +231,7 @@ generate_type_copy (const Symbol *s)
used_fail = 0;
- fprintf (codefile, "int\n"
+ fprintf (codefile, "int ASN1CALL\n"
"copy_%s(const %s *from, %s *to)\n"
"{\n"
"memset(to, 0, sizeof(*to));\n",
diff --git a/source4/heimdal/lib/asn1/gen_decode.c b/source4/heimdal/lib/asn1/gen_decode.c
index 043cfac2db..ad76c07251 100644
--- a/source4/heimdal/lib/asn1/gen_decode.c
+++ b/source4/heimdal/lib/asn1/gen_decode.c
@@ -320,14 +320,13 @@ decode_type (const char *name, const Type *t, int optional,
break;
ASN1_TAILQ_FOREACH(m, t->members, members) {
- char *s;
+ char *s = NULL;
if (m->ellipsis)
continue;
- asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&",
- name, m->gen_name);
- if (s == NULL)
+ 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);
free (s);
@@ -363,8 +362,7 @@ decode_type (const char *name, const Type *t, int optional,
is_primitive_type(m->type->subtype->type) ? "PRIM" : "CONS",
valuename(m->type->tag.tagclass, m->type->tag.tagvalue));
- asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
- if (s == NULL)
+ if (asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name) < 0 || s == NULL)
errx(1, "malloc");
if(m->optional)
fprintf(codefile,
@@ -388,8 +386,7 @@ decode_type (const char *name, const Type *t, int optional,
ASN1_TAILQ_FOREACH(m, t->members, members) {
char *s;
- asprintf (&s, "%s->%s", name, m->gen_name);
- if (s == NULL)
+ if (asprintf (&s, "%s->%s", name, m->gen_name) < 0 || s == NULL)
errx(1, "malloc");
fprintf(codefile, "if((members & (1 << %d)) == 0)\n", memno);
if(m->optional)
@@ -406,8 +403,8 @@ decode_type (const char *name, const Type *t, int optional,
}
case TSetOf:
case TSequenceOf: {
- char *n;
- char *sname;
+ char *n = NULL;
+ char *sname = NULL;
fprintf (codefile,
"{\n"
@@ -441,11 +438,9 @@ decode_type (const char *name, const Type *t, int optional,
tmpstr, forwstr,
name, tmpstr);
- asprintf (&n, "&(%s)->val[(%s)->len]", name, name);
- if (n == NULL)
+ if (asprintf (&n, "&(%s)->val[(%s)->len]", name, name) < 0 || n == NULL)
errx(1, "malloc");
- asprintf (&sname, "%s_s_of", tmpstr);
- if (sname == NULL)
+ if (asprintf (&sname, "%s_s_of", tmpstr) < 0 || sname == NULL)
errx(1, "malloc");
decode_type (n, t->subtype, 0, forwstr, sname, NULL);
fprintf (codefile,
@@ -472,10 +467,11 @@ decode_type (const char *name, const Type *t, int optional,
decode_primitive ("general_string", name, forwstr);
break;
case TTag:{
- char *tname, *typestring;
+ char *tname = NULL, *typestring = NULL;
char *ide = NULL;
- asprintf(&typestring, "%s_type", tmpstr);
+ if (asprintf(&typestring, "%s_type", tmpstr) < 0 || typestring == NULL)
+ errx(1, "malloc");
fprintf(codefile,
"{\n"
@@ -528,8 +524,7 @@ decode_type (const char *name, const Type *t, int optional,
fprintf(codefile,
"if (%s_datalen > len) { e = ASN1_OVERRUN; %s; }\n"
"len = %s_datalen;\n", tmpstr, forwstr, tmpstr);
- asprintf (&tname, "%s_Tag", tmpstr);
- if (tname == NULL)
+ if (asprintf (&tname, "%s_Tag", tmpstr) < 0 || tname == NULL)
errx(1, "malloc");
decode_type (name, t->subtype, 0, forwstr, tname, ide);
if(support_ber)
@@ -568,7 +563,7 @@ decode_type (const char *name, const Type *t, int optional,
ASN1_TAILQ_FOREACH(m, t->members, members) {
const Type *tt = m->type;
- char *s;
+ char *s = NULL;
Der_class cl;
Der_type ty;
unsigned tag;
@@ -586,9 +581,8 @@ decode_type (const char *name, const Type *t, int optional,
classname(cl),
ty ? "CONS" : "PRIM",
valuename(cl, tag));
- asprintf (&s, "%s(%s)->u.%s", m->optional ? "" : "&",
- name, m->gen_name);
- if (s == NULL)
+ 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);
fprintf(codefile,
@@ -667,7 +661,7 @@ generate_type_decode (const Symbol *s)
{
int preserve = preserve_type(s->name) ? TRUE : FALSE;
- fprintf (codefile, "int\n"
+ fprintf (codefile, "int ASN1CALL\n"
"decode_%s(const unsigned char *p,"
" size_t len, %s *data, size_t *size)\n"
"{\n",
diff --git a/source4/heimdal/lib/asn1/gen_encode.c b/source4/heimdal/lib/asn1/gen_encode.c
index e9b4e7cd12..43f29c1fe1 100644
--- a/source4/heimdal/lib/asn1/gen_encode.c
+++ b/source4/heimdal/lib/asn1/gen_encode.c
@@ -259,13 +259,12 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
break;
ASN1_TAILQ_FOREACH_REVERSE(m, t->members, memhead, members) {
- char *s;
+ char *s = NULL;
if (m->ellipsis)
continue;
- asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
- if (s == NULL)
+ if (asprintf (&s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name) < 0 || s == NULL)
errx(1, "malloc");
fprintf(codefile, "/* %s */\n", m->name);
if (m->optional)
@@ -289,8 +288,8 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
fprintf(codefile,
"{\n"
"struct heim_octet_string *val;\n"
- "size_t elen, totallen = 0;\n"
- "int eret;\n");
+ "size_t elen = 0, totallen = 0;\n"
+ "int eret = 0;\n");
fprintf(codefile,
"if ((%s)->len > UINT_MAX/sizeof(val[0]))\n"
@@ -352,19 +351,17 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
break;
}
case TSequenceOf: {
- char *n;
- char *sname;
+ char *sname = NULL;
+ char *n = NULL;
fprintf (codefile,
"for(i = (%s)->len - 1; i >= 0; --i) {\n"
"size_t %s_for_oldret = ret;\n"
"ret = 0;\n",
name, tmpstr);
- asprintf (&n, "&(%s)->val[i]", name);
- if (n == NULL)
+ if (asprintf (&n, "&(%s)->val[i]", name) < 0 || n == NULL)
errx(1, "malloc");
- asprintf (&sname, "%s_S_Of", tmpstr);
- if (sname == NULL)
+ if (asprintf (&sname, "%s_S_Of", tmpstr) < 0 || sname == NULL)
errx(1, "malloc");
encode_type (n, t->subtype, sname);
fprintf (codefile,
@@ -388,10 +385,9 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
constructed = 0;
break;
case TTag: {
- char *tname;
+ char *tname = NULL;
int c;
- asprintf (&tname, "%s_tag", tmpstr);
- if (tname == NULL)
+ if (asprintf (&tname, "%s_tag", tmpstr) < 0 || tname == NULL)
errx(1, "malloc");
c = encode_type (name, t->subtype, tname);
fprintf (codefile,
@@ -405,20 +401,19 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
}
case TChoice:{
Member *m, *have_ellipsis = NULL;
- char *s;
+ char *s = NULL;
if (t->members == NULL)
break;
fprintf(codefile, "\n");
- asprintf (&s, "(%s)", name);
- if (s == NULL)
+ if (asprintf (&s, "(%s)", name) < 0 || s == NULL)
errx(1, "malloc");
fprintf(codefile, "switch(%s->element) {\n", s);
ASN1_TAILQ_FOREACH_REVERSE(m, t->members, memhead, members) {
- char *s2;
+ char *s2 = NULL;
if (m->ellipsis) {
have_ellipsis = m;
@@ -426,9 +421,8 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
}
fprintf (codefile, "case %s: {", m->label);
- asprintf(&s2, "%s(%s)->u.%s", m->optional ? "" : "&",
- s, m->gen_name);
- if (s2 == NULL)
+ if (asprintf(&s2, "%s(%s)->u.%s", m->optional ? "" : "&",
+ s, m->gen_name) < 0 || s2 == NULL)
errx(1, "malloc");
if (m->optional)
fprintf (codefile, "if(%s) {\n", s2);
@@ -508,7 +502,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
void
generate_type_encode (const Symbol *s)
{
- fprintf (codefile, "int\n"
+ fprintf (codefile, "int ASN1CALL\n"
"encode_%s(unsigned char *p, size_t len,"
" const %s *data, size_t *size)\n"
"{\n",
diff --git a/source4/heimdal/lib/asn1/gen_free.c b/source4/heimdal/lib/asn1/gen_free.c
index dc612074a3..7c88751c32 100644
--- a/source4/heimdal/lib/asn1/gen_free.c
+++ b/source4/heimdal/lib/asn1/gen_free.c
@@ -93,10 +93,9 @@ free_type (const char *name, const Type *t, int preserve)
if(t->type == TChoice)
fprintf(codefile, "case %s:\n", m->label);
- asprintf (&s, "%s(%s)->%s%s",
- m->optional ? "" : "&", name,
- t->type == TChoice ? "u." : "", m->gen_name);
- if (s == NULL)
+ if (asprintf (&s, "%s(%s)->%s%s",
+ m->optional ? "" : "&", name,
+ t->type == TChoice ? "u." : "", m->gen_name) < 0 || s == NULL)
errx(1, "malloc");
if(m->optional)
fprintf(codefile, "if(%s) {\n", s);
@@ -128,8 +127,7 @@ free_type (const char *name, const Type *t, int preserve)
char *n;
fprintf (codefile, "while((%s)->len){\n", name);
- asprintf (&n, "&(%s)->val[(%s)->len-1]", name, name);
- if (n == NULL)
+ if (asprintf (&n, "&(%s)->val[(%s)->len-1]", name, name) < 0 || n == NULL)
errx(1, "malloc");
free_type(n, t->subtype, FALSE);
fprintf(codefile,
@@ -182,7 +180,7 @@ generate_type_free (const Symbol *s)
{
int preserve = preserve_type(s->name) ? TRUE : FALSE;
- fprintf (codefile, "void\n"
+ fprintf (codefile, "void ASN1CALL\n"
"free_%s(%s *data)\n"
"{\n",
s->gen_name, s->gen_name);
diff --git a/source4/heimdal/lib/asn1/gen_glue.c b/source4/heimdal/lib/asn1/gen_glue.c
index 32680cef41..5ab93305a2 100644
--- a/source4/heimdal/lib/asn1/gen_glue.c
+++ b/source4/heimdal/lib/asn1/gen_glue.c
@@ -103,7 +103,7 @@ generate_units (const Type *t, const char *gen_name)
gen_name, gen_name);
} else {
fprintf (headerfile,
- "const struct units * asn1_%s_units(void);",
+ "const struct units * asn1_%s_units(void);\n",
gen_name);
}
diff --git a/source4/heimdal/lib/asn1/gen_length.c b/source4/heimdal/lib/asn1/gen_length.c
index da6d26e373..20b5adfe5d 100644
--- a/source4/heimdal/lib/asn1/gen_length.c
+++ b/source4/heimdal/lib/asn1/gen_length.c
@@ -149,10 +149,9 @@ length_type (const char *name, const Type *t,
if(t->type == TChoice)
fprintf(codefile, "case %s:\n", m->label);
- asprintf (&s, "%s(%s)->%s%s",
- m->optional ? "" : "&", name,
- t->type == TChoice ? "u." : "", m->gen_name);
- if (s == NULL)
+ if (asprintf (&s, "%s(%s)->%s%s",
+ m->optional ? "" : "&", name,
+ t->type == TChoice ? "u." : "", m->gen_name) < 0 || s == NULL)
errx(1, "malloc");
if (m->optional)
fprintf (codefile, "if(%s)", s);
@@ -183,24 +182,22 @@ length_type (const char *name, const Type *t,
}
case TSetOf:
case TSequenceOf: {
- char *n;
- char *sname;
+ char *n = NULL;
+ char *sname = NULL;
fprintf (codefile,
"{\n"
- "int %s_oldret = %s;\n"
+ "size_t %s_oldret = %s;\n"
"int i;\n"
"%s = 0;\n",
tmpstr, variable, variable);
fprintf (codefile, "for(i = (%s)->len - 1; i >= 0; --i){\n", name);
- fprintf (codefile, "int %s_for_oldret = %s;\n"
+ fprintf (codefile, "size_t %s_for_oldret = %s;\n"
"%s = 0;\n", tmpstr, variable, variable);
- asprintf (&n, "&(%s)->val[i]", name);
- if (n == NULL)
+ if (asprintf (&n, "&(%s)->val[i]", name) < 0 || n == NULL)
errx(1, "malloc");
- asprintf (&sname, "%s_S_Of", tmpstr);
- if (sname == NULL)
+ if (asprintf (&sname, "%s_S_Of", tmpstr) < 0 || sname == NULL)
errx(1, "malloc");
length_type(n, t->subtype, variable, sname);
fprintf (codefile, "%s += %s_for_oldret;\n",
@@ -248,9 +245,8 @@ length_type (const char *name, const Type *t,
fprintf (codefile, "/* NULL */\n");
break;
case TTag:{
- char *tname;
- asprintf(&tname, "%s_tag", tmpstr);
- if (tname == NULL)
+ char *tname = NULL;
+ if (asprintf(&tname, "%s_tag", tmpstr) < 0 || tname == NULL)
errx(1, "malloc");
length_type (name, t->subtype, variable, tname);
fprintf (codefile, "ret += %lu + der_length_len (ret);\n",
@@ -271,7 +267,7 @@ void
generate_type_length (const Symbol *s)
{
fprintf (codefile,
- "size_t\n"
+ "size_t ASN1CALL\n"
"length_%s(const %s *data)\n"
"{\n"
"size_t ret = 0;\n",
diff --git a/source4/heimdal/lib/asn1/gen_seq.c b/source4/heimdal/lib/asn1/gen_seq.c
index ec3ccc265e..ac7b9ed0ba 100644
--- a/source4/heimdal/lib/asn1/gen_seq.c
+++ b/source4/heimdal/lib/asn1/gen_seq.c
@@ -47,8 +47,8 @@ generate_type_seq (const Symbol *s)
while(type->type == TTag)
type = type->subtype;
- if (type->type != TSequenceOf) {
- printf("%s not seq of %d\n", s->name, (int)type->type);
+ if (type->type != TSequenceOf && type->type != TSetOf) {
+ fprintf(stderr, "%s not seq of %d\n", s->name, (int)type->type);
return;
}
@@ -67,12 +67,12 @@ generate_type_seq (const Symbol *s)
subname = type->subtype->symbol->gen_name;
fprintf (headerfile,
- "int add_%s (%s *, const %s *);\n"
- "int remove_%s (%s *, unsigned int);\n",
+ "ASN1EXP int ASN1CALL add_%s (%s *, const %s *);\n"
+ "ASN1EXP int ASN1CALL remove_%s (%s *, unsigned int);\n",
s->gen_name, s->gen_name, subname,
s->gen_name, s->gen_name);
- fprintf (codefile, "int\n"
+ fprintf (codefile, "int ASN1CALL\n"
"add_%s(%s *data, const %s *element)\n"
"{\n",
s->gen_name, s->gen_name, subname);
@@ -93,7 +93,7 @@ generate_type_seq (const Symbol *s)
fprintf (codefile, "}\n\n");
- fprintf (codefile, "int\n"
+ fprintf (codefile, "int ASN1CALL\n"
"remove_%s(%s *data, unsigned int element)\n"
"{\n",
s->gen_name, s->gen_name);
diff --git a/source4/heimdal/lib/asn1/gen_template.c b/source4/heimdal/lib/asn1/gen_template.c
index 8d4d9b49c2..9e09eb2d8d 100644
--- a/source4/heimdal/lib/asn1/gen_template.c
+++ b/source4/heimdal/lib/asn1/gen_template.c
@@ -224,7 +224,8 @@ partial_offset(const char *basetype, const char *name, int need_offset)
char *str;
if (name == NULL || need_offset == 0)
return strdup("0");
- asprintf(&str, "offsetof(struct %s, %s)", basetype, name);
+ if (asprintf(&str, "offsetof(struct %s, %s)", basetype, name) < 0 || str == NULL)
+ errx(1, "malloc");
return str;
}
@@ -273,7 +274,8 @@ tlist_header(struct tlist *t, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- vasprintf(&t->header, fmt, ap);
+ if (vasprintf(&t->header, fmt, ap) < 0 || t->header == NULL)
+ errx(1, "malloc");
va_end(ap);
}
@@ -389,7 +391,8 @@ add_line(struct templatehead *t, const char *fmt, ...)
struct template *q = calloc(1, sizeof(*q));
va_list ap;
va_start(ap, fmt);
- vasprintf(&q->line, fmt, ap);
+ if (vasprintf(&q->line, fmt, ap) < 0 || q->line == NULL)
+ errx(1, "malloc");
va_end(ap);
ASN1_TAILQ_INSERT_TAIL(t, q, members);
return q;
@@ -404,10 +407,11 @@ add_line_pointer(struct templatehead *t,
{
struct template *q;
va_list ap;
- char *tt;
+ char *tt = NULL;
va_start(ap, ttfmt);
- vasprintf(&tt, ttfmt, ap);
+ if (vasprintf(&tt, ttfmt, ap) < 0 || tt == NULL)
+ errx(1, "malloc");
va_end(ap);
q = add_line(t, "{ %s, %s, asn1_%s }", tt, offset, ptr);
@@ -543,7 +547,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
struct template *q;
Member *m;
size_t count = 0, i;
- char *bname;
+ char *bname = NULL;
FILE *f = get_code_file();
if (ASN1_TAILQ_EMPTY(t->members)) {
@@ -551,7 +555,8 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
break;
}
- asprintf(&bname, "bmember_%s_%lu", name ? name : "", (unsigned long)t);
+ if (asprintf(&bname, "bmember_%s_%lu", name ? name : "", (unsigned long)t) < 0 || bname == NULL)
+ errx(1, "malloc");
output_name(bname);
ASN1_TAILQ_FOREACH(m, t->members, members) {
@@ -583,15 +588,18 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
Member *m;
ASN1_TAILQ_FOREACH(m, t->members, members) {
- char *newbasename;
-
+ char *newbasename = NULL;
+
if (m->ellipsis)
continue;
- if (name)
- asprintf(&newbasename, "%s_%s", basetype, name);
- else
+ if (name) {
+ if (asprintf(&newbasename, "%s_%s", basetype, name) < 0)
+ errx(1, "malloc");
+ } else
newbasename = strdup(basetype);
+ if (newbasename == NULL)
+ errx(1, "malloc");
template_members(temp, newbasename, m->gen_name, m->type, m->optional, isstruct, 1);
@@ -601,7 +609,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
break;
}
case TTag: {
- char *tname, *elname;
+ char *tname = NULL, *elname = NULL;
const char *sename, *dupname;
int subtype_is_struct = is_struct(t->subtype, isstruct);
@@ -610,10 +618,12 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
else
sename = symbol_name(basetype, t->subtype);
- asprintf(&tname, "tag_%s_%lu", name ? name : "", (unsigned long)t);
+ if (asprintf(&tname, "tag_%s_%lu", name ? name : "", (unsigned long)t) < 0 || tname == NULL)
+ errx(1, "malloc");
output_name(tname);
- asprintf(&elname, "%s_%s", basetype, tname);
+ if (asprintf(&elname, "%s_%s", basetype, tname) < 0 || elname == NULL)
+ errx(1, "malloc");
generate_template_type(elname, &dupname, NULL, sename, name,
t->subtype, 0, subtype_is_struct, 0);
@@ -633,16 +643,17 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
case TSetOf:
case TSequenceOf: {
const char *type, *tname, *dupname;
- char *sename, *elname;
+ char *sename = NULL, *elname = NULL;
int subtype_is_struct = is_struct(t->subtype, 0);
if (name && subtype_is_struct) {
tname = "seofTstruct";
- asprintf(&sename, "%s_%s_val",
- basetype, name);
+ if (asprintf(&sename, "%s_%s_val", basetype, name) < 0)
+ errx(1, "malloc");
} else if (subtype_is_struct) {
tname = "seofTstruct";
- asprintf(&sename, "%s_val", symbol_name(basetype, t->subtype));
+ if (asprintf(&sename, "%s_val", symbol_name(basetype, t->subtype)) < 0)
+ errx(1, "malloc");
} else {
if (name)
tname = name;
@@ -650,12 +661,15 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
tname = "seofTstruct";
sename = strdup(symbol_name(basetype, t->subtype));
}
+ if (sename == NULL)
+ errx(1, "malloc");
if (t->type == TSetOf) type = "A1_OP_SETOF";
else if (t->type == TSequenceOf) type = "A1_OP_SEQOF";
else abort();
- asprintf(&elname, "%s_%s_%lu", basetype, tname, (unsigned long)t);
+ if (asprintf(&elname, "%s_%s_%lu", basetype, tname, (unsigned long)t) < 0 || elname == NULL)
+ errx(1, "malloc");
generate_template_type(elname, &dupname, NULL, sename, NULL, t->subtype,
0, subtype_is_struct, need_offset);
@@ -668,21 +682,22 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
struct templatehead template = ASN1_TAILQ_HEAD_INITIALIZER(template);
struct template *q;
size_t count = 0, i;
- char *tname;
+ char *tname = NULL;
FILE *f = get_code_file();
Member *m;
int ellipsis = 0;
char *e;
- asprintf(&tname, "asn1_choice_%s_%s%x",
- basetype, name ? name : "", (unsigned int)(uintptr_t)t);
+ if (asprintf(&tname, "asn1_choice_%s_%s%x",
+ basetype, name ? name : "", (unsigned int)(uintptr_t)t) < 0 || tname == NULL)
+ errx(1, "malloc");
ASN1_TAILQ_FOREACH(m, t->members, members) {
const char *dupname;
- char *elname;
- char *newbasename;
+ char *elname = NULL;
+ char *newbasename = NULL;
int subtype_is_struct;
-
+
if (m->ellipsis) {
ellipsis = 1;
continue;
@@ -690,13 +705,19 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
subtype_is_struct = is_struct(m->type, 0);
- asprintf(&elname, "%s_choice_%s", basetype, m->gen_name);
+ if (asprintf(&elname, "%s_choice_%s", basetype, m->gen_name) < 0 || elname == NULL)
+ errx(1, "malloc");
- if (subtype_is_struct)
- asprintf(&newbasename, "%s_%s", basetype, m->gen_name);
- else
+ if (subtype_is_struct) {
+ if (asprintf(&newbasename, "%s_%s", basetype, m->gen_name) < 0)
+ errx(1, "malloc");
+ } else
newbasename = strdup(basetype);
+ if (newbasename == NULL)
+ errx(1, "malloc");
+
+
generate_template_type(elname, &dupname, NULL,
symbol_name(newbasename, m->type),
NULL, m->type, 0, subtype_is_struct, 1);
@@ -710,10 +731,11 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
free(newbasename);
}
+ e = NULL;
if (ellipsis) {
- asprintf(&e, "offsetof(%s%s, u.asn1_ellipsis)", isstruct ? "struct " : "", basetype);
- } else
- e = NULL;
+ if (asprintf(&e, "offsetof(%s%s, u.asn1_ellipsis)", isstruct ? "struct " : "", basetype) < 0 || e == NULL)
+ errx(1, "malloc");
+ }
ASN1_TAILQ_FOREACH(q, &template, members) {
count++;
diff --git a/source4/heimdal/lib/asn1/rfc2459.asn1 b/source4/heimdal/lib/asn1/rfc2459.asn1
index 9794ca1514..5df9e41fff 100644
--- a/source4/heimdal/lib/asn1/rfc2459.asn1
+++ b/source4/heimdal/lib/asn1/rfc2459.asn1
@@ -52,6 +52,9 @@ id-rsadsi-des-ede3-cbc OBJECT IDENTIFIER ::= { id-rsadsi-encalg 7 }
id-secsig-sha-1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)
oiw(14) secsig(3) algorithm(2) 26 }
+id-secsig-sha-1WithRSAEncryption OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)
+ oiw(14) secsig(3) algorithm(2) 29 }
+
id-nistAlgorithm OBJECT IDENTIFIER ::= {
joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) 4 }
@@ -241,6 +244,13 @@ DomainParameters ::= SEQUENCE {
validationParms ValidationParms OPTIONAL -- ValidationParms
}
+-- As defined by PKCS3
+DHParameter ::= SEQUENCE {
+ prime INTEGER, -- odd prime, p=jq +1
+ base INTEGER, -- generator, g
+ privateValueLength INTEGER OPTIONAL
+}
+
DHPublicKey ::= INTEGER
OtherName ::= SEQUENCE {