X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fspost.c;h=4a24fc4b74989228e0b6c3236eae866e87387701;hp=f755a162cc18d4339995503462bce05497713d68;hb=27f39f1e62375fdd22f4cecab4883b0ad764b361;hpb=15378d1b682670191b2a186391398b1e1a285983 diff --git a/uip/spost.c b/uip/spost.c index f755a16..4a24fc4 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -117,6 +117,7 @@ static enum { static char *tmpfil; static char *subject = NULL; /* the subject field for BCC'ing */ +static struct mailname *from = NULL; /* the from field for BCC'ing */ static char fccs[BUFSIZ] = ""; struct mailname *bccs = NULL; /* list of the bcc recipients */ struct mailname *recipients = NULL; /* list of the recipients */ @@ -357,7 +358,8 @@ putfmt(char *name, char *str, FILE *out) int i; struct headers *hdr; struct mailname addr_start, *addr_end; - size_t addrc; + size_t addrc = 0; + ssize_t ret; addr_end = &addr_start; addr_end->m_next = NULL; @@ -411,7 +413,11 @@ putfmt(char *name, char *str, FILE *out) return; } - addrc = getmboxes(str, &addr_end); + if ((ret = getmboxes(str, &addr_end)) < 0) { + adios(EX_DATAERR, NULL, "can't parse address: %s", str); + } + + addrc += ret; if (aliasflg) { addrc += do_aliasing(&addr_start, &addr_end); @@ -426,22 +432,20 @@ putfmt(char *name, char *str, FILE *out) if (hdr->set & MFRM) { struct mailname *mp = NULL; struct mailname *my = NULL; - unsigned int fromcnt = 0; /* needed because the address parser holds global state */ ismymbox(NULL); - for ( mp = addr_start.m_next; mp; mp = mp->m_next) { + for (mp = addr_start.m_next; mp; mp = mp->m_next) { if (ismymbox(mp)) { msgflags |= MFMM; if (my == NULL) { - my = mp; + from = my = mp; } } - fromcnt++; } - if (fromcnt > 1) { + if (addrc > 1) { sender = my; } } @@ -531,7 +535,8 @@ get_header(char *header, struct headers *table) static void putadr(char *name, struct mailname *nl) { - struct mailname *mp, *mp2; + struct mailname *mp; + char *cp; int linepos; int namelen; @@ -544,8 +549,17 @@ putadr(char *name, struct mailname *nl) fprintf(out, "\n%s: ", name); linepos = namelen; } - linepos = putone(mp->m_text, linepos, namelen); - mp2 = mp; + if (mp->m_ingrp) { + if (mp->m_gname != NULL) { + cp = getcpy(mp->m_gname); + cp = add(";", cp); + linepos = putone(cp, linepos, namelen); + free(cp); + cp = NULL; + } + } else { + linepos = putone(mp->m_text, linepos, namelen); + } mp = mp->m_next; } putc('\n', out); @@ -654,6 +668,9 @@ process_bccs(char *origmsg) for (mp=bccs; mp; mp=mp->m_next) { bccdraft = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out)); fprintf(out, "To: %s\n", mp->m_text); + if (from) { + fprintf(out, "From: %s\n", from->m_text); + } fprintf(out, "Subject: [BCC] %s", subject ? subject : ""); fprintf(out, "%s: %s\n", attach_hdr, origmsg); fprintf(out, "------------\n"); @@ -681,6 +698,7 @@ do_aliasing(struct mailname *start, struct mailname **end) struct mailname *prev, *cur; char *cp; size_t i = 0; + ssize_t e; prev = start; cur = prev->m_next; @@ -690,7 +708,10 @@ do_aliasing(struct mailname *start, struct mailname **end) cp = akvalue(cur->m_mbox); if (strcmp(cp, cur->m_mbox) != 0) { prev->m_next = cur->m_next; - i += getmboxes(cp, &prev); + if ((e = getmboxes(cp, &prev)) < 0) { + goto error; + } + i += e; i -= 1; mnfree(cur); } else { @@ -703,4 +724,7 @@ do_aliasing(struct mailname *start, struct mailname **end) } *end = prev; return i; +error: + adios(EX_CONFIG, NULL, "can't parse alias %s: %s", cur->m_mbox, cp); + return 0; /* not reached */ }