/***********************************************************************
X3 ChangeLog
+2006-01-16 Alex Schumann <rubin@afternet.org>
+
+ * src/tools.c: created an email valididty function
+
+ * src/nickserv.c: check valididty of email better
+
+ * src/sendmail.c: check validity of email better
+
2006-01-06 Alex Schumann <rubin@afternet.org>
* src/opserv.c: fix gtrace, trace, csearch and alerts to work when aliased
char *unsplit_string(char *set[], unsigned int max, char *dest);
extern char* x3_strtok(char** save, char* str, char* fs);
+int valid_email(const char *email);
+
#define DECLARE_LIST(STRUCTNAME,ITEMTYPE) struct STRUCTNAME {\
unsigned int used, size;\
ITEMTYPE *list;\
}
return 1;
}
+/* this has been replaced with one in tools.c
static int
is_valid_email_addr(const char *email)
return strchr(email, '@') != NULL;
}
+*/
+
static const char *
visible_email_addr(struct userNode *user, struct handle_info *hi)
{
email_addr = argv[3];
/* Check that the email address looks valid.. */
- if (!is_valid_email_addr(email_addr)) {
+ if (!valid_email(email_addr)) {
reply("NSMSG_BAD_EMAIL_ADDR");
return 0;
}
}
if (nickserv_conf.email_required) {
- if (!is_valid_email_addr(argv[4])) {
+ if (!valid_email(argv[4])) {
reply("NSMSG_BAD_EMAIL_ADDR");
return 0;
}
{
if (argc > 1) {
const char *str;
- if (!is_valid_email_addr(argv[1])) {
+ if (!valid_email(argv[1])) {
send_message(user, nickserv, "NSMSG_BAD_EMAIL_ADDR");
return 0;
}
}
}
+/* moved to tools.c
+int
+valid_email(email)
+{
+ for (i=0;i<strlen(email);i++)
+ {
+ if(!isalnum(to->email_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)
{
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) {
return (tmp);
}
+int valid_email(const char *email)
+{
+ unsigned int i;
+ for (i=0;i<strlen(email);i++)
+ {
+ if(!isalnum(email[i]) &&
+ email[i] != '.' &&
+ email[i] != '@' &&
+ email[i] != '-' &&
+ email[i] != '+' &&
+ email[i] != '_' )
+ return false;
+ }
+ if(strchr(email, '@') == NULL)
+ return false;
+ return true;
+}
+