Skip to content

Commit

Permalink
parse: fix uninitialized pointer access
Browse files Browse the repository at this point in the history
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
  • Loading branch information
2xsec committed Oct 10, 2018
1 parent 8392708 commit af5e7ee
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lxc/parse.c
Expand Up @@ -81,12 +81,12 @@ int lxc_file_for_each_line_mmap(const char *file, lxc_file_cb callback, void *da
ret = fstat(fd, &st);
if (ret < 0) {
SYSERROR("Failed to stat config file \"%s\"", file);
goto on_error;
goto on_error_fstat;
}

ret = 0;
if (st.st_size == 0)
goto on_error;
goto on_error_fstat;

ret = -1;
buf = lxc_strmmap(NULL, st.st_size, PROT_READ | PROT_WRITE,
Expand Down Expand Up @@ -117,6 +117,7 @@ int lxc_file_for_each_line_mmap(const char *file, lxc_file_cb callback, void *da
ret = -1;
}

on_error_fstat:
saved_errno = errno;
close(fd);
errno = saved_errno;
Expand Down

0 comments on commit af5e7ee

Please sign in to comment.