[sr-dev] git:master:97855a17: core: cfg select - safety check accessing vars before initialization

Daniel-Constantin Mierla miconda at gmail.com
Fri Oct 19 11:34:27 CEST 2018


Module: kamailio
Branch: master
Commit: 97855a1766edf4ecc2cc4e38f3cc0d3cea3190db
URL: https://github.com/kamailio/kamailio/commit/97855a1766edf4ecc2cc4e38f3cc0d3cea3190db

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-10-19T11:34:08+02:00

core: cfg select - safety check accessing vars before initialization

---

Modified: src/core/cfg/cfg_select.c

---

Diff:  https://github.com/kamailio/kamailio/commit/97855a1766edf4ecc2cc4e38f3cc0d3cea3190db.diff
Patch: https://github.com/kamailio/kamailio/commit/97855a1766edf4ecc2cc4e38f3cc0d3cea3190db.patch

---

diff --git a/src/core/cfg/cfg_select.c b/src/core/cfg/cfg_select.c
index b8b5d265a0..175c6bd589 100644
--- a/src/core/cfg/cfg_select.c
+++ b/src/core/cfg/cfg_select.c
@@ -220,7 +220,12 @@ int select_cfg_var(str *res, select_t *s, struct sip_msg *msg)
 			break;
 
 		case CFG_VAR_STR:
-			memcpy(res, p, sizeof(str));
+			if(p) {
+				memcpy(res, p, sizeof(str));
+			} else {
+				res->s = 0;
+				res->len = 0;
+			}
 			break;
 
 		default:




More information about the sr-dev mailing list