From 7ba8414262c777bb277ef04bf36b11e9b5d8be58 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Tue, 8 Sep 2015 15:58:41 +1000 Subject: Fix possible passing of -1 to write() in extract-gcov.c Just print an error and exit() instead Signed-off-by: Stewart Smith --- extract-gcov.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'extract-gcov.c') diff --git a/extract-gcov.c b/extract-gcov.c index 75c1108..c9b82f3 100644 --- a/extract-gcov.c +++ b/extract-gcov.c @@ -128,6 +128,11 @@ static void write_gcda(char *addr, struct gcov_info* gi) printf("Writing %s\n", filename); fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); + if (fd < 0) { + fprintf(stderr, "Error opening file %s: %d %s\n", + filename, errno, strerror(errno)); + exit(EXIT_FAILURE); + } write_u32(fd, GCOV_DATA_MAGIC); write_u32(fd, be32toh(gi->version)); write_u32(fd, be32toh(gi->stamp)); -- cgit v1.1