X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/de9510bcaba3fc0377e09259f8b49921c421d269..8dc0685213ead3f8896c83cadc130143ccc4d181:/src/sendmail.c diff --git a/src/sendmail.c b/src/sendmail.c index 0661281..5a6dd59 100644 --- a/src/sendmail.c +++ b/src/sendmail.c @@ -3,7 +3,7 @@ * * This file is part of x3. * - * srvx is free software; you can redistribute it and/or modify + * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. @@ -85,7 +85,7 @@ send_flowed_text(FILE *where, const char *para) break; } else if (eol && (eol < para + (80 - shift))) { /* Newline inside paragraph, no need to wrap. */ - fprintf(where, "%.*s\n", eol - para, para); + fprintf(where, "%.*s\n", (int)(eol - para), para); para = eol + 1; } else { int pos; @@ -100,6 +100,24 @@ send_flowed_text(FILE *where, const char *para) } } +/* moved to tools.c +int +valid_email(email) +{ + for (i=0;iemail_addr[i]) && + to->email_addr[i] != '.' && + to->email_addr[i] != '@' && + to->email_addr[i] != '-' && + to->email_addr[i] != '+' && + to->email_addr[i] != '_' ) + return false; + } + return true; +} +*/ + void sendmail(struct userNode *from, struct handle_info *to, const char *subject, const char *body, int first_time) { @@ -227,6 +245,12 @@ sendmail(struct userNode *from, struct handle_info *to, const char *subject, con argv[argc++] = "-f"; argv[argc++] = fromaddr; } + if(!valid_email(to->email_addr)) + { + log_module(MAIN_LOG, LOG_ERROR, "email address contained illegal chars. Refusing to execv() sendmail."); + _exit(1); + } + argv[argc++] = to->email_addr; argv[argc++] = NULL; if (execv(mpath, (char**)argv) < 0) {