[PATCH 3/4] erec: Handle returned value properly in erec_print

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@xxxxxxxxxxxxxxx>
---
 src/erec.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/erec.c b/src/erec.c
index 501bf4b..554a406 100644
--- a/src/erec.c
+++ b/src/erec.c
@@ -78,7 +78,7 @@ void erec_print(FILE *f, const struct error_record *erec)
 	const char *line = NULL; /* silence gcc */
 	char buf[1024];
 	unsigned int i, end;
-	int l;
+	int l, ret;
 
 	switch (indesc->type) {
 	case INDESC_BUFFER:
@@ -88,8 +88,9 @@ void erec_print(FILE *f, const struct error_record *erec)
 	case INDESC_FILE:
 		memset(buf, 0, sizeof(buf));
 		lseek(indesc->fd, loc->line_offset, SEEK_SET);
-		read(indesc->fd, buf, sizeof(buf) - 1);
-		*strchrnul(buf, '\n') = '\0';
+		ret = read(indesc->fd, buf, sizeof(buf) - 1);
+		if (ret > 0)
+			*strchrnul(buf, '\n') = '\0';
 		line = buf;
 		break;
 	case INDESC_INTERNAL:
-- 
1.7.8.6

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux