bin/xbps-checkvers/main.c: use-after-free (CID 62743)

This commit is contained in:
Juan RP 2014-10-05 10:06:42 +02:00
parent 14da590f41
commit fe80347a32

View File

@ -571,7 +571,7 @@ rcv_check_version(rcv_t *rcv)
static int static int
rcv_process_dir(rcv_t *rcv, const char *path, rcv_proc_func process) rcv_process_dir(rcv_t *rcv, const char *path, rcv_proc_func process)
{ {
DIR *dir; DIR *dir = NULL;
struct dirent entry, *result; struct dirent entry, *result;
struct stat st; struct stat st;
char filename[BUFSIZ]; char filename[BUFSIZ];
@ -579,7 +579,7 @@ rcv_process_dir(rcv_t *rcv, const char *path, rcv_proc_func process)
dir = opendir(path); dir = opendir(path);
error: error:
if (errors > 0) { if (errors > 0 || !dir) {
fprintf(stderr, "Error: while processing dir '%s': %s\n", path, fprintf(stderr, "Error: while processing dir '%s': %s\n", path,
strerror(errors)); strerror(errors));
exit(1); exit(1);
@ -619,10 +619,12 @@ error:
if ((closedir(dir)) == -1) { if ((closedir(dir)) == -1) {
errors = errno; errors = errno;
dir = NULL;
goto error; goto error;
} }
if ((chdir("..")) == -1) { if ((chdir("..")) == -1) {
errors = errno; errors = errno;
dir = NULL;
goto error; goto error;
} }