]> git.ipfire.org Git - thirdparty/elfutils.git/commit
ar, ranlib: Don't double close file descriptors
authorMark Wielaard <mark@klomp.org>
Sat, 22 Jun 2024 23:29:42 +0000 (01:29 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 22 Jun 2024 23:30:57 +0000 (01:30 +0200)
commit564f3cc77aa7a4d5e650e351d79c15e50c6339cb
tree7d2d3087c0b8b1f2d79774de3c0adc1602180be1
parentfe14f12fa4c1515725d42495dc6226650b778ac4
ar, ranlib: Don't double close file descriptors

Found by GCC14 -Wanalyzer-fd-double-close.

close always closes the given file descriptor even on error. So don't
try to close a file descriptor again on error (even on EINTR). This
could be bad in a multi-threaded environment.

      * src/ar.c (do_oper_extract): Call close and set newfd to -1.
      (do_oper_delete): Likewise.
      (do_oper_insert): Likewise.
      * src/ranlib.c (handle_file): Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ar.c
src/ranlib.c