The Samba-Bugzilla – Attachment 17759 Details for
Bug 15311
fd_load() function implicitly closes the fd where it should not
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.18, 4.17 and 4.16
bug-15311.txt (text/plain), 1.43 KB, created by
Volker Lendecke
on 2023-02-16 12:31:12 UTC
(
hide
)
Description:
Patch for 4.18, 4.17 and 4.16
Filename:
MIME Type:
Creator:
Volker Lendecke
Created:
2023-02-16 12:31:12 UTC
Size:
1.43 KB
patch
obsolete
>From 6db8cca72d42704b8d76bfbd44773ce00ff1335e Mon Sep 17 00:00:00 2001 >From: baixiangcpp <baixiangcpp@gmail.com> >Date: Fri, 10 Feb 2023 11:01:47 +0800 >Subject: [PATCH] lib:util: File descriptor being closed repeatedly. > >In file_load()/file_lines_load(), the file's fd is obtained using >open(), and in fd_load() the fd is converted to a FILE* using >fdopen(). However, after fclose(), the fd is closed again using >close(). > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=15311 >Signed-off-by: baixiangcpp baixiangcpp@gmail.com >Reviewed-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> > >Autobuild-User(master): Volker Lendecke <vl@samba.org> >Autobuild-Date(master): Thu Feb 16 12:13:05 UTC 2023 on atb-devel-224 > >(cherry picked from commit 206dcf7d426e9e85c896c54839008e194d9a2824) >--- > lib/util/util_file.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > >diff --git a/lib/util/util_file.c b/lib/util/util_file.c >index af90e4a7621..fa5abadedec 100644 >--- a/lib/util/util_file.c >+++ b/lib/util/util_file.c >@@ -175,13 +175,20 @@ _PUBLIC_ char *fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ct > size_t size = 0; > size_t chunk = 1024; > int err; >+ int fd_dup; > > if (maxsize == 0) { > maxsize = SIZE_MAX; > } > >- file = fdopen(fd, "r"); >+ fd_dup = dup(fd); >+ if (fd_dup == -1) { >+ return NULL; >+ } >+ >+ file = fdopen(fd_dup, "r"); > if (file == NULL) { >+ close(fd_dup); > return NULL; > } > >-- >2.30.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
vl
:
review?
(
slow
)
asn
:
review+
Actions:
View
Attachments on
bug 15311
: 17759