[sr-dev] git:master: enum: define the max size for numbers

Daniel-Constantin Mierla miconda at gmail.com
Sun Mar 24 13:55:48 CET 2013


Module: sip-router
Branch: master
Commit: ef8fae0e21ca09725c7f9c06384e0a4ce37c4c6e
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ef8fae0e21ca09725c7f9c06384e0a4ce37c4c6e

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sun Mar 24 13:24:58 2013 +0100

enum: define the max size for numbers

- set it to 22 (previously hardcoded value was 17)
- easier to adjust and check for overlenght
- patch by Marcus Hunger

---

 modules/enum/enum.c |    8 ++++----
 modules/enum/enum.h |    5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/modules/enum/enum.c b/modules/enum/enum.c
index 756f4e5..166be63 100644
--- a/modules/enum/enum.c
+++ b/modules/enum/enum.c
@@ -256,7 +256,7 @@ static inline int is_e164(str* _user)
 	int i;
 	char c;
 	
-	if ((_user->len > 2) && (_user->len < 17) && ((_user->s)[0] == '+')) {
+	if ((_user->len > 2) && (_user->len < MAX_NUM_LEN) && ((_user->s)[0] == '+')) {
 		for (i = 1; i < _user->len; i++) {
 			c = (_user->s)[i];
 			if ((c < '0') || (c > '9')) return -1;
@@ -309,7 +309,7 @@ int is_from_user_enum_2(struct sip_msg* _msg, char* _suffix, char* _service)
 	struct naptr_rdata* naptr;
 
 	str pattern, replacement, result;
-	char string[17];
+	char string[MAX_NUM_LEN];
 
 	if (parse_from_header(_msg) < 0) {
 	    LM_ERR("Failed to parse From header\n");
@@ -754,7 +754,7 @@ int enum_query(struct sip_msg* _msg, str* suffix, str* service)
 	char *user_s;
 	int user_len, i, j;
 	char name[MAX_DOMAIN_SIZE];
-	char string[17];
+	char string[MAX_NUM_LEN];
 
 	LM_DBG("enum_query on suffix <%.*s> service <%.*s>\n",
 	       suffix->len, suffix->s, service->len, service->s);
@@ -818,7 +818,7 @@ int i_enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service)
 	int cc_len;
 	struct rdata* head;
 
-	char string[17];
+	char string[MAX_NUM_LEN];
 
 	str *suffix, *service;
 
diff --git a/modules/enum/enum.h b/modules/enum/enum.h
index 2dffce0..d3d5e2a 100644
--- a/modules/enum/enum.h
+++ b/modules/enum/enum.h
@@ -37,8 +37,9 @@
 
 
 #define MAX_DOMAIN_SIZE 256
-#define MAX_COMPONENT_SIZE 32  /* separator, apex, ... This simplifies checks */
-		
+#define MAX_NUM_LEN 22
+#define MAX_COMPONENT_SIZE (MAX_NUM_LEN * 2)  /* separator, apex, ... This simplifies checks */
+
 
 /*
  * Check if from user is an e164 number and has a naptr record




More information about the sr-dev mailing list