Browse code

tls: safety checks for select values

Daniel-Constantin Mierla authored on 08/12/2017 15:42:19
Showing 1 changed files
... ...
@@ -198,7 +198,11 @@ static int get_cipher(str* res, sip_msg_t* msg)
198 198
 		ERR("Cipher name too long\n");
199 199
 		goto err;
200 200
 	}
201
-	memcpy(buf, cipher.s, cipher.len);
201
+	if(cipher.s!=NULL && cipher.len>0) {
202
+		memcpy(buf, cipher.s, cipher.len);
203
+	} else {
204
+		buf[0] = '\0';
205
+	}
202 206
 	res->s = buf;
203 207
 	res->len = cipher.len;
204 208
 	tcpconn_put(c);
... ...
@@ -298,7 +302,11 @@ static int get_version(str* res, sip_msg_t* msg)
298 302
 		ERR("Version string too long\n");
299 303
 		goto err;
300 304
 	}
301
-	memcpy(buf, version.s, version.len);
305
+	if(version.s!=NULL && version.len>0) {
306
+		memcpy(buf, version.s, version.len);
307
+	} else {
308
+		buf[0] = '\0';
309
+	}
302 310
 	res->s = buf;
303 311
 	res->len = version.len;
304 312
 	tcpconn_put(c);