fix null deref spotted by Seth Hanford, pinpointed by dtucker@
ok florian@
-/* $OpenBSD: gethostnamadr_async.c,v 1.28 2014/03/26 18:13:15 eric Exp $ */
+/* $OpenBSD: gethostnamadr_async.c,v 1.29 2014/05/13 11:57:35 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
return (NULL);
}
+ /* there must be an address and at least one name */
+ if (n < 2)
+ continue;
+
if (reqtype == ASR_GETHOSTBYNAME) {
for (i = 1; i < n; i++) {
if (strcasecmp(data, tokens[i]))
-/* $OpenBSD: getnetnamadr_async.c,v 1.14 2014/03/26 18:13:15 eric Exp $ */
+/* $OpenBSD: getnetnamadr_async.c,v 1.15 2014/05/13 11:57:35 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
return (NULL);
}
+ /* there must be an address and at least one name */
+ if (n < 2)
+ continue;
+
if (reqtype == ASR_GETNETBYADDR) {
net = inet_network(tokens[1]);
if (memcmp(&net, data, sizeof net) == 0)