[sr-dev] git:4.1:eb2cad0b: p_usrloc: str->s string NULL check before str_dup
Stefan Mititelu
stefan.mititelu at 1and1.ro
Mon Nov 23 12:21:25 CET 2015
Module: kamailio
Branch: 4.1
Commit: eb2cad0ba521c260d7a3b7aeda2642e5eed965a5
URL: https://github.com/kamailio/kamailio/commit/eb2cad0ba521c260d7a3b7aeda2642e5eed965a5
Author: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Date: 2015-11-23T13:19:17+02:00
p_usrloc: str->s string NULL check before str_dup
Don't shm_str_dup() NULL str->s strings.
Add checks to avoid shm_str_dup() warning.
(cherry picked from commit d1c6dc67b222e05be1ff90be9b38846f63866839)
---
Modified: modules/p_usrloc/ucontact.c
---
Diff: https://github.com/kamailio/kamailio/commit/eb2cad0ba521c260d7a3b7aeda2642e5eed965a5.diff
Patch: https://github.com/kamailio/kamailio/commit/eb2cad0ba521c260d7a3b7aeda2642e5eed965a5.patch
---
diff --git a/modules/p_usrloc/ucontact.c b/modules/p_usrloc/ucontact.c
index 10defc5..c458e42 100644
--- a/modules/p_usrloc/ucontact.c
+++ b/modules/p_usrloc/ucontact.c
@@ -67,20 +67,31 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
}
memset(c, 0, sizeof(ucontact_t));
- if (shm_str_dup( &c->c, _contact) < 0) goto error;
- if (shm_str_dup( &c->callid, _ci->callid) < 0) goto error;
- if (shm_str_dup( &c->user_agent, _ci->user_agent) < 0) goto error;
+ if (_contact->s && _contact->len > 0) {
+ if (shm_str_dup( &c->c, _contact) < 0) goto error;
+ }
- if (_ci->received.s && _ci->received.len) {
+ if (_ci->callid->s && _ci->callid->len > 0) {
+ if (shm_str_dup( &c->callid, _ci->callid) < 0) goto error;
+ }
+
+ if (_ci->user_agent->s && _ci->user_agent->len > 0) {
+ if (shm_str_dup( &c->user_agent, _ci->user_agent) < 0) goto error;
+ }
+
+ if (_ci->received.s && _ci->received.len > 0) {
if (shm_str_dup( &c->received, &_ci->received) < 0) goto error;
}
- if (_ci->path && _ci->path->len) {
+
+ if (_ci->path && _ci->path->len > 0) {
if (shm_str_dup( &c->path, _ci->path) < 0) goto error;
}
- if (_ci->ruid.s && _ci->ruid.len) {
+
+ if (_ci->ruid.s && _ci->ruid.len > 0) {
if (shm_str_dup( &c->ruid, &_ci->ruid) < 0) goto error;
}
- if (_ci->instance.s && _ci->instance.len) {
+
+ if (_ci->instance.s && _ci->instance.len > 0) {
if (shm_str_dup( &c->instance, &_ci->instance) < 0) goto error;
}
More information about the sr-dev
mailing list