]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blobdiff - src/trackfds.h
tests/lib.sh: Minor cleanup.
[coloredstderr/coloredstderr.git] / src / trackfds.h
index ed2ea57738227a046ee290ded817182d9bca1e4a..70751d760c68bb6ee3ad2fe924348f1ee6d3ee52 100644 (file)
@@ -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",