X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Ftrackfds.h;h=70751d760c68bb6ee3ad2fe924348f1ee6d3ee52;hb=3d46e3ab9b45d83f69e79a338a45f316e3f61dc0;hp=ed2ea57738227a046ee290ded817182d9bca1e4a;hpb=d171e6bbecb87d793003230d2557575d2c6460c0;p=coloredstderr%2Fcoloredstderr.git diff --git a/src/trackfds.h b/src/trackfds.h index ed2ea57..70751d7 100644 --- a/src/trackfds.h +++ b/src/trackfds.h @@ -135,7 +135,10 @@ static void init_from_environment(void) { *x = 0; int fd = atoi(last); - if (fd < TRACKFDS_STATIC_COUNT) { + if (fd < 0) { + goto next; + + } else if (fd < TRACKFDS_STATIC_COUNT) { tracked_fds[fd] = 1; } else { if (!tracked_fds_list) { @@ -169,7 +172,7 @@ static char *update_environment_buffer_entry(char *x, int fd) { assert(fd >= 0); int length = snprintf(x, 10 + 1, "%d", fd); - if (length >= 10 + 1) { + if (length >= 10 + 1 || length <= 0 /* shouldn't happen */) { /* Integer too big to fit the buffer, skip it. */ #ifdef WARNING warning("update_environment_buffer_entry(): truncated fd: %d [%d]\n",