Merge pull request #7943 from yuwata/fix-chase_symlinks

fs-util: use `_cleanup_close_` attribute
This commit is contained in:
Lennart Poettering 2018-01-22 12:42:24 +01:00 committed by GitHub
commit 47925d7f32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 14 deletions

View File

@ -730,7 +730,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
/* Two dots? Then chop off the last bit of what we already found out. */
if (path_equal(first, "/..")) {
_cleanup_free_ char *parent = NULL;
int fd_parent = -1;
_cleanup_close_ int fd_parent = -1;
/* If we already are at the top, then going up will not change anything. This is in-line with
* how the kernel handles this. */
@ -765,6 +765,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
safe_close(fd);
fd = fd_parent;
fd_parent = -1;
continue;
}
@ -833,8 +834,6 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
if (fd < 0)
return -errno;
free(done);
if (flags & CHASE_SAFE) {
if (fstat(fd, &st) < 0)
return -errno;
@ -845,6 +844,8 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
previous_stat = st;
}
free(done);
/* Note that we do not revalidate the root, we take it as is. */
if (isempty(root))
done = NULL;

View File

@ -62,7 +62,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
server->bound_leases[pool_offset] = lease;
assert_se(hashmap_put(server->leases_by_client_id, &lease->client_id, lease) >= 0);
dhcp_server_handle_message(server, (DHCPMessage*)data, size);
(void) dhcp_server_handle_message(server, (DHCPMessage*)data, size);
return 0;
}

View File

@ -21,23 +21,20 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
int r;
if (size > DNS_PACKET_SIZE_MAX)
return 0;
r = dns_packet_new(&p, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX);
if (r < 0)
return 0;
assert_se(dns_packet_new(&p, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX) >= 0);
p->size = 0; /* by default append starts after the header, undo that */
dns_packet_append_blob(p, data, size, NULL);
assert_se(dns_packet_append_blob(p, data, size, NULL) >= 0);
if (size < DNS_PACKET_HEADER_SIZE) {
/* make sure we pad the packet back up to the minimum header size */
assert(p->allocated >= DNS_PACKET_HEADER_SIZE);
assert_se(p->allocated >= DNS_PACKET_HEADER_SIZE);
memzero(DNS_PACKET_DATA(p) + size, DNS_PACKET_HEADER_SIZE - size);
p->size = DNS_PACKET_HEADER_SIZE;
}
dns_packet_extract(p);
(void) dns_packet_extract(p);
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv) {
}
printf("%s... ", name);
fflush(stdout);
(void)LLVMFuzzerTestOneInput((uint8_t*)buf, size);
(void) LLVMFuzzerTestOneInput((uint8_t*)buf, size);
printf("ok\n");
}
return EXIT_SUCCESS;

View File

@ -949,7 +949,7 @@ static int client_parse_message(
pos += sizeof(*option) + optlen;
}
if (r < 0 || !clientid) {
if (!clientid) {
log_dhcp6_client(client, "%s has incomplete options",
dhcp6_message_type_to_string(message->type));
return -EINVAL;

View File

@ -89,7 +89,9 @@ int main(int argc, char *argv[]) {
assert_se(sd_resolve_default(&resolve) >= 0);
/* Test a floating resolver query */
sd_resolve_getaddrinfo(resolve, NULL, "redhat.com", "http", NULL, getaddrinfo_handler, NULL);
r = sd_resolve_getaddrinfo(resolve, NULL, "redhat.com", "http", NULL, getaddrinfo_handler, NULL);
if (r < 0)
log_error_errno(r, "sd_resolve_getaddrinfo(): %m");
/* Make a name -> address query */
r = sd_resolve_getaddrinfo(resolve, &q1, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints, getaddrinfo_handler, NULL);