X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fmhbuild.c;h=01acdb77e030120f951812faafd9efb8fa411ae9;hb=a1a744d898ec8842871dca302e6ae54d9233413f;hp=de2cf4596ac2b5bd499f9c38e38d505afa6b5d15;hpb=cf1205b5cbea2f0cd6ea710ec16c637df85b647c;p=mmh diff --git a/uip/mhbuild.c b/uip/mhbuild.c index de2cf45..01acdb7 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -319,6 +319,7 @@ build_mime(char *infile) struct part **pp; CT ct; FILE *in; + HF hp; umask(~m_gmprot()); @@ -329,7 +330,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"); /* @@ -348,7 +349,6 @@ build_mime(char *infile) switch (state = m_getfld(state, name, buf, sizeof(buf), in)) { case FLD: case FLDPLUS: - case FLDEOF: compnum++; /* abort if draft has Mime-Version header field */ @@ -367,7 +367,7 @@ build_mime(char *infile) while (state == FLDPLUS) state = m_getfld(state, name, buf, sizeof(buf), in); - goto finish_field; + continue; } /* get copies of the buffers */ @@ -384,18 +384,13 @@ build_mime(char *infile) /* Now add the header data to the list */ add_header(ct, np, vp); -finish_field: - /* if this wasn't the last hdr field, then continue */ - if (state != FLDEOF) - continue; - /* else fall... */ + continue; case FILEEOF: adios(EX_CONFIG, NULL, "draft has empty body -- no directives!"); /* NOTREACHED */ case BODY: - case BODYEOF: fseek(in, (long) (-strlen(buf)), SEEK_CUR); break; @@ -411,6 +406,16 @@ finish_field: } /* + ** Iterate through the list of headers and call the function to + ** MIME-ify them if required. + */ + 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 +435,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 +455,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 +536,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 +597,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 +907,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 +918,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 +934,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 +994,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 +1012,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 +1534,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); }