mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Fix #782: Segmentation fault in stats.c:404.
This commit is contained in:
parent
81861aee05
commit
effbf99281
2 changed files with 36 additions and 19 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
30 November 2022: Wouter
|
||||||
|
- Fix #782: Segmentation fault in stats.c:404.
|
||||||
|
|
||||||
28 November 2022: Wouter
|
28 November 2022: Wouter
|
||||||
- Fix for the ignore of tcp events for closed comm points, preserve
|
- Fix for the ignore of tcp events for closed comm points, preserve
|
||||||
the use after free protection features.
|
the use after free protection features.
|
||||||
|
|
|
||||||
52
util/tube.c
52
util/tube.c
|
|
@ -45,6 +45,9 @@
|
||||||
#include "util/netevent.h"
|
#include "util/netevent.h"
|
||||||
#include "util/fptr_wlist.h"
|
#include "util/fptr_wlist.h"
|
||||||
#include "util/ub_event.h"
|
#include "util/ub_event.h"
|
||||||
|
#ifdef HAVE_POLL_H
|
||||||
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef USE_WINSOCK
|
#ifndef USE_WINSOCK
|
||||||
/* on unix */
|
/* on unix */
|
||||||
|
|
@ -396,20 +399,28 @@ int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** perform a select() on the fd */
|
/** perform poll() on the fd */
|
||||||
static int
|
static int
|
||||||
pollit(int fd, struct timeval* t)
|
pollit(int fd, struct timeval* t)
|
||||||
{
|
{
|
||||||
fd_set r;
|
struct pollfd fds;
|
||||||
|
int pret;
|
||||||
|
int msec = -1;
|
||||||
|
memset(&fds, 0, sizeof(fds));
|
||||||
|
fds.fd = fd;
|
||||||
|
fds.events = POLLIN | POLLERR | POLLHUP;
|
||||||
#ifndef S_SPLINT_S
|
#ifndef S_SPLINT_S
|
||||||
FD_ZERO(&r);
|
if(t)
|
||||||
FD_SET(FD_SET_T fd, &r);
|
msec = t->tv_sec*1000 + t->tv_usec/1000;
|
||||||
#endif
|
#endif
|
||||||
if(select(fd+1, &r, NULL, NULL, t) == -1) {
|
|
||||||
|
pret = poll(&fds, 1, msec);
|
||||||
|
|
||||||
|
if(pret == -1)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
if(pret != 0)
|
||||||
errno = 0;
|
return 1;
|
||||||
return (int)(FD_ISSET(fd, &r));
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tube_poll(struct tube* tube)
|
int tube_poll(struct tube* tube)
|
||||||
|
|
@ -426,24 +437,27 @@ int tube_wait(struct tube* tube)
|
||||||
|
|
||||||
int tube_wait_timeout(struct tube* tube, int msec)
|
int tube_wait_timeout(struct tube* tube, int msec)
|
||||||
{
|
{
|
||||||
struct timeval t;
|
int ret = 0;
|
||||||
int fd = tube->sr;
|
|
||||||
fd_set r;
|
|
||||||
t.tv_sec = msec/1000;
|
|
||||||
t.tv_usec = (msec%1000)*1000;
|
|
||||||
#ifndef S_SPLINT_S
|
|
||||||
FD_ZERO(&r);
|
|
||||||
FD_SET(FD_SET_T fd, &r);
|
|
||||||
#endif
|
|
||||||
while(1) {
|
while(1) {
|
||||||
if(select(fd+1, &r, NULL, NULL, &t) == -1) {
|
struct pollfd fds;
|
||||||
|
memset(&fds, 0, sizeof(fds));
|
||||||
|
|
||||||
|
fds.fd = tube->sr;
|
||||||
|
fds.events = POLLIN | POLLERR | POLLHUP;
|
||||||
|
ret = poll(&fds, 1, msec);
|
||||||
|
|
||||||
|
if(ret == -1) {
|
||||||
if(errno == EAGAIN || errno == EINTR)
|
if(errno == EAGAIN || errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (int)(FD_ISSET(fd, &r));
|
|
||||||
|
if(ret != 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tube_read_fd(struct tube* tube)
|
int tube_read_fd(struct tube* tube)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue