mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-03 13:38:32 +00:00
Don't bump arrsize in poll_listen() until the realloc has succeeded.
If whine_realloc() fails in poll_listen(), arrsize has already been doubled while pollfds keeps its old size. The next call then sees arrsize != nfds, skips the extension and writes past the end of the array (or through NULL if the very first allocation failed). poll_reset() only clears nfds, so this sticks around until restart. Only update arrsize once the reallocation has succeeded. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f90df6c532
commit
baeb7430e2
1 file changed
+3
-3
+3
-3
@@ -100,13 +100,13 @@ void poll_listen(int fd, short event)
|
||||
{
|
||||
/* Array too small. Extend. */
|
||||
struct pollfd *new;
|
||||
nfds_t newsize = (arrsize == 0) ? 64 : arrsize * 2;
|
||||
|
||||
arrsize = (arrsize == 0) ? 64 : arrsize * 2;
|
||||
|
||||
if (!(new = whine_realloc(pollfds, arrsize * sizeof(struct pollfd))))
|
||||
if (!(new = whine_realloc(pollfds, newsize * sizeof(struct pollfd))))
|
||||
return;
|
||||
|
||||
pollfds = new;
|
||||
arrsize = newsize;
|
||||
}
|
||||
|
||||
memmove(&pollfds[i+1], &pollfds[i], (nfds - i) * sizeof(struct pollfd));
|
||||
|
||||
Reference in new issue
Block a user