netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: netfilter-devel@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [PATCH 3/4] erec: Handle returned value properly in erec_print
Date: Thu,  2 Aug 2012 13:31:34 +0300	[thread overview]
Message-ID: <1343903495-14486-4-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
In-Reply-To: <1343903495-14486-1-git-send-email-tomasz.bursztyka@linux.intel.com>

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
 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


  parent reply	other threads:[~2012-08-02 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 10:31 [PATCH 0/4] [nftables] Various compilation error fixes Tomasz Bursztyka
2012-08-02 10:31 ` [PATCH 1/4] netlink: Use the right datatype for verdict Tomasz Bursztyka
2012-08-02 10:31 ` [PATCH 2/4] evaluate: Remove useless variable in expr_evaluate_bitwise() Tomasz Bursztyka
2012-08-02 10:31 ` Tomasz Bursztyka [this message]
2012-08-02 10:31 ` [PATCH 4/4] expression: Differentiate expr among anonymous structures in struct expr Tomasz Bursztyka
2012-08-06 12:44 ` [PATCH 0/4] [nftables] Various compilation error fixes Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343903495-14486-4-git-send-email-tomasz.bursztyka@linux.intel.com \
    --to=tomasz.bursztyka@linux.intel.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).