mirror of
https://github.com/samba-team/samba.git
synced 2025-03-09 08:58:35 +03:00
lib:util: Move open() of /dev/null into the if-clause
"Error: RESOURCE_LEAK (CWE-772): samba-4.20.0rc2/lib/util/close_low_fd.c:40: open_fn: Returning handle opened by ""open"". [Note: The source code implementation of the function has been overridden by a user model.] samba-4.20.0rc2/lib/util/close_low_fd.c:40: var_assign: Assigning: ""dev_null"" = handle returned from ""open(""/dev/null"", 2, 0)"". samba-4.20.0rc2/lib/util/close_low_fd.c:52: overwrite_var: Overwriting handle ""dev_null"" in ""dev_null = open(""/dev/null"", 2, 0)"" leaks the handle. 50| } 51| 52|-> dev_null = open(""/dev/null"", O_RDWR, 0); 53| if (dev_null == -1) { 54| dev_null = open(""/dev/null"", O_WRONLY, 0);" Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
This commit is contained in:
parent
ddadbddb40
commit
d21b8e057c
@ -47,9 +47,10 @@ _PUBLIC_ int close_low_fd(int fd)
|
||||
if (ret != 0) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
dev_null = open("/dev/null", O_RDWR, 0);
|
||||
}
|
||||
|
||||
dev_null = open("/dev/null", O_RDWR, 0);
|
||||
if (dev_null == -1) {
|
||||
dev_null = open("/dev/null", O_WRONLY, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user