if FD got reused, clear stale buffered data for old FD

git-svn-id: file:///var/lib/svn/clamav-devel/branches/clamd-proto@4615 77e5149b-7576-45b1-b177-96237e5ba77b
0.95
Török Edvin 17 years ago
parent 4a588824db
commit d100458f04
  1. 5
      ChangeLog
  2. 9
      clamd/others.c

@ -1,3 +1,8 @@
Wed Jan 14 18:28:16 EET 2009 (edwin)
------------------------------------
* clamd/others.c: if FD got reused, clear stale buffered data for
old FD
Wed Jan 14 18:20:56 EET 2009 (edwin)
------------------------------------
* clamd/scanner.c, libclamav/others_common.c: fix build

@ -321,8 +321,15 @@ int fds_add(struct fd_data *data, int fd, int listen_only)
logg("!add_fd: invalid fd passed to add_fd\n");
return -1;
}
/* we may already have this fd, if
* the old FD got closed, and the kernel reused the FD */
for (n = 0; n < data->nfds; n++)
if (data->buf[n].fd == fd) return 0;
if (data->buf[n].fd == fd) {
/* clear stale data in buffer */
data->buf[n].off = 0;
data->buf[n].got_newdata = 0;
return 0;
}
n++;
buf = realloc(data->buf, n*sizeof(*buf));

Loading…
Cancel
Save