char* dir_name = _zzip_strndup(name, p-name);
makedirs(dir_name);
free (dir_name);
- } else {
- _zzip_mkdir(name, 775);
- errno = 0;
+ }
+ if (_zzip_mkdir(name, 0775) == -1 && errno != EEXIST)
+ {
+ DBG3("while mkdir %s : %s", name, strerror(errno));
}
+ errno = 0;
}
static FILE* create_fopen(char* name, char* mode, int subdirs)
char* dir_name = _zzip_strndup(name, p-name);
makedirs(dir_name);
free (dir_name);
- } else {
- _zzip_mkdir(name, 775);
- errno = 0;
}
+ if (_zzip_mkdir(name, 0775) == -1 && errno != EEXIST)
+ {
+ DBG3("while mkdir %s : %s", name, strerror(errno));
+ }
+ errno = 0;
}
static FILE* create_fopen(char* name, char* mode, int subdirs)
char* dir_name = _zzip_strndup(name, p-name);
makedirs(dir_name);
free (dir_name);
- } else {
- _zzip_mkdir(name, 775);
- errno = 0;
}
+ if (_zzip_mkdir(name, 0775) == -1 && errno != EEXIST)
+ {
+ DBG3("while mkdir %s : %s", name, strerror(errno));
+ }
+ errno = 0;
}
static FILE* create_fopen(char* name, char* mode, int subdirs)
#include <zzip/__mkdir.h>
#include <zzip/__string.h>
#include <zzip/__fnmatch.h>
+#include <zzip/__debug.h>
#include "unzzipcat-zip.h"
#include "unzzip-states.h"
char* dir_name = _zzip_strndup(name, p-name);
makedirs(dir_name);
free (dir_name);
- } else {
- _zzip_mkdir(name, 775);
- errno = 0;
+ }
+ if (_zzip_mkdir(name, 0775) == -1 && errno != EEXIST)
+ {
+ DBG3("while mkdir %s : %s", name, strerror(errno));
}
+ errno = 0;
}
static FILE* create_fopen(char* name, char* mode, int subdirs)
free (dir_name);
}
}
- return fopen(name, mode);
+ return fopen(name, mode);
}
static int unzzip_cat (int argc, char ** argv, int extract)
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
if (! out) {
- done = EXIT_ERRORS;
+ DBG3("fopen' %s : %s", name, strerror(errno));
+ if (errno != EISDIR) done = EXIT_ERRORS;
continue;
}
unzzip_cat_file (disk, name, out);
FILE* out = stdout;
if (extract) out = create_fopen(name, "w", 1);
if (! out) {
- done = EXIT_ERRORS;
+ DBG3("fopen. %s : %s", name, strerror(errno));
+ if (errno != EISDIR) done = EXIT_ERRORS;
continue;
}
unzzip_cat_file (disk, name, out);
def test_20595_zzextract_zap_test5_zip(self):
""" run zzextract-zap on test5.zip
=> coughs up a SEGFAULT in zzip_dir_close() ?!?"""
+ self.rm_testdir()
zipfile = "test5.zip"
getfile = "test5.zip"
tmpdir = self.testdir()
exe = self.bins("unzzip")
- run = shell("cd {tmpdir} && ../{exe} ../{getfile} ".format(**locals()))
+ run = shell("cd {tmpdir} && ../{exe} ../{getfile} ".format(**locals()));
self.assertTrue(tmpdir+'/subdir1/subdir2/file3-1024.txt')
- self.rm_testdir()
+ # self.rm_testdir()
url_CVE_2017_5977 = "https://github.com/asarubbo/poc/blob/master"
zip_CVE_2017_5977 = "00153-zziplib-invalidread-zzip_mem_entry_extra_block"