From 217c906ea57fecdf78469048bb1384c0e1ff2a19 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 11 Nov 2013 22:33:17 -0200 Subject: [PATCH] - Improve error message and added check for fstat return --- phpdbg_list.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); - } /* }}} */ -- 2.50.1