| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hunt.c,v 1.36 2009/08/12 07:42:11 dholland Exp $ */ | | 1 | /* $NetBSD: hunt.c,v 1.37 2011/01/05 15:40:55 wiz Exp $ */ |
2 | /* | | 2 | /* |
3 | * Copyright (c) 1983-2003, Regents of the University of California. | | 3 | * Copyright (c) 1983-2003, Regents of the University of California. |
4 | * All rights reserved. | | 4 | * All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are | | 7 | * modification, are permitted provided that the following conditions are |
8 | * met: | | 8 | * met: |
9 | * | | 9 | * |
10 | * + Redistributions of source code must retain the above copyright | | 10 | * + Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * + Redistributions in binary form must reproduce the above copyright | | 12 | * + Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
23 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | | 23 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | | 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | #ifndef lint | | 34 | #ifndef lint |
35 | __RCSID("$NetBSD: hunt.c,v 1.36 2009/08/12 07:42:11 dholland Exp $"); | | 35 | __RCSID("$NetBSD: hunt.c,v 1.37 2011/01/05 15:40:55 wiz Exp $"); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #include <sys/param.h> | | 38 | #include <sys/param.h> |
39 | #include <sys/stat.h> | | 39 | #include <sys/stat.h> |
40 | #include <sys/time.h> | | 40 | #include <sys/time.h> |
41 | #include <sys/poll.h> | | 41 | #include <sys/poll.h> |
42 | #include <ctype.h> | | 42 | #include <ctype.h> |
43 | #include <err.h> | | 43 | #include <err.h> |
44 | #include <errno.h> | | 44 | #include <errno.h> |
45 | #include <curses.h> | | 45 | #include <curses.h> |
46 | #include <signal.h> | | 46 | #include <signal.h> |
47 | #include <stdlib.h> | | 47 | #include <stdlib.h> |
48 | #include <string.h> | | 48 | #include <string.h> |
| @@ -458,28 +458,32 @@ list_drivers(void) | | | @@ -458,28 +458,32 @@ list_drivers(void) |
458 | if (sendto(test_socket, &msg, sizeof msg, 0, | | 458 | if (sendto(test_socket, &msg, sizeof msg, 0, |
459 | (struct sockaddr *) &test, DAEMON_SIZE) < 0) { | | 459 | (struct sockaddr *) &test, DAEMON_SIZE) < 0) { |
460 | leave(1, "sendto"); | | 460 | leave(1, "sendto"); |
461 | /* NOTREACHED */ | | 461 | /* NOTREACHED */ |
462 | } | | 462 | } |
463 | | | 463 | |
464 | get_response: | | 464 | get_response: |
465 | namelen = DAEMON_SIZE; | | 465 | namelen = DAEMON_SIZE; |
466 | errno = 0; | | 466 | errno = 0; |
467 | set[0].fd = test_socket; | | 467 | set[0].fd = test_socket; |
468 | set[0].events = POLLIN; | | 468 | set[0].events = POLLIN; |
469 | for (;;) { | | 469 | for (;;) { |
470 | if (listc + 1 >= listmax) { | | 470 | if (listc + 1 >= listmax) { |
| | | 471 | void *newlistv; |
471 | listmax += 20; | | 472 | listmax += 20; |
472 | listv = realloc(listv, listmax * sizeof(SOCKET)); | | 473 | newlistv = realloc(listv, listmax * sizeof(SOCKET)); |
| | | 474 | if (newlistv == NULL) |
| | | 475 | leave(1, "realloc"); |
| | | 476 | listv = (SOCKET *)newlistv; |
473 | } | | 477 | } |
474 | | | 478 | |
475 | if (poll(set, 1, 1000) == 1 && | | 479 | if (poll(set, 1, 1000) == 1 && |
476 | recvfrom(test_socket, &port_num, sizeof(port_num), | | 480 | recvfrom(test_socket, &port_num, sizeof(port_num), |
477 | 0, (struct sockaddr *) &listv[listc], &namelen) > 0) { | | 481 | 0, (struct sockaddr *) &listv[listc], &namelen) > 0) { |
478 | /* | | 482 | /* |
479 | * Note that we do *not* convert from network to host | | 483 | * Note that we do *not* convert from network to host |
480 | * order since the port number *should* be in network | | 484 | * order since the port number *should* be in network |
481 | * order: | | 485 | * order: |
482 | */ | | 486 | */ |
483 | for (j = 0; j < listc; j += 1) | | 487 | for (j = 0; j < listc; j += 1) |
484 | if (listv[listc].sin_addr.s_addr | | 488 | if (listv[listc].sin_addr.s_addr |
485 | == listv[j].sin_addr.s_addr) | | 489 | == listv[j].sin_addr.s_addr) |