1
0
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:
Mike Yuan 2024-04-13 02:47:42 +08:00
parent edd85c8414
commit 3c321488bc
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3

View File

@ -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)