From: Felipe Pena Date: Tue, 12 Nov 2013 00:33:17 +0000 (-0200) Subject: - Improve error message and added check for fstat return X-Git-Tag: php-5.6.0alpha1~110^2~459^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=217c906ea57fecdf78469048bb1384c0e1ff2a19;p=php - Improve error message and added check for fstat return --- diff --git a/phpdbg_list.c b/phpdbg_list.c index 9102a797fc..d460315531 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -33,11 +33,14 @@ void phpdbg_list_file(const char *filename, long count, long offset) /* {{{ */ unsigned int line = 0, displayed = 0; if ((fd = open(filename, O_RDONLY)) == -1) { - printf("[Failed to open file to list]\n"); + printf("[Failed to open file %s to list]\n", filename); return; } - fstat(fd, &st); + if (fstat(fd, &st) == -1) { + printf("[Failed to stat file %s]\n", filename); + goto out; + } last_pos = mem = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); end_pos = mem + st.st_size; @@ -67,6 +70,6 @@ void phpdbg_list_file(const char *filename, long count, long offset) /* {{{ */ } munmap(mem, st.st_size); +out: close(fd); - } /* }}} */