Module: kamailio Branch: master Commit: 0baeb4ccad37df13544f475b729975834267e6eb URL: https://github.com/kamailio/kamailio/commit/0baeb4ccad37df13544f475b729975834267e6eb
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2025-08-14T15:22:01+02:00 core: fixup helpers for numbers support hexadecimal format --- Modified: src/core/mod_fix.c Modified: src/core/sr_module.c --- Diff: https://github.com/kamailio/kamailio/commit/0baeb4ccad37df13544f475b729975834267e6eb.diff Patch: https://github.com/kamailio/kamailio/commit/0baeb4ccad37df13544f475b729975834267e6eb.patch --- diff --git a/src/core/mod_fix.c b/src/core/mod_fix.c index 900c982e3c1..aa632635bc1 100644 --- a/src/core/mod_fix.c +++ b/src/core/mod_fix.c @@ -174,11 +174,18 @@ int fixup_uint_uint(void **param, int param_no) s.s = *param; s.len = strlen(s.s); - if(likely(str2int(&s, &num) == 0)) { + if(s.len > 2 && s.s[0] == '0' && s.s[1] == 'x') { + if(hexstr2int(s.s, s.len, &num) < 0) { + /* not a hex number */ + return E_UNSPEC; + } *param = (void *)(long)num; - } else + } else if(likely(str2int(&s, &num) == 0)) { + *param = (void *)(long)num; + } else { /* not a number */ return E_UNSPEC; + } return 0; } diff --git a/src/core/sr_module.c b/src/core/sr_module.c index 6fd2bb32390..85e762ebaa4 100644 --- a/src/core/sr_module.c +++ b/src/core/sr_module.c @@ -1241,13 +1241,22 @@ int fix_param(int type, void **param) case FPARAM_INT: s.s = (char *)*param; s.len = strlen(s.s); - err = str2sint(&s, &num); - if(err == 0) { - p->v.i = (int)num; + if(s.len > 2 && s.s[0] == '0' && s.s[1] == 'x') { + if(hexstr2int(s.s, s.len, (unsigned int *)&num) < 0) { + /* not a hex number */ + pkg_free(p); + return 1; + } + p->v.i = num; } else { - /* Not a number */ - pkg_free(p); - return 1; + err = str2sint(&s, &num); + if(err == 0) { + p->v.i = (int)num; + } else { + /* not a number */ + pkg_free(p); + return 1; + } } p->fixed = (void *)(long)num; break; _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-le...@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!