X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Ftrackfds.h;h=70751d760c68bb6ee3ad2fe924348f1ee6d3ee52;hb=59375c2b7949791d8cad8e5cebde2649bac83ec8;hp=b9089bbd25b0444772c6442ca27dedd3ac7e4334;hpb=6d6ad4423ae87771bd44f90006a648ec03931961;p=coloredstderr%2Fcoloredstderr.git diff --git a/src/trackfds.h b/src/trackfds.h index b9089bb..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", @@ -325,7 +328,7 @@ static int tracked_fds_find_slow(int fd) noinline; * they are not called often enough. */ inline static int tracked_fds_find(int fd) always_inline; -static int tracked_fds_find(int fd) { +inline static int tracked_fds_find(int fd) { assert(fd >= 0); if (fd < TRACKFDS_STATIC_COUNT) {