Module: kamailio
Branch: master
Commit: 26d6a518c974cfe509d23e41fe9db6b02f357930
URL:
https://github.com/kamailio/kamailio/commit/26d6a518c974cfe509d23e41fe9db6b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-11-21T20:00:22+01:00
core: ppcfg - use define for size of the buffer for core defined values
---
Modified: src/core/ppcfg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/26d6a518c974cfe509d23e41fe9db6b…
Patch:
https://github.com/kamailio/kamailio/commit/26d6a518c974cfe509d23e41fe9db6b…
---
diff --git a/src/core/ppcfg.c b/src/core/ppcfg.c
index 407918aca72..db574ddf769 100644
--- a/src/core/ppcfg.c
+++ b/src/core/ppcfg.c
@@ -290,7 +290,8 @@ void pp_ifdef_level_error(void)
*/
void pp_define_core(void)
{
- char defval[64];
+#define PP_DEFINE_COREVAL_SIZE 64
+ char defval[PP_DEFINE_COREVAL_SIZE];
char *p;
int n;
str_list_t *sb;
@@ -302,8 +303,9 @@ void pp_define_core(void)
p++;
}
- n = snprintf(p, 64 - (int)(p - defval), "_%u", VERSIONVAL / 1000000);
- if(n < 0 || n >= 64 - (int)(p - defval)) {
+ n = snprintf(p, PP_DEFINE_COREVAL_SIZE - (int)(p - defval), "_%u",
+ VERSIONVAL / 1000000);
+ if(n < 0 || n >= PP_DEFINE_COREVAL_SIZE - (int)(p - defval)) {
LM_ERR("failed to build define token\n");
return;
}
@@ -313,9 +315,9 @@ void pp_define_core(void)
return;
}
- n = snprintf(p, 64 - (int)(p - defval), "_%u_%u", VERSIONVAL / 1000000,
- (VERSIONVAL % 1000000) / 1000);
- if(n < 0 || n >= 64 - (int)(p - defval)) {
+ n = snprintf(p, PP_DEFINE_COREVAL_SIZE - (int)(p - defval), "_%u_%u",
+ VERSIONVAL / 1000000, (VERSIONVAL % 1000000) / 1000);
+ if(n < 0 || n >= PP_DEFINE_COREVAL_SIZE - (int)(p - defval)) {
LM_ERR("failed to build define token\n");
return;
}
@@ -325,9 +327,10 @@ void pp_define_core(void)
return;
}
- n = snprintf(p, 64 - (int)(p - defval), "_%u_%u_%u", VERSIONVAL / 1000000,
- (VERSIONVAL % 1000000) / 1000, VERSIONVAL % 1000);
- if(n < 0 || n >= 64 - (int)(p - defval)) {
+ n = snprintf(p, PP_DEFINE_COREVAL_SIZE - (int)(p - defval), "_%u_%u_%u",
+ VERSIONVAL / 1000000, (VERSIONVAL % 1000000) / 1000,
+ VERSIONVAL % 1000);
+ if(n < 0 || n >= PP_DEFINE_COREVAL_SIZE - (int)(p - defval)) {
LM_ERR("failed to build define token\n");
return;
}
@@ -344,8 +347,8 @@ void pp_define_core(void)
return;
}
- n = snprintf(defval, 64, "%u", VERSIONVAL);
- if(n < 0 || n >= 64) {
+ n = snprintf(defval, PP_DEFINE_COREVAL_SIZE, "%u", VERSIONVAL);
+ if(n < 0 || n >= PP_DEFINE_COREVAL_SIZE) {
LM_ERR("failed to build version define value\n");
return;
}