diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/util_file.c | 9 |
1 files changed, 8 insertions, 1 deletions
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; } |