]> git.lizzy.rs Git - plan9front.git/commitdiff
fix parseip()
authorcinap_lenrek <cinap_lenrek@gmx.de>
Tue, 2 Apr 2013 01:39:24 +0000 (03:39 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Tue, 2 Apr 2013 01:39:24 +0000 (03:39 +0200)
addresses like: "1:2:3:4:5:6:7:255.255.255.255" caused parseip
to write beyond the ip buffer.

sys/src/libip/parseip.c

index 7856b4a6cb86de12053513b8cefe9920edc8afd1..9f5d5dac7f3f2b10e6b7ebc668ee47f7cb54e475 100644 (file)
@@ -74,6 +74,10 @@ parseip(uchar *to, char *from)
                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;