chiark / gitweb /
sel/bres-adns.c: Fix incorrect array bound.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 7 Apr 2020 19:30:49 +0000 (20:30 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 7 Apr 2020 19:37:51 +0000 (20:37 +0100)
GCC helpfully points out that `N(av)' does nothing very useful.  In
fact, I expect that it's almost always zero, which means that we don't
end up assembling addresses correctly.  And we never have done.

How embarrassing.

sel/bres-adns.c

index 0d93ab0ed1af6468d1f3ea70a90926b110f30264..03fafa4f12a9935a717b9940431101e280227633 100644 (file)
@@ -217,7 +217,7 @@ static void report(bres_client *rc, adns_answer *a,
   for (i = 0; i < nn && j < N(n) - 1; i++)
     if (strcmp(n[0], nv[i]) != 0) n[j++] = nv[i];
   n[j++] = 0;
-  for (i = j = 0; i < an && j < N(av) - 1; i++) {
+  for (i = j = 0; i < an && j < N(aa) - 1; i++) {
     if (av[i].addr.sa.sa_family == AF_INET)
       aa[j++] = (char *)&av[i].addr.inet.sin_addr;
   }