Add error handling to fputs()/fgets() functions.
Signed-off-by: Stanislaw Wadas <[email protected]>
---
src/usbg.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/usbg.c b/src/usbg.c
index 198b504..c673be9 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -93,6 +93,11 @@ static char *usbg_read_buf(char *path, char *name, char
*file, char *buf)
goto out;
ret = fgets(buf, USBG_MAX_STR_LENGTH, fp);
+ if (ret == NULL) {
+ ERROR("read error");
+ fclose(fp);
+ return ret;
+ }
fclose(fp);
@@ -136,7 +141,11 @@ static void usbg_write_buf(char *path, char *name, char
*file, char *buf)
return;
}
- fputs(buf, fp);
+ if (fputs(buf, fp) == EOF) {
+ ERROR("write error");
+ fclose(fp);
+ return;
+ }
fclose(fp);
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html