diff options
author | Wieland Hoffmann <themineo@gmail.com> | 2019-05-02 20:10:08 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-05-03 13:22:36 +0200 |
commit | 8a7033ac2f3ac6d30ae7f453074a1ed47243fbf2 (patch) | |
tree | 572e02b6d75687c11c3b4bebfcbf40a994c91bb2 | |
parent | 64538af89b4fe72658d7b33e2022d06805badb14 (diff) | |
download | systemd-8a7033ac2f3ac6d30ae7f453074a1ed47243fbf2.tar.gz |
fstab-generator: Prevent double free of reused FILE*
When the .automount unit file already existed for any reason in the
`normal-dir` passed to `systemd-fstab-generator`, but the normal .mount unit
file did not, `f` was closed (but _not_ set to NULL). The call to
`generator_open_unit_file(..., automount_name, &f)` then failed because the
.mount unit file already existed. Now `f` did not point to an open FILE and the
later cleanup from the `_cleanup_fclose_` attribute failed with a double free.
Reset `f` to NULL before reusing it.
-rw-r--r-- | src/fstab-generator/fstab-generator.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 28ae48d551..76270aec17 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -463,7 +463,7 @@ static int add_mount( if (r < 0) return log_error_errno(r, "Failed to generate unit name: %m"); - fclose(f); + f = safe_fclose(f); r = generator_open_unit_file(dest, "/etc/fstab", automount_name, &f); if (r < 0) |