Skip to content

Commit

Permalink
security: don't leak a file descriptor
Browse files Browse the repository at this point in the history
CID 131305 (#1 of 1): Resource leak (RESOURCE_LEAK)
20. leaked_storage: Variable f going out of scope leaks the storage it points to.

CID 131304 (#1 of 1): Resource leak (RESOURCE_LEAK)
16. leaked_storage: Variable f going out of scope leaks the storage it points to.

CID 131302 (#1 of 1): Resource leak (RESOURCE_LEAK)
14. leaked_handle: Handle variable fd going out of scope leaks the handle.

CID 131301 (#1 of 1): Dereference null return value (NULL_RETURNS)
4. dereference: Dereferencing a pointer that might be null f when calling fscanf
  • Loading branch information
avagin committed Oct 22, 2015
1 parent 15ff4ec commit b1cc426
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,8 @@ static ct_process_t __local_enter_cb(ct_handler_t h, ct_process_desc_t ph, int (
return &pr->h;
err:
xfree(pr);
close(wait_sock);
if (wait_sock >= 0)
close(wait_sock);
if (pid > 0)
waitpid(pid, NULL, 0);
return ERR_PTR(-1);
Expand Down
1 change: 1 addition & 0 deletions src/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ static int libct_getpwnam(char *user, char *buf, size_t buflen, struct passwd *r
xfree(gecos);
xfree(home);
xfree(shell);
fclose(f);
return 0;
}

Expand Down

0 comments on commit b1cc426

Please sign in to comment.