com php-src: - Improve error message and added check for fstat return: phpdbg_list.c
| From: | Bob Weinand | Date: | Tue, 12 Nov 2013 00:33:17 +0000 |
| Subject: | com php-src: - Improve error message and added check for fstat return: phpdbg_list.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75119@lists.php.net to get a copy of this message | ||
Commit: 217c906ea57fecdf78469048bb1384c0e1ff2a19
Author: Felipe Pena <felipensp@gmail.com> Mon, 11 Nov 2013 22:33:17 -0200
Parents: bbc35b60f9564d556f1c0c154f69108201b4913c
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=217c906ea57fecdf78469048bb1384c0e1ff2a19
Log:
- Improve error message and added check for fstat return
Changed paths:
M phpdbg_list.c
Diff:
diff --git a/phpdbg_list.c b/phpdbg_list.c
index 9102a79..d460315 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);
-
} /* }}} */