shithub: drawterm-fdroid

Download patch

ref: af5fa79bc7dfb38c654fd591c4c9d02aad386494
parent: 7b844275cf4d15ded8a6c050583fcb7bba0d4f2e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 27 20:50:31 EST 2016

libip: update parseip() from 9front

--- a/libip/parseip.c
+++ b/libip/parseip.c
@@ -40,7 +40,7 @@
 static int
 ipcharok(int c)
 {
-	return c == '.' || c == ':' || (isascii(c) && isxdigit(c));
+	return c == '.' || c == ':' || isascii(c) && isxdigit(c);
 }
 
 static int
@@ -48,7 +48,7 @@
 {
 	if(c == '\0')
 		return 1;
-	if(c == '.' || c == ':' || (isascii(c) && isalnum(c)))
+	if(c == '.' || c == ':' || isascii(c) && isalnum(c))
 		return 0;
 	return 1;
 }
@@ -74,12 +74,16 @@
 		op = p;
 		x = strtoul(p, &p, 16);
 		if(*p == '.' || (*p == 0 && i == 0)){	/* ends with v4? */
+			if(i > IPaddrlen-4){
+				memset(to, 0, IPaddrlen);
+				return -1;		/* parse error */
+			}
 			p = v4parseip(to+i, op);
 			i += 4;
 			break;
 		}
 		/* v6: at most 4 hex digits, followed by colon or delim */
-		if(x != (ushort)x || (*p != ':' && !delimchar(*p))) {
+		if(x != (ushort)x || *p != ':' && !delimchar(*p)) {
 			memset(to, 0, IPaddrlen);
 			return -1;			/* parse error */
 		}