From 609a262447fdc5ed4466a08b76bfb3f506ce2564 Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Mon, 27 Sep 2021 13:09:17 -0700 Subject: [PATCH] binutils/aa-features-abi: fix a couple of minor issues A small patch set to fix two issues with binutils/aa-features-abi: 1. The `aa-features-abi -f` short argument was not added to the `getopt_long()` set of short arguments, resulting in the command incorrectly failing when passed -f 2. Due to variable shadowing the file descriptor for the `--file` argument was not being autoclosed. - binutils/aa-features-abi: make -f short arg actually be accepted - binutils/aa-features-abi: fix failure to close fd due to shadowed var decl Signed-off-by: Steve Beattie Acked-by: John Johansen MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/804 (cherry picked from commit a24cda5ae1bf067f6cd4cababe8a8ea29306fe57) 8137beb2 binutils/aa-features-abi: make -f short arg actually be accepted ffc6529b binutils/aa-features-abi: fix failure to close fd due to shadowed var decl --- binutils/aa_features_abi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binutils/aa_features_abi.c b/binutils/aa_features_abi.c index a92574466..ed734aea9 100644 --- a/binutils/aa_features_abi.c +++ b/binutils/aa_features_abi.c @@ -124,7 +124,7 @@ static char **parse_args(int argc, char **argv) {"stdout", no_argument, 0, ARG_STDOUT}, }; - while ((opt = getopt_long(argc, argv, "+dvhxl:w:", long_opts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "+dvhxf:l:w:", long_opts, NULL)) != -1) { switch (opt) { case 'd': opt_debug = true; @@ -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);