[asterisk-commits] may: trunk r403292 - in /trunk: ./ addons/chan_ooh323.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 2 12:12:58 CST 2013


Author: may
Date: Mon Dec  2 12:12:57 2013
New Revision: 403292

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403292
Log:
Check and reject non-digits e164 values on peers and general sections in ooh323.conf
Regenerate e164 endpoint list on reload ooh323
(issue ASTERISK-22901)
Reported by: Cyril CONSTANTIN
Patches:
	ASTERISK-22901.patch
........

Merged revisions 403288 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 403290 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/addons/chan_ooh323.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Dec  2 12:12:57 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403175,403179,403207,403209,403221,403223,403240,403256,403258,403271
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403175,403179,403207,403209,403221,403223,403240,403256,403258,403271,403290

Modified: trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/chan_ooh323.c?view=diff&rev=403292&r1=403291&r2=403292
==============================================================================
--- trunk/addons/chan_ooh323.c (original)
+++ trunk/addons/chan_ooh323.c Mon Dec  2 12:12:57 2013
@@ -2487,11 +2487,23 @@
 					return NULL;
 				}
 			} else if (!strcasecmp(v->name, "e164")) {
-				if (!(peer->e164 = ast_strdup(v->value))) {
-					ast_log(LOG_ERROR, "Could not allocate memory for e164 of "
+				int valid = 1;
+				const char *tmp;
+				for(tmp = v->value; *tmp; tmp++) {
+					if (!isdigit(*tmp)) {
+						valid = 0;
+						break;
+					}
+				}
+				if (valid) {
+					if (!(peer->e164 = ast_strdup(v->value))) {
+						ast_log(LOG_ERROR, "Could not allocate memory for e164 of "
 											 "peer %s\n", name);
-					ooh323_delete_peer(peer);
-					return NULL;
+						ooh323_delete_peer(peer);
+						return NULL;
+					}
+				} else {
+					ast_log(LOG_ERROR, "Invalid e164: %s for peer %s\n", v->value, name);
 				}
 			} else  if (!strcasecmp(v->name, "email")) {
 				if (!(peer->email = ast_strdup(v->value))) {
@@ -2622,6 +2634,9 @@
 
 static int ooh323_do_reload(void)
 {
+	struct ooAliases * pNewAlias = NULL;
+	struct ooh323_peer *peer = NULL;
+
 	if (gH323Debug) {
 		ast_verb(0, "---   ooh323_do_reload\n");
 	}
@@ -2640,6 +2655,46 @@
 								gGatekeeper : 0, 0);
 		ooGkClientStart(gH323ep.gkClient);
 	}
+
+	/* Set aliases if any */
+	if (gH323Debug) {
+		ast_verb(0, "updating local aliases\n");
+	}
+
+	for (pNewAlias = gAliasList; pNewAlias; pNewAlias = pNewAlias->next) {
+		switch (pNewAlias->type) {
+		case T_H225AliasAddress_h323_ID:
+			ooH323EpAddAliasH323ID(pNewAlias->value);
+			break;
+		case T_H225AliasAddress_dialedDigits:	
+			ooH323EpAddAliasDialedDigits(pNewAlias->value);
+			break;
+		case T_H225AliasAddress_email_ID:	
+			ooH323EpAddAliasEmailID(pNewAlias->value);
+			break;
+		default:
+            		;
+		}
+	}
+
+	ast_mutex_lock(&peerl.lock);
+	peer = peerl.peers;
+	while (peer) {
+		if(peer->h323id) {
+			ooH323EpAddAliasH323ID(peer->h323id);
+		}
+		if(peer->email) {
+			ooH323EpAddAliasEmailID(peer->email);
+		}
+		if(peer->e164) {
+			ooH323EpAddAliasDialedDigits(peer->e164);
+		}
+       		if(peer->url) {
+			ooH323EpAddAliasURLID(peer->url);
+		}
+		peer = peer->next;
+	}
+	ast_mutex_unlock(&peerl.lock);
 
 	if (gH323Debug) {
 		ast_verb(0, "+++   ooh323_do_reload\n");
@@ -2724,6 +2779,7 @@
 	  		free(prev);
 		}
 		gAliasList = NULL;
+		ooH323EpClearAllAliases();
 	}
 
 	/* Inintialize everything to default */
@@ -2840,17 +2896,29 @@
 			gAliasList = pNewAlias;
 			pNewAlias = NULL;
 		} else if (!strcasecmp(v->name, "e164")) {
-         		pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
-			if (!pNewAlias) {
-				ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n");
-				ast_config_destroy(cfg);
-				return 1;
+			int valid = 1;
+			const char *tmp;
+			for(tmp = v->value; *tmp; tmp++) {
+				if (!isdigit(*tmp)) {
+					valid = 0;
+					break;
+				}
 			}
-			pNewAlias->type =  T_H225AliasAddress_dialedDigits;
-			pNewAlias->value = strdup(v->value);
-			pNewAlias->next = gAliasList;
-			gAliasList = pNewAlias;
-			pNewAlias = NULL;
+			if (valid) {
+         			pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
+				if (!pNewAlias) {
+					ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n");
+					ast_config_destroy(cfg);
+					return 1;
+				}
+				pNewAlias->type =  T_H225AliasAddress_dialedDigits;
+				pNewAlias->value = strdup(v->value);
+				pNewAlias->next = gAliasList;
+				gAliasList = pNewAlias;
+				pNewAlias = NULL;
+			} else {
+				ast_log(LOG_ERROR, "Invalid e164: %s\n", v->value);
+			}
 		} else if (!strcasecmp(v->name, "email")) {
          		pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
 			if (!pNewAlias) {




More information about the asterisk-commits mailing list