X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmhbuild.c;h=d636cf7c7d069133e4ceeb1059ba24be5ee7b8ae;hp=de2cf4596ac2b5bd499f9c38e38d505afa6b5d15;hb=55ca5bf643035fd37cf0568e5ea73c1a8636b9a6;hpb=cf1205b5cbea2f0cd6ea710ec16c637df85b647c diff --git a/uip/mhbuild.c b/uip/mhbuild.c index de2cf45..d636cf7 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -329,7 +329,7 @@ build_mime(char *infile) /* ** Allocate space for primary (outside) content */ - if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL) + if ((ct = (CT) mh_xcalloc(1, sizeof(*ct))) == NULL) adios(EX_OSERR, NULL, "out of memory"); /* @@ -411,6 +411,18 @@ finish_field: } /* + * Iterate through the list of headers and call the function to MIME-ify + * them if required. + */ + + HF hp; + for (hp = ct->c_first_hf; hp != NULL; hp = hp->next) { + if (encode_rfc2047(hp->name, &hp->value, NULL)) { + adios(EX_DATAERR, NULL, "Unable to encode header \"%s\"", hp->name); + } + } + + /* ** Now add the MIME-Version header field ** to the list of header fields. */ @@ -430,7 +442,7 @@ finish_field: ct->c_subtype = MULTI_MIXED; ct->c_file = getcpy(infile); - if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL) + if ((m = (struct multipart *) mh_xcalloc(1, sizeof(*m))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -450,7 +462,7 @@ finish_field: if (!p) continue; - if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL) + if ((part = (struct part *) mh_xcalloc(1, sizeof(*part))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *pp = part; pp = &part->mp_next; @@ -531,7 +543,7 @@ init_decoded_content(CT ct) { CE ce; - if ((ce = (CE) calloc(1, sizeof(*ce))) == NULL) + if ((ce = (CE) mh_xcalloc(1, sizeof(*ce))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_cefile = ce; @@ -592,7 +604,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp) } /* allocate basic Content structure */ - if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL) + if ((ct = (CT) mh_xcalloc(1, sizeof(*ct))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *ctp = ct; @@ -902,7 +914,7 @@ use_forw: ct->c_subtype = MULTI_DIGEST; if ((m = (struct multipart *) - calloc(1, sizeof(*m))) == NULL) + mh_xcalloc(1, sizeof(*m))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -913,7 +925,7 @@ use_forw: CT p; CE pe; - if ((p = (CT) calloc(1, sizeof(*p))) + if ((p = (CT) mh_xcalloc(1, sizeof(*p))) == NULL) adios(EX_OSERR, NULL, "out of memory"); init_decoded_content(p); @@ -929,7 +941,7 @@ use_forw: msgnum); pe->ce_file = getcpy(buffer); - if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL) + if ((part = (struct part *) mh_xcalloc(1, sizeof(*part))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *pp = part; pp = &part->mp_next; @@ -989,7 +1001,7 @@ use_forw: ct->c_type = CT_MULTIPART; ct->c_subtype = vrsn; - if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL) + if ((m = (struct multipart *) mh_xcalloc(1, sizeof(*m))) == NULL) adios(EX_OSERR, NULL, "out of memory"); ct->c_ctparams = (void *) m; @@ -1007,7 +1019,7 @@ use_forw: continue; if ((part = (struct part *) - calloc(1, sizeof(*part))) == NULL) + mh_xcalloc(1, sizeof(*part))) == NULL) adios(EX_OSERR, NULL, "out of memory"); *pp = part; pp = &part->mp_next; @@ -1529,6 +1541,9 @@ build_headers(CT ct) if (ct->c_descr) { np = getcpy(DESCR_FIELD); vp = concat(" ", ct->c_descr, NULL); + if (encode_rfc2047(DESCR_FIELD, &vp, NULL)) { + adios(EX_DATAERR, NULL, "Unable to encode %s header", DESCR_FIELD); + } add_header(ct, np, vp); }