浏览代码

uac: Sanity checks

Sanity checks for decode_uri(). Add NULL and len > 0 checks.
Segfault when vsf parameter was empty in the Route: header (e.g 'vsf=').
Stefan Mititelu 10 年之前
父节点
当前提交
d956f397c8
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      modules/uac/replace.c

+ 16 - 0
modules/uac/replace.c

@@ -128,6 +128,22 @@ static inline int decode_uri( str *src , str *dst)
 	int i,j;
 	signed char c;
 
+	/* sanity checks */
+	if (!src) {
+		LM_ERR("NULL src\n");
+		return -1;
+	}
+
+	if (!dst) {
+		LM_ERR("NULL dst\n");
+		return -1;
+	}
+
+	if (!src->s || src->len == 0) {
+		LM_ERR("empty src\n");
+		return -1;
+	}
+
 	/* Count '-' at end and disregard them */
 	for( n=0,i=src->len-1; src->s[i]=='-'; i--)
 		n++;