Module: kamailio
Branch: master
Commit: 61018e4774b0f6f7bda75aad7c74a56f9d14bb4a
URL:
https://github.com/kamailio/kamailio/commit/61018e4774b0f6f7bda75aad7c74a56…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-04-14T11:35:03+02:00
jsonrpcs: define size for _jsonrpcs_stored_id buffer
---
Modified: src/modules/jsonrpcs/jsonrpcs_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/61018e4774b0f6f7bda75aad7c74a56…
Patch:
https://github.com/kamailio/kamailio/commit/61018e4774b0f6f7bda75aad7c74a56…
---
diff --git a/src/modules/jsonrpcs/jsonrpcs_mod.c b/src/modules/jsonrpcs/jsonrpcs_mod.c
index 5ccaf0bac5..e369c62569 100644
--- a/src/modules/jsonrpcs/jsonrpcs_mod.c
+++ b/src/modules/jsonrpcs/jsonrpcs_mod.c
@@ -211,7 +211,8 @@ static jsonrpc_error_t _jsonrpc_error_table[] = {
{0, { 0, 0 } }
};
-static char _jsonrpcs_stored_id[64];
+#define JSONRPCS_STORED_ID_SIZE 72
+static char _jsonrpcs_stored_id[JSONRPCS_STORED_ID_SIZE];
char *jsonrpcs_stored_id_get(void)
{
@@ -409,13 +410,14 @@ static int jsonrpc_send_mode(jsonrpc_ctx_t* ctx, int mode)
"id", 2,
nj->valuestring, strlen(nj->valuestring));
if(mode==1) {
- snprintf(_jsonrpcs_stored_id, 62, "\"%s\"",
nj->valuestring);
+ snprintf(_jsonrpcs_stored_id, JSONRPCS_STORED_ID_SIZE-1,
+ "\"%s\"", nj->valuestring);
}
} else {
srjson_AddNumberToObject(ctx->jrpl, ctx->jrpl->root, "id",
nj->valuedouble);
if(mode==1) {
- snprintf(_jsonrpcs_stored_id, 62, "%lld",
+ snprintf(_jsonrpcs_stored_id, JSONRPCS_STORED_ID_SIZE-1, "%lld",
(long long int)nj->valuedouble);
}
}
@@ -426,13 +428,15 @@ static int jsonrpc_send_mode(jsonrpc_ctx_t* ctx, int mode)
"id", 2,
ctx->jsrid_val, strlen(ctx->jsrid_val));
if(mode==1) {
- snprintf(_jsonrpcs_stored_id, 62, "\"%s\"", ctx->jsrid_val);
+ snprintf(_jsonrpcs_stored_id, JSONRPCS_STORED_ID_SIZE-1,
+ "\"%s\"", ctx->jsrid_val);
}
} else if(ctx->jsrid_type == 2) {
srjson_AddNumberToObject(ctx->jrpl, ctx->jrpl->root, "id",
(double)(*(long*)ctx->jsrid_val));
if(mode==1) {
- snprintf(_jsonrpcs_stored_id, 62, "%ld", *((long*)ctx->jsrid_val));
+ snprintf(_jsonrpcs_stored_id, JSONRPCS_STORED_ID_SIZE-1,
+ "%ld", *((long*)ctx->jsrid_val));
}
}
}