2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

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 <steve.beattie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/804
This commit is contained in:
Steve Beattie 2021-09-27 12:12:33 -07:00
parent 8137beb265
commit ffc6529bef
No known key found for this signature in database
GPG Key ID: 8D1914B4F3D3B795

View File

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