Index: /branches/rel_avx_2_7_5/src/library/avx_log/avx_log.c
===================================================================
--- /branches/rel_avx_2_7_5/src/library/avx_log/avx_log.c	(revision 9152)
+++ /branches/rel_avx_2_7_5/src/library/avx_log/avx_log.c	(working copy)
@@ -44,6 +44,10 @@
 #define OP_UPDATE_FAC   "-uf"
 #define OP_CLEAR        "-cl"
 
+#define MAX_EMAIL_LEN 320
+#define MAX_EMAIL_LOCAL_PART_LEN 64
+#define MAX_EMAIL_DOMAIN_PART_LEN 253
+
 #ifndef IS_IP6_ADDRESS
 #define IS_IP6_ADDRESS(x)    (strchr(x, ':') != NULL)
 #define IS_IP4_ADDRESS(x)    (strchr(x, '.') != NULL)
@@ -324,6 +328,75 @@
 }
 
 int
+log_alert_email_valid(char *email, char *reason, int reason_max_size)
+{
+        char local_part[MAX_EMAIL_LOCAL_PART_LEN + 1];
+	int local_len = 0;
+	char *domain = NULL;
+	char *at = NULL;
+	char *tld = NULL;
+	int all_digit_flag = 1;
+
+	int email_len = strlen(email);
+	if (email_len < 1 || email_len > MAX_EMAIL_LEN) {
+		snprintf(reason, reason_max_size, "Email: Total length should be greater than 0 and less than or equal to %d", MAX_EMAIL_LEN);
+		return 0;
+	}
+	at = strchr(email,'@');
+	if (!at) {
+		snprintf(reason, reason_max_size, "Email: @ expected");
+		return 0;
+	}
+	local_len = at - email;
+	if (local_len < 1 || local_len > MAX_EMAIL_LOCAL_PART_LEN) {
+		snprintf(reason, reason_max_size, "Email: Local part length should be greater than zero and less than or equal to %d", MAX_EMAIL_LOCAL_PART_LEN);
+		return 0;
+	}
+	snprintf(local_part, sizeof(local_part), "%.*s", local_len, email);
+	if (!str_match(local_part,"^[0-9a-zA-Z!#$%&'*+/=?^_`{|}~-]+([.][0-9a-zA-Z!#$%&'*+/=?^_`{|}~-]+)*$"))
+	{
+		snprintf(reason, reason_max_size, "Email: Local part not in correct format");
+		return 0;
+	}
+
+	domain = at + 1;
+	if (strchr(domain, '@')) {
+		snprintf(reason, reason_max_size, "Email: More than 1 @ in email");
+		return 0;
+	}
+	if (strlen(domain) < 1 || strlen(domain) > MAX_EMAIL_DOMAIN_PART_LEN) {
+		snprintf(reason, reason_max_size, "Email: Domain part length should be greater than zero and less than or equal to %d", MAX_EMAIL_DOMAIN_PART_LEN);
+		return 0;
+	}
+        if (!str_match(domain,"^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$"))
+	{
+		snprintf(reason, reason_max_size, "Email: Domain part not in correct format");
+		return 0;
+	}
+        
+	tld = strrchr(domain, '.');
+	if (tld) {
+		tld++;
+		if (!*tld) {
+			snprintf(reason, reason_max_size, "Email: Domain part can't end with dot");
+			return 0;
+		}
+		while (*tld) {
+			if (!isdigit((unsigned char)*tld)) {
+				all_digit_flag = 0;
+				break;
+			}
+			tld++;
+		}
+	}
+        if (all_digit_flag == 1) {
+		snprintf(reason, reason_max_size, "Email: Top Level Domain can't be all numeric");
+		return 0;
+        }
+        return 1;
+}
+
+int
 avx_log_set_alert_add(int id, char *match, char *email, int interval, char *flag)
 {
         log_alert_buffer_t* alert_buf;
@@ -379,6 +452,12 @@
                         printf("Email: SPACE unexpected.\n");
                         return -1;
                 }
+	        memset(reason, 0, sizeof(reason));
+                if (!log_alert_email_valid(email, reason, sizeof(reason) - 1)) {
+
+                        printf("%s\n", reason);
+                        return -1;
+                }	
         }
         /*check the alert interval*/
         if ( (interval < 0) || (interval > AVX_LOG_MAX_ALERT_INTERVAL) ) {
Index: /branches/rel_avx_2_7_5/src/library/ca_regex/avx_regex.c
===================================================================
--- /branches/rel_avx_2_7_5/src/library/ca_regex/avx_regex.c	(revision 9151)
+++ /branches/rel_avx_2_7_5/src/library/ca_regex/avx_regex.c	(working copy)
@@ -45,7 +45,7 @@
 #include "avx_regex.h"
 #include "patricia.h"
 
-extern regexp *regcomp(char *exp);
+extern regexp *ca_regcomp(char *exp);
 
 #ifdef MALLOC_DEFINE
 MALLOC_DEFINE(M_REGEX_NODE, "regex_node_t",	"regex tree node");
@@ -908,7 +908,7 @@
 	new_regex_node->data = NULL;
 	new_regex_node->perl_regex = 1;
 	
-	new_regex_node->compiledReg = regcomp(pattern);
+	new_regex_node->compiledReg = ca_regcomp(pattern);
 	if(new_regex_node->compiledReg == NULL) {
 		REGEX_FREE(new_regex_node, M_REGEX_NODE);
 		return NULL;
@@ -933,7 +933,7 @@
 		{
 			/* Send back this one, since it is a duplicate */
 			REGEX_FREE(new_regex_node->regular_expression, M_TEMP);
-			regfree(new_regex_node->compiledReg);
+			ca_regfree(new_regex_node->compiledReg);
 			REGEX_FREE(new_regex_node, M_REGEX_NODE);
 			return curr;
 		}
@@ -956,7 +956,7 @@
 			REGEX_FREE(regex_node->regular_expression, M_TEMP);
 		}
 		if(regex_node->compiledReg) {
-			regfree(regex_node->compiledReg);
+			ca_regfree(regex_node->compiledReg);
 		}
 		REGEX_FREE(regex_node, M_REGEX_NODE);
 	}
Index: /branches/rel_avx_2_7_5/src/library/ca_regex/regexp_match.h
===================================================================
--- /branches/rel_avx_2_7_5/src/library/ca_regex/regexp_match.h	(revision 9151)
+++ /branches/rel_avx_2_7_5/src/library/ca_regex/regexp_match.h	(working copy)
@@ -23,8 +23,8 @@
 } regexp;
 
 #ifdef _KERNEL
-regexp *regcomp(char *exp);
-void regfree(regexp *r);
+regexp *ca_regcomp(char *exp);
+void ca_regfree(regexp *r);
 void regerror(const char* s);
 /*extern void regsub();*/
 #endif
Index: /branches/rel_avx_2_7_5/src/library/ca_regex/regexp_match.c
===================================================================
--- /branches/rel_avx_2_7_5/src/library/ca_regex/regexp_match.c	(revision 9151)
+++ /branches/rel_avx_2_7_5/src/library/ca_regex/regexp_match.c	(working copy)
@@ -229,7 +229,7 @@
  * of the structure of the compiled regexp.
  */
 regexp *
-regcomp(char *exp)
+ca_regcomp(char *exp)
 {
 	register regexp *r;
 	register char *scan;
@@ -313,7 +313,7 @@
 
 
 void 
-regfree(regexp * r)
+ca_regfree(regexp * r)
 {
 	REGEX_FREE(r, M_PROXYTEMP);
 }
