Module: kamailio
Branch: master
Commit: 2d0a0d8decbad9cea3d603a5067b6656d659cbf6
URL:
https://github.com/kamailio/kamailio/commit/2d0a0d8decbad9cea3d603a5067b665…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-03-06T09:16:12+01:00
siputils: reintroduced the c function for is_alphanum()
- accidentaly stripped when adding is_alphanumex()
- reported by Carsten Bock
---
Modified: src/modules/siputils/checks.c
Modified: src/modules/siputils/checks.h
Modified: src/modules/siputils/siputils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2d0a0d8decbad9cea3d603a5067b665…
Patch:
https://github.com/kamailio/kamailio/commit/2d0a0d8decbad9cea3d603a5067b665…
---
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index cfddfda..ca6991f 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -807,11 +807,38 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2)
return 1;
}
+
+/*
+ * Check if the parameter contains alphanumeric characters
+ */
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2)
+{
+ str tval = {0, 0};
+ int i;
+
+ if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
+ LM_ERR("cannot get parameter value\n");
+ return -1;
+ }
+ if(tval.len<=0)
+ return -2;
+
+ i = 0;
+ for(; i<tval.len; i++) {
+ if( !((tval.s[i]>='0' && tval.s[i]<='9')
+ || (tval.s[i]>='A' && tval.s[i]<='Z')
+ || (tval.s[i]>='z' && tval.s[i]<='z')) )
+ return -3;
+ }
+
+ return 1;
+}
+
/*
* Check if the parameter contains alphanumeric characters or are part of
* the second parameter
*/
-int is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
{
str tval = {0, 0};
str eset = {0, 0};
diff --git a/src/modules/siputils/checks.h b/src/modules/siputils/checks.h
index f071e24..39a575d 100644
--- a/src/modules/siputils/checks.h
+++ b/src/modules/siputils/checks.h
@@ -127,12 +127,12 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2);
/*
* Check if the parameter contains alphanumeric characters
*/
-int is_alphanum(sip_msg_t *msg, char *_sp, char* _s2);
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2);
/*
* Check if the parameter contains alphanumeric characters or are part of
* the second parameter
*/
-int is_alphanumex(sip_msg_t *msg, char *_sp, char* _se);
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se);
#endif /* CHECKS_H */
diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c
index f01bf6f..519e82b 100644
--- a/src/modules/siputils/siputils.c
+++ b/src/modules/siputils/siputils.c
@@ -179,9 +179,9 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE},
{"is_numeric", (cmd_function)is_numeric, 1, fixup_spve_null,
0, ANY_ROUTE},
- {"is_alphanum", (cmd_function)is_alphanum, 1, fixup_spve_null,
+ {"is_alphanum", (cmd_function)ksr_is_alphanum, 1,
fixup_spve_null,
0, ANY_ROUTE},
- {"is_alphanumex", (cmd_function)is_alphanumex, 2, fixup_spve_spve,
+ {"is_alphanumex", (cmd_function)ksr_is_alphanumex, 2,
fixup_spve_spve,
0, ANY_ROUTE},
{"sip_p_charging_vector", (cmd_function)sip_handle_pcv, 1, fixup_spve_null,
fixup_free_spve_null, ANY_ROUTE},