mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-21 17:47:10 +00:00
Merge regression: disconnected_mount_complain dangling fds and alloc fail handling
Signed-off-by: Ryan Lee <ryan.lee@canonical.com> MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1767 Approved-by: Georgia Garcia <georgia.garcia@canonical.com> Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
e7daccedc6
@ -85,6 +85,7 @@ int test_with_old_style_mount() {
|
||||
perror("FAIL: could not open executable file in shadowed dir");
|
||||
close(shadowed_file_fd);
|
||||
close(shadowing_dirfd);
|
||||
close(shadowed_dirfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -137,6 +138,11 @@ int test_with_old_style_mount() {
|
||||
|
||||
DEBUG_PRINTF("Read from disconnected file\n");
|
||||
char *file_contents_buf = calloc(shadowed_file_size+1, sizeof(char));
|
||||
if (file_contents_buf == NULL) {
|
||||
perror("FAIL: could not allocate memory to read file");
|
||||
rc |= 1;
|
||||
goto cleanup_mount;
|
||||
}
|
||||
if (read(shadowed_file_fd, file_contents_buf, shadowed_file_size) == -1) {
|
||||
perror("FAIL: could not read from file after mount");
|
||||
rc |= 1;
|
||||
@ -164,6 +170,7 @@ int test_with_old_style_mount() {
|
||||
rc |= 1;
|
||||
}
|
||||
cleanup_fds:
|
||||
close(shadowed_exec_fd);
|
||||
close(shadowed_file_fd);
|
||||
close(shadowing_dirfd);
|
||||
close(shadowed_exec_fd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user