]> granicus.if.org Git - curl/commitdiff
unit1650: fix out of boundary access
authorDaniel Stenberg <daniel@haxx.se>
Sat, 22 Sep 2018 20:53:05 +0000 (22:53 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 23 Sep 2018 21:07:06 +0000 (23:07 +0200)
Fixes #2987
Closes #3035

tests/unit/unit1650.c

index a6278dd3cf3b71925da8ec4842116902503962a2..b76936a9778e39f702632ddab356a1bf56aeecec 100644 (file)
@@ -268,12 +268,12 @@ UNITTEST_START
       rc = doh_decode((unsigned char *)full49, sizeof(full49)-1,
                       DNS_TYPE_A, &d);
       fail_if(d.numaddr != 1, "missing address");
-      a = &d.addr[i];
-      snprintf((char *)buffer, sizeof(buffer), "%d.%d.%d.%d\n",
+      a = &d.addr[0];
+      snprintf((char *)buffer, sizeof(buffer), "%d.%d.%d.%d",
                a->ip.v4 & 0xff, (a->ip.v4>>8) & 0xff,
                (a->ip.v4>>16) & 0xff, a->ip.v4 >>24);
-      if(rc && strcmp((char *)buffer, "127.0.0.1")) {
-        fprintf(stderr, "bad address decoded\n");
+      if(rc || strcmp((char *)buffer, "127.0.0.1")) {
+        fprintf(stderr, "bad address decoded: %s, rc == %d\n", buffer, rc);
         return 7;
       }
       fail_if(d.numcname, "bad cname counter");