From 5c3861dac3f16ff361b816a5a6b7b092a7b76ca5 Mon Sep 17 00:00:00 2001
From: piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>
Date: Wed, 4 Jun 2008 02:04:20 +0000
Subject: - prevent wrong email test on multiple '@'s.

git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4336 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
---
 mbbsd/user.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'mbbsd')

diff --git a/mbbsd/user.c b/mbbsd/user.c
index 10b9f6c8..fe8fede2 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1325,15 +1325,20 @@ u_editplan(void)
 }
 
 int
-isvalidemail(const char *email)
+isvalidemail(char *email)
 {
     FILE           *fp;
     char            buf[128], *c;
     int allow = 0;
 
-    if (!strstr(email, "@"))
-	return 0;
-    for (c = strstr(email, "@"); *c != 0; ++c)
+    c = strchr(email, '@');
+    if (c == NULL) return 0;
+
+    // reject multiple '@'
+    if (c != strrchr(email, '@')) return 0;
+
+    // domain tolower
+    for (; *c != 0; ++c)
 	if ('A' <= *c && *c <= 'Z')
 	    *c += 32;
 
-- 
cgit v1.2.3