Permalink
Browse files

Prevent loop when writing to stdout in foreground mode causing segfault

  • Loading branch information...
Cizzle authored and vanosg committed Dec 1, 2017
1 parent ea58861 commit affc49eef90560eff6dedcd6464b35f4b36116b4
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/net.c
View
@@ -797,9 +797,15 @@ void safe_write(int fd, const void *buf, size_t count)
{
const char *bytes = buf;
ssize_t ret;
static int inhere = 0;
do {
if ((ret = write(fd, bytes, count)) == -1 && errno != EINTR) {
putlog(LOG_MISC, "*", "Unexpected write() failure on attempt to write %zd bytes to fd %d: %s.", count, fd, strerror(errno));
if (!inhere) {
inhere = 1;
putlog(LOG_MISC, "*", "Unexpected write() failure on attempt to write %zd bytes to fd %d: %s.", count, fd, strerror(errno));
inhere = 0;
}
break;
}
} while ((bytes += ret, count -= ret));

0 comments on commit affc49e

Please sign in to comment.