skupperproject / skupper-router

An application-layer router for Skupper networks
https://skupper.io
Apache License 2.0
14 stars 18 forks source link

Coverity issue: Leaking file descriptor in main.c #1532

Open ganeshmurthy opened 3 weeks ago

ganeshmurthy commented 3 weeks ago
170            if (fd != 0) fail(pipefd[1], "Can't redirect stdin to /dev/null");
      10. Condition dup(fd) < 0, taking false branch.
      CID 379163:(#1 of 2):Resource leak (RESOURCE_LEAK) [ "select issue" ]
      CID 379174:Argument cannot be negative (NEGATIVE_RETURNS) [ "select issue" ]
171            if (dup(fd) < 0) fail(pipefd[1], "Can't redirect stdout to /dev/null");
      11. open_fn: Returning handle opened by dup.
      12. Condition dup(fd) < 0, taking false branch.

CID 379163: (#2 of 2): Resource leak (RESOURCE_LEAK)
13. leaked_handle: Failing to save or close handle opened by dup(fd) leaks it.
172            if (dup(fd) < 0) fail(pipefd[1], "Can't redirect stderr /dev/null");

Also this

      23. Condition pf == NULL, taking true branch.
      24. var_compare_op: Comparing pf to null implies that pf might be null.
      25. Condition *__errno_location(), taking false branch.
228                if (pf == 0) fail(pipefd[1], "Can't write pidfile %s", pidfile);

CID 379178: (#1 of 1): Dereference after null check (FORWARD_NULL)
26. var_deref_model: Passing null pointer pf to fprintf, which dereferences it.
229                fprintf(pf, "%d\n", getpid());
230                fclose(pf);
231            }