asn1: Fix warnings
This commit is contained in:
@@ -461,23 +461,24 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
|
||||
|
||||
if (replace_tag)
|
||||
fprintf(codefile,
|
||||
"{ unsigned char *psave_%s = p;\n"
|
||||
"{ unsigned char *psave_%s = p, *pfree_%s = NULL;\n"
|
||||
"size_t l2_%s, lensave_%s = len;\n"
|
||||
"len = length_%s(%s);\n"
|
||||
/* Allocate a temp buffer for the encoder */
|
||||
"if ((p = malloc(len)) == NULL) return ENOMEM;\n"
|
||||
"if ((p = pfree_%s = malloc(len)) == NULL) return ENOMEM;\n"
|
||||
/* Make p point to the last byte of the allocated buf */
|
||||
"p += len - 1;\n",
|
||||
tmpstr, tmpstr, tmpstr,
|
||||
t->subtype->symbol->gen_name, name);
|
||||
tmpstr, tmpstr, tmpstr, tmpstr,
|
||||
t->subtype->symbol->gen_name, name, tmpstr);
|
||||
|
||||
/* XXX Currently we generate code that leaks `pfree_%s` here. */
|
||||
c = encode_type (name, t->subtype, tname);
|
||||
/* Explicit non-UNIVERSAL tags are always constructed */
|
||||
if (!c && t->tag.tagclass != ASN1_C_UNIV && t->tag.tagenv == TE_EXPLICIT)
|
||||
c = 1;
|
||||
if (replace_tag)
|
||||
fprintf(codefile,
|
||||
"if (len) abort();\n"
|
||||
"if (len) { free(pfree_%s); return EINVAL; }\n"
|
||||
/*
|
||||
* Here we have `p' pointing to one byte before the buffer
|
||||
* we allocated above.
|
||||
@@ -551,8 +552,8 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
|
||||
* \
|
||||
* +-- psave_<fieldName>
|
||||
*/
|
||||
"e = der_put_tag(psave_%s, %zu, %s, %s, %d, &l2_%s);\n"
|
||||
"if (e) return e;\n"
|
||||
"e = der_put_tag(psave_%s, %lu, %s, %s, %d, &l2_%s);\n"
|
||||
"if (e) { free(pfree_%s); return e; }\n"
|
||||
/* Restore `len' and adjust it (see `p' below) */
|
||||
"len = lensave_%s - (l + %zu - asn1_tag_length_%s);\n"
|
||||
/*
|
||||
@@ -561,7 +562,7 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
|
||||
*/
|
||||
"ret += %zu - asn1_tag_length_%s;\n"
|
||||
/* Free the buffer and restore `p' */
|
||||
"free(p + 1);\n"
|
||||
"free(pfree_%s);\n"
|
||||
/*
|
||||
* Make `p' point into the original buffer again, to one
|
||||
* byte before the bytes we wrote:
|
||||
@@ -572,8 +573,8 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
|
||||
* \
|
||||
* +-- p
|
||||
*/
|
||||
"p = psave_%s - (1 + %zu - asn1_tag_length_%s); }\n",
|
||||
tmpstr, tmpstr, t->subtype->symbol->name,
|
||||
"p = psave_%s - (1 + %lu - asn1_tag_length_%s); }\n",
|
||||
tmpstr, tmpstr, tmpstr, t->subtype->symbol->name,
|
||||
tmpstr, t->subtype->symbol->name, t->subtype->symbol->name,
|
||||
tmpstr, length_tag(t->tag.tagvalue),
|
||||
classname(t->tag.tagclass),
|
||||
@@ -581,9 +582,9 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
|
||||
t->tag.tagvalue,
|
||||
tmpstr,
|
||||
|
||||
tmpstr, length_tag(t->tag.tagvalue), t->subtype->symbol->name,
|
||||
tmpstr, tmpstr, length_tag(t->tag.tagvalue), t->subtype->symbol->name,
|
||||
length_tag(t->tag.tagvalue), t->subtype->symbol->name,
|
||||
tmpstr, length_tag(t->tag.tagvalue), t->subtype->symbol->name);
|
||||
tmpstr, tmpstr, length_tag(t->tag.tagvalue), t->subtype->symbol->name);
|
||||
else
|
||||
fprintf(codefile,
|
||||
"e = der_put_length_and_tag (p, len, ret, %s, %s, %s, &l);\n"
|
||||
|
Reference in New Issue
Block a user