-/* asn_mime.c */
/*
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project.
#include <openssl/x509.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
+#include "internal/evp_int.h"
+#include "internal/bio.h"
#include "asn1_locl.h"
/*
* from parameter values. Quotes are stripped off
*/
-typedef struct {
+struct mime_param_st {
char *param_name; /* Param name e.g. "micalg" */
char *param_value; /* Param value e.g. "sha1" */
-} MIME_PARAM;
+};
-DECLARE_STACK_OF(MIME_PARAM)
-
-typedef struct {
+struct mime_header_st {
char *name; /* Name of line e.g. "content-type" */
char *value; /* Value of line e.g. "text/plain" */
STACK_OF(MIME_PARAM) *params; /* Zero or more parameters */
-} MIME_HEADER;
-
-DECLARE_STACK_OF(MIME_HEADER)
+};
static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
const ASN1_ITEM *it);
BIO *b64;
int r;
b64 = BIO_new(BIO_f_base64());
- if (!b64) {
+ if (b64 == NULL) {
ASN1err(ASN1_F_B64_WRITE_ASN1, ERR_R_MALLOC_FAILURE);
return 0;
}
if (!val)
ASN1err(ASN1_F_B64_READ_ASN1, ASN1_R_DECODE_ERROR);
(void)BIO_flush(bio);
- bio = BIO_pop(bio);
+ BIO_pop(bio);
BIO_free(b64);
return val;
}
int rv = 1;
/*
- * If data is not deteched or resigning then the output BIO is already
+ * If data is not detached or resigning then the output BIO is already
* set up to finalise when it is written through.
*/
if (!(flags & SMIME_DETACHED) || (flags & PKCS7_REUSE_DIGEST)) {
* when streaming as we don't end up with one OCTET STRING per line.
*/
bf = BIO_new(BIO_f_buffer());
- if (!bf)
+ if (bf == NULL)
return 0;
out = BIO_push(bf, out);
if (flags & SMIME_BINARY) {
int len, state, save_state = 0;
headers = sk_MIME_HEADER_new(mime_hdr_cmp);
- if (!headers)
+ if (headers == NULL)
return NULL;
while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
/* If whitespace at line start then continuation line */
int c;
if (name) {
- if ((tmpname = BUF_strdup(name)) == NULL)
+ if ((tmpname = OPENSSL_strdup(name)) == NULL)
return NULL;
for (p = tmpname; *p; p++) {
c = (unsigned char)*p;
}
}
if (value) {
- if ((tmpval = BUF_strdup(value)) == NULL)
+ if ((tmpval = OPENSSL_strdup(value)) == NULL)
goto err;
for (p = tmpval; *p; p++) {
c = (unsigned char)*p;
}
}
mhdr = OPENSSL_malloc(sizeof(*mhdr));
- if (!mhdr)
+ if (mhdr == NULL)
goto err;
mhdr->name = tmpname;
mhdr->value = tmpval;
int c;
MIME_PARAM *mparam = NULL;
if (name) {
- tmpname = BUF_strdup(name);
+ tmpname = OPENSSL_strdup(name);
if (!tmpname)
goto err;
for (p = tmpname; *p; p++) {
}
}
if (value) {
- tmpval = BUF_strdup(value);
+ tmpval = OPENSSL_strdup(value);
if (!tmpval)
goto err;
}
/* Parameter values are case sensitive so leave as is */
mparam = OPENSSL_malloc(sizeof(*mparam));
- if (!mparam)
+ if (mparam == NULL)
goto err;
mparam->param_name = tmpname;
mparam->param_value = tmpval;