summaryrefslogtreecommitdiffstats
path: root/src/erec.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2012-08-02 00:31:34 +0000
committerPablo Neira Ayuso <pablo@netfilter.org>2012-08-03 11:37:46 +0200
commit1f9ce119666902e92619ee648395fed3147d18a3 (patch)
treeabe8d00d2126444586a7efce03f823f62f53ee4d /src/erec.c
parente9f8729a93e0145d59bc7487a0045c519f764ffd (diff)
erec: Handle returned value properly in erec_print
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/erec.c')
-rw-r--r--src/erec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/erec.c b/src/erec.c
index 501bf4b6..554a406c 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: