mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
sd-dhcp-server: check dir_fd with assert_return
This commit is contained in:
parent
edd85c8414
commit
3c321488bc
@ -1592,6 +1592,7 @@ int sd_dhcp_server_set_lease_file(sd_dhcp_server *server, int dir_fd, const char
|
||||
int r;
|
||||
|
||||
assert_return(server, -EINVAL);
|
||||
assert_return(!path || (dir_fd >= 0 || dir_fd == AT_FDCWD), -EBADF);
|
||||
assert_return(!sd_dhcp_server_is_running(server), -EBUSY);
|
||||
|
||||
if (!path) {
|
||||
@ -1604,9 +1605,6 @@ int sd_dhcp_server_set_lease_file(sd_dhcp_server *server, int dir_fd, const char
|
||||
if (!path_is_safe(path))
|
||||
return -EINVAL;
|
||||
|
||||
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
||||
return -EBADF;
|
||||
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
fd = fd_reopen(dir_fd, O_CLOEXEC | O_DIRECTORY | O_PATH);
|
||||
if (fd < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user