Module: kamailio Branch: 5.1 Commit: d86963283cd7a58d94929959ca09ed31ae9bd116 URL: https://github.com/kamailio/kamailio/commit/d86963283cd7a58d94929959ca09ed31...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2017-12-08T16:55:06+01:00
tls: safety checks for select values
(cherry picked from commit 084364becd2f6f5d6e620721cb0837466c3a2f31)
---
Modified: src/modules/tls/tls_select.c
---
Diff: https://github.com/kamailio/kamailio/commit/d86963283cd7a58d94929959ca09ed31... Patch: https://github.com/kamailio/kamailio/commit/d86963283cd7a58d94929959ca09ed31...
---
diff --git a/src/modules/tls/tls_select.c b/src/modules/tls/tls_select.c index c1c44c3763..ba765ff755 100644 --- a/src/modules/tls/tls_select.c +++ b/src/modules/tls/tls_select.c @@ -198,7 +198,11 @@ static int get_cipher(str* res, sip_msg_t* msg) ERR("Cipher name too long\n"); goto err; } - memcpy(buf, cipher.s, cipher.len); + if(cipher.s!=NULL && cipher.len>0) { + memcpy(buf, cipher.s, cipher.len); + } else { + buf[0] = '\0'; + } res->s = buf; res->len = cipher.len; tcpconn_put(c); @@ -298,7 +302,11 @@ static int get_version(str* res, sip_msg_t* msg) ERR("Version string too long\n"); goto err; } - memcpy(buf, version.s, version.len); + if(version.s!=NULL && version.len>0) { + memcpy(buf, version.s, version.len); + } else { + buf[0] = '\0'; + } res->s = buf; res->len = version.len; tcpconn_put(c);