Skip to content

Commit

Permalink
parasite: take into account the fact that a file descriptor can be zero
Browse files Browse the repository at this point in the history
6. Condition "rst > 0", taking false branch
7. off_by_one: Testing whether handle "rst" is strictly greater than
   zero is suspicious. Did you intend to include equality with zero?
   "rst" leaks when it is zero.

CID 1072986 (cyrillos#3 of 4): Resource leak (RESOURCE_LEAK)
12. leaked_handle: Handle variable "rst" going out of scope leaks the
handle.
  • Loading branch information
avagin committed Sep 3, 2013
1 parent 6b6a6b9 commit 539e57c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parasite-syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
if (ssock < 0)
pr_perror("Can't create socket");

if (rst > 0 && restore_ns(rst, &net_ns_desc) < 0)
if (rst >= 0 && restore_ns(rst, &net_ns_desc) < 0)
return -1;
if (ssock < 0)
return -1;
Expand Down

0 comments on commit 539e57c

Please sign in to comment.