]> git.ipfire.org Git - thirdparty/shadow.git/commit
src/useradd.c: Add fmkstemp() to fix file-descriptor leak
authorAlejandro Colomar <alx@kernel.org>
Fri, 17 May 2024 11:40:58 +0000 (13:40 +0200)
committerAlejandro Colomar <alx@kernel.org>
Fri, 17 May 2024 23:15:10 +0000 (01:15 +0200)
commite7d1508e076bbf4053faacc0370c6fe43d9c8f04
treeacefe707548876ddb5e120cd9755a1fb41730edb
parenta74c4b6ae124a55cd272e574e0d056102f331e17
src/useradd.c: Add fmkstemp() to fix file-descriptor leak

This function creates a temporary file, and returns a FILE pointer to
it.  This avoids dealing with both a file descriptor and a FILE pointer,
and correctly deallocating the resources on error.

The code before this patch was leaking the file descriptor if fdopen(3)
failed.

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/useradd.c