From ab6e3fce040f9ad27cbce44e9038a24f15b601c8 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sun, 15 Aug 2010 18:31:28 +0400 Subject: 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 --- source4/heimdal/lib/asn1/gen_length.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'source4/heimdal/lib/asn1/gen_length.c') 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", -- cgit