Module: kamailio
Branch: master
Commit: 0b629dfc66ec7a2f5620ba253f8a932e3f164b07
URL:
https://github.com/kamailio/kamailio/commit/0b629dfc66ec7a2f5620ba253f8a932…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-06-14T10:20:59+02:00
siputils: added e164_max_len modparam
- specify the max length for e164 number check, includting the leading
'+'
- GH #3117
---
Modified: src/modules/siputils/checks.c
Modified: src/modules/siputils/siputils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0b629dfc66ec7a2f5620ba253f8a932…
Patch:
https://github.com/kamailio/kamailio/commit/0b629dfc66ec7a2f5620ba253f8a932…
---
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index 792cfca94a..d9730ddad1 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -48,6 +48,8 @@
#include "../../core/mod_fix.h"
#include "checks.h"
+extern int e164_max_len;
+
/**
* return 1 (true) if the SIP message type is request
*/
@@ -661,7 +663,7 @@ int siputils_e164_check(str* _user)
int i;
char c;
- if ((_user->len > 2) && (_user->len < 17) &&
((_user->s)[0] == '+')) {
+ if ((_user->len > 2) && (_user->len <= e164_max_len) &&
((_user->s)[0] == '+')) {
for (i = 1; i < _user->len; i++) {
c = (_user->s)[i];
if (c < '0' || c > '9') return -1;
diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c
index 2e7ddeb7c0..e7c5e3dcfc 100644
--- a/src/modules/siputils/siputils.c
+++ b/src/modules/siputils/siputils.c
@@ -89,6 +89,9 @@ str rpid_suffix = {DEF_RPID_SUFFIX, sizeof(DEF_RPID_SUFFIX) - 1};
/*! Definition of AVP containing rpid value */
char* rpid_avp_param = DEF_RPID_AVP;
+/* max length for e164 number including the leading '+' */
+int e164_max_len = 16;
+
/* for options functionality */
str opt_accept = str_init(ACPT_DEF);
str opt_accept_enc = str_init(ACPT_ENC_DEF);
@@ -217,6 +220,7 @@ static param_export_t params[] = {
{"rpid_prefix", PARAM_STR, &rpid_prefix },
{"rpid_suffix", PARAM_STR, &rpid_suffix },
{"rpid_avp", PARAM_STRING, &rpid_avp_param },
+ {"e164_max_len", PARAM_INT, &e164_max_len },
{0, 0, 0}
};