From: mmj Date: Fri, 31 Oct 2008 12:29:44 +0000 (+1100) Subject: Remove trailing whitespaces and not mmap 0 sized bounce index file X-Git-Tag: RELEASE_1_2_16~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=560b8ec19e5fdf1750e5343885b63eb293e702ed;p=thirdparty%2Fmlmmj.git Remove trailing whitespaces and not mmap 0 sized bounce index file --- diff --git a/src/mlmmj-bounce.c b/src/mlmmj-bounce.c index ad7fdf73..2668e27c 100644 --- a/src/mlmmj-bounce.c +++ b/src/mlmmj-bounce.c @@ -55,7 +55,7 @@ char *fetchindexes(const char *bouncefile) char *indexstr = NULL, *s, *start, *line, *cur, *colon, *next; size_t len; struct stat st; - + fd = open(bouncefile, O_RDONLY); if(fd < 0) { log_error(LOG_ARGS, "Could not open bounceindexfile %s", @@ -68,13 +68,19 @@ char *fetchindexes(const char *bouncefile) bouncefile); } + if(st.st_size == 0) { + log_error(LOG_ARGS, "Bounceindexfile %s is size 0", + bouncefile); + return NULL; + } + start = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if(start == MAP_FAILED) { log_error(LOG_ARGS, "Could not mmap bounceindexfile"); return NULL; } - - + + for(next = cur = start; next < start + st.st_size; next++) { if(*next == '\n') { len = next - cur; @@ -92,7 +98,7 @@ char *fetchindexes(const char *bouncefile) myfree(s); myfree(line); } - + munmap(start, st.st_size); close(fd); @@ -200,7 +206,7 @@ char *dsnparseaddr(const char *mailname) addr = mystrdup(emails.emaillist[0]); for(i = 0; i < emails.emailcount; i++) myfree(emails.emaillist[i]); - myfree(emails.emaillist); + myfree(emails.emaillist); } else { addr = NULL; } @@ -210,7 +216,7 @@ char *dsnparseaddr(const char *mailname) } myfree(line); } - + return NULL; } @@ -325,7 +331,7 @@ int main(int argc, char **argv) i++; } address = lowcaseaddr; - + if(number != NULL && probe != 0) { fprintf(stderr, "You can only specify one of -n or -p\n"); fprintf(stderr, "%s -h for help\n", argv[0]); @@ -375,7 +381,7 @@ int main(int argc, char **argv) myfree(a); exit(EXIT_SUCCESS); } - + /* save the filename with '=' before replacing it with '@' */ bfilename = concatstr(3, listdir, "/bounce/", address); @@ -435,7 +441,7 @@ int main(int argc, char **argv) rename(mailname, savename); myfree(savename); } - + myfree(bfilename); if(dsnbounce && address) myfree(address); diff --git a/src/mlmmj-process.c b/src/mlmmj-process.c index 72158ec7..24178598 100644 --- a/src/mlmmj-process.c +++ b/src/mlmmj-process.c @@ -234,7 +234,7 @@ static enum action do_access(struct strlist *rule_strs, struct strlist *hdrs, } regfree(®exp); - + if (match != not) { if (match) { hdr = mystrdup(hdrs->strs[j]); @@ -354,7 +354,7 @@ int main(int argc, char **argv) mlmmjunsub = concatstr(2, bindir, "/mlmmj-unsub"); mlmmjbounce = concatstr(2, bindir, "/mlmmj-bounce"); myfree(bindir); - + while ((opt = getopt(argc, argv, "hVPm:L:")) != -1) { switch(opt) { case 'L': @@ -410,7 +410,7 @@ int main(int argc, char **argv) S_IRUSR|S_IWUSR); } while ((donemailfd < 0) && (errno == EEXIST)); - + if(donemailfd < 0) { log_error(LOG_ARGS, "could not create %s", donemailname); myfree(donemailname); @@ -431,7 +431,7 @@ int main(int argc, char **argv) headerfilename = concatstr(2, listdir, "/control/customheaders"); hdrfd = open(headerfilename, O_RDONLY); myfree(headerfilename); - + /* footfd is checked in do_all_the_voodo_here(), see above */ footerfilename = concatstr(2, listdir, "/control/footer"); footfd = open(footerfilename, O_RDONLY); @@ -449,9 +449,9 @@ int main(int argc, char **argv) delheaders->strs[delheaders->count++] = mystrdup("From "); delheaders->strs[delheaders->count++] = mystrdup("Return-Path:"); delheaders->strs[delheaders->count] = NULL; - - subjectprefix = ctrlvalue(listdir, "prefix"); - + + subjectprefix = ctrlvalue(listdir, "prefix"); + if(do_all_the_voodo_here(rawmailfd, donemailfd, hdrfd, footfd, (const char**)delheaders->strs, readhdrs, &allheaders, subjectprefix) < 0) { @@ -599,7 +599,7 @@ int main(int argc, char **argv) listaddr = getlistaddr(listdir); alternates = ctrlvalues(listdir, "listaddress"); - + /* checking incoming mail's size */ maxmailsizestr = ctrlvalue(listdir, "maxmailsize"); if(maxmailsizestr) { @@ -648,14 +648,14 @@ int main(int argc, char **argv) "-T", fromemails.emaillist[0], "-F", fromaddr, "-m", queuefilename, (char *)NULL); - + log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); exit(EXIT_FAILURE); } } /* discard malformed mail with invalid From: */ - if(fromemails.emailcount != 1) { + if(fromemails.emailcount != 1) { for(i = 0; i < fromemails.emailcount; i++) printf("fromemails.emaillist[%d] = %s\n", i, fromemails.emaillist[i]); @@ -699,6 +699,8 @@ int main(int argc, char **argv) addrtocc = !(statctrl(listdir, "tocc")); if(addrtocc) { for(i = 0; i < toemails.emailcount; i++) { + log_error(LOG_ARGS, "Found To: %s", + toemails.emaillist[i]); for(j = 0; j < alternates->count; j++) { chomp(alternates->strs[j]); if(strcasecmp(alternates->strs[j], @@ -707,6 +709,8 @@ int main(int argc, char **argv) } } for(i = 0; i < ccemails.emailcount; i++) { + log_error(LOG_ARGS, "Found Cc: %s", + ccemails.emaillist[i]); for(j = 0; j < alternates->count; j++) { chomp(alternates->strs[j]); if(strcasecmp(alternates->strs[j], @@ -720,7 +724,7 @@ int main(int argc, char **argv) myfree(alternates->strs[i]); notoccdenymails = statctrl(listdir, "notoccdenymails"); - + if(addrtocc && !intocc) { /* Don't send a mail about denial to the list, but silently * discard and exit. Also don't in case of it being turned off @@ -783,7 +787,7 @@ int main(int argc, char **argv) moderated = 1; goto startaccess; } - + nosubonlydenymails = statctrl(listdir, "nosubonlydenymails"); @@ -893,7 +897,7 @@ startaccess: exit(EXIT_SUCCESS); } } - + if(!moderated) moderated = statctrl(listdir, "moderated"); if(moderated) { @@ -919,7 +923,7 @@ startaccess: /* XXX: toemails and ccemails etc. have to be myfree() */ exit(EXIT_SUCCESS); } - + execlp(mlmmjsend, mlmmjsend, "-L", listdir, "-m", donemailname, (char *)NULL);