]> granicus.if.org Git - php/commitdiff
- Improve error message and added check for fstat return
authorFelipe Pena <felipensp@gmail.com>
Tue, 12 Nov 2013 00:33:17 +0000 (22:33 -0200)
committerFelipe Pena <felipensp@gmail.com>
Tue, 12 Nov 2013 00:33:17 +0000 (22:33 -0200)
phpdbg_list.c

index 9102a797fc6703466c2a547780026e6e9f4e556e..d4603155312025593f666f12f23ffa3fa83ba645 100644 (file)
@@ -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);
-
 } /* }}} */