[prev in list] [next in list] [prev in thread] [next in thread]
List: libftdi
Subject: [PATCH] ftdi_eeprom crash if output file cannot be opened
From: Thilo Schulz <thilo () tjps ! eu>
Date: 2015-10-10 11:09:59
Message-ID: 3507541.14MHjDHqbk () helmuth
[Download RAW message or body]
Hi everybody,
Subject says it all. Find patch attached to this email.
--
Best regards,
Thilo Schulz
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@developer.intra2net.com
["0001-Fix-segfault-crash-if-output-file-cannot-be-opened.patch" (0001-Fix-segfault-crash-if-output-file-cannot-be-opened.patch)]
From d426de6070ba4fcbcf800547ff1d8b9002daca22 Mon Sep 17 00:00:00 2001
From: Thilo Schulz <thilo@tjps.eu>
Date: Sat, 10 Oct 2015 13:06:04 +0200
Subject: [PATCH] Fix segfault crash if output file cannot be opened
---
ftdi_eeprom/main.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c
index edcfad7..0d75c24 100644
--- a/ftdi_eeprom/main.c
+++ b/ftdi_eeprom/main.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <confuse.h>
#include <libusb.h>
@@ -395,10 +396,15 @@ int main(int argc, char *argv[])
}
if (filename != NULL && strlen(filename) > 0)
{
-
FILE *fp = fopen (filename, "wb");
- fwrite (eeprom_buf, 1, my_eeprom_size, fp);
- fclose (fp);
+
+ if(fp)
+ {
+ fwrite(eeprom_buf, 1, my_eeprom_size, fp);
+ fclose(fp);
+ }
+ else
+ fprintf(stderr, "Could not open output file %s: %s\n", filename, strerror(errno));
}
else
{
--
2.1.4
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic