Skip to content

Commit

Permalink
lib/ims: check return of strtok(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Feb 7, 2023
1 parent 7a960bd commit 63095ef
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib/ims/ims_getters.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,12 +1247,13 @@ int cscf_get_p_charging_vector(struct sip_msg *msg, str * icid, str * orig_ioi,
LM_DBG("p_charging_vector body is %.*s\n", header_body.len, header_body.s);

p = strtok(header_body.s, " ;:\r\t\n\"=");
loop: if (p > (header_body.s + header_body.len))
loop:
if (p == NULL || p > (header_body.s + header_body.len))
return 1;

if (strncmp(p, "icid-value", 10) == 0) {
p = strtok(NULL, " ;:\r\t\n\"=");
if (p > (header_body.s + header_body.len)) {
if (p == NULL || p > (header_body.s + header_body.len)) {
LM_ERR("cscf_get_p_charging_vector: no value for icid\n");
return 0;
}
Expand All @@ -1272,7 +1273,7 @@ int cscf_get_p_charging_vector(struct sip_msg *msg, str * icid, str * orig_ioi,
} else if (strncmp(p, "orig-ioi", 8) == 0) {

p = strtok(NULL, " ;:\r\t\n\"=");
if (p > (header_body.s + header_body.len)) {
if (p == NULL || p > (header_body.s + header_body.len)) {
LM_ERR("cscf_get_p_charging_vector: no value for icid\n");
return 0;
}
Expand All @@ -1292,7 +1293,7 @@ int cscf_get_p_charging_vector(struct sip_msg *msg, str * icid, str * orig_ioi,
} else if (strncmp(p, "term-ioi", 8) == 0) {

p = strtok(NULL, " ;:\r\t\n\"=");
if (p > (header_body.s + header_body.len)) {
if (p == NULL || p > (header_body.s + header_body.len)) {
LM_ERR("cscf_get_p_charging_vector: no value for icid\n");
return 0;
}
Expand All @@ -1314,7 +1315,7 @@ int cscf_get_p_charging_vector(struct sip_msg *msg, str * icid, str * orig_ioi,
LM_DBG("end\n");
str_free(header_body, pkg);
return 1;
out_of_memory:
out_of_memory:
PKG_MEM_ERROR;
return 0;
}
Expand Down

0 comments on commit 63095ef

Please sign in to comment.