From ffc6529bef6b799795bbb6fb9bcb4590a25e5f4e Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Mon, 27 Sep 2021 12:12:33 -0700 Subject: [PATCH] binutils/aa-features-abi: fix failure to close fd due to shadowed var decl The variable used to store the file descriptor for the --file ended up being declared twice, resulting in the autoclose attribute attached to the first declaration being removed by the shadowed second declaration. Fix this by converting the second declaration to just be an assignment, as was intended. strace output before: [...] ) = 1925 close(1) = 0 exit_group(0) = ? +++ exited with 0 +++ strace output after removing shadow declaration: ) = 1925 close(1) = 0 close(3) = 0 exit_group(0) = ? +++ exited with 0 +++ (File descriptor 3 is what is returned by the open() call on the --file argument.) Signed-off-by: Steve Beattie Acked-by: John Johansen MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/804 --- binutils/aa_features_abi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binutils/aa_features_abi.c b/binutils/aa_features_abi.c index 8885b6a52..ed734aea9 100644 --- a/binutils/aa_features_abi.c +++ b/binutils/aa_features_abi.c @@ -181,7 +181,7 @@ int main(int argc, char **argv) error("failed to extract features abi from the kernel"); } if (opt_file) { - int in = open(opt_file, O_RDONLY); + in = open(opt_file, O_RDONLY); if (in == -1) error("failed to open file '%s'", opt_file); rc = aa_features_new_from_file(&features, in);