From: Andreas Henriksson <andreas@fatal.se>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org, Andreas Henriksson <andreas@fatal.se>
Subject: [PATCH iproute2 v2 2/2] arpd: fix parsing of unlikely long comments
Date: Sun, 3 Jan 2016 19:39:33 +0100 [thread overview]
Message-ID: <1451846374-2665-2-git-send-email-andreas@fatal.se> (raw)
In-Reply-To: <1451846374-2665-1-git-send-email-andreas@fatal.se>
In case the commented out line was longer than the buffer size,
the remaining part was previously not properly skipped.
With this fix we should now continue ignoring lines starting with #
until we find a newline character.
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
misc/arpd.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/misc/arpd.c b/misc/arpd.c
index 700dc50..a4f0f0d 100644
--- a/misc/arpd.c
+++ b/misc/arpd.c
@@ -691,6 +691,7 @@ int main(int argc, char **argv)
FILE *fp;
struct dbkey k;
DBT dbkey, dbdat;
+ int skip_until_eol = 0;
dbkey.data = &k;
dbkey.size = sizeof(k);
@@ -707,8 +708,19 @@ int main(int argc, char **argv)
char ipbuf[128];
char macbuf[128];
- if (buf[0] == '#')
+ /* skip remaining part of commented outline. */
+ if (skip_until_eol) {
+ if (strrchr(buf, '\n') != NULL)
+ skip_until_eol = 0;
continue;
+ }
+
+ /* skip (beginning of) commented out line. */
+ if (buf[0] == '#') {
+ if (strrchr(buf, '\n') == NULL)
+ skip_until_eol = 1;
+ continue;
+ }
if (sscanf(buf, "%u%s%s", &k.iface, ipbuf, macbuf) != 3) {
fprintf(stderr, "Wrong format of input file \"%s\"\n", do_load);
--
2.1.4
next prev parent reply other threads:[~2016-01-03 18:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-03 16:09 [PATCH iproute2] arpd: drop unnecessary explicit null termination Andreas Henriksson
2016-01-03 17:04 ` Stephen Hemminger
2016-01-03 18:39 ` [PATCH iproute2 v2 1/2] " Andreas Henriksson
2016-01-03 18:39 ` Andreas Henriksson [this message]
2016-01-03 18:44 ` [PATCH iproute2 v2 2/2] arpd: fix parsing of unlikely long comments Andreas Henriksson
2016-01-03 23:04 ` Stephen Hemminger
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=1451846374-2665-2-git-send-email-andreas@fatal.se \
--to=andreas@fatal.se \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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).