summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/asn1/gen_length.c
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/gen_length.c
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/gen_length.c')
-rw-r--r--source4/heimdal/lib/asn1/gen_length.c28
1 files changed, 12 insertions, 16 deletions
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",