1
0
mirror of https://github.com/prirun/p50em.git synced 2026-03-10 12:18:24 +00:00

devpnc.h: check fd before FD_SET

If there is no socket connection, fd will be -1.  On Ubuntu 18.04, gcc doesn't like adding -1 with FD_SET, and gives a buffer overflow abort.
This commit is contained in:
Jim Wilcoxson
2020-04-12 22:42:09 -04:00
committed by GitHub
parent 1816d42238
commit 76a87f62eb

View File

@@ -757,7 +757,8 @@ void pncrecv() {
for (nodeid=0; nodeid<=MAXNODEID; nodeid++)
if (ni[nodeid].cstate == PNCCSAUTH) {
fd = ni[nodeid].fd;
FD_SET(fd, &fds);
if (fd != -1)
FD_SET(fd, &fds);
if (fd > n)
n = fd;
}