Dune support (#7880)
[hiphop-php.git] / patches / 0001-Updating-zip_fdopen.patch
blob775a73058b92ef9110c341fdb592ac0f3a83f7dc
1 From c73ea3fc8aacb41fb7a54236d9e9bcca3284e934 Mon Sep 17 00:00:00 2001
2 From: William Lee <wkl@fb.com>
3 Date: Tue, 2 Oct 2018 12:37:47 -0700
4 Subject: [PATCH] Close file descriptors in case of zip_fdopen errors
6 In certain error cases when trying to open invalid ZIP files, zip_fdopen leaks
7 file descriptors since it internally creates dup()-ed FDs and ends up not
8 freeing them.
9 ---
10 lib/zip_fdopen.c | 2 ++
11 1 file changed, 2 insertions(+)
13 diff --git a/third-party/libzip/src/lib/zip_fdopen.c b/third-party/libzip/src/lib/zip_fdopen.c
14 index bbcdf4f..3a6766c 100644
15 --- a/third-party/libzip/src/lib/zip_fdopen.c
16 +++ b/third-party/libzip/src/lib/zip_fdopen.c
17 @@ -68,12 +68,14 @@ zip_fdopen(int fd_orig, int _flags, int *zep)
19 zip_error_init(&error);
20 if ((src = zip_source_filep_create(fp, 0, -1, &error)) == NULL) {
21 + fclose(fp);
22 _zip_set_open_error(zep, &error, 0);
23 zip_error_fini(&error);
24 return NULL;
27 if ((za = zip_open_from_source(src, _flags, &error)) == NULL) {
28 + zip_source_free(src);
29 _zip_set_open_error(zep, &error, 0);
30 zip_error_fini(&error);
31 return NULL;
32 --
33 2.17.1