From: Dirk Tilger <dirk@systemication.com>
To: drbd-dev@lists.linbit.com
Subject: [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256
Date: Sun, 16 Nov 2014 18:35:43 +0400 [thread overview]
Message-ID: <20141116143543.GA26665@miriup.de> (raw)
fscanf line probably copied from kernel printf, but printf specifies the
minimal field widwth and scanf the maximal field width.
printf (3) manual:
> Each conversion specification is introduced by the character %, and ends with
> a conversion specifier. In between there may be (in this order) zero or more
> flags, an optional minimum field width, an optional precision and an optional
> length modifier.
fscanf manual:
> Each conversion specification in format begins with either the character '%'
> or the character sequence "%n$" (see below for the distinction) followed by:
>
> * An optional '*' assignment-suppression character: scanf() reads input as
> directed by the conversion specification, but discards the input. No
> corresponding pointer argument is required, and this specification is not
> included in the count of successful assignments returned by scanf().
[...]
> * An optional decimal integer which specifies the maximum field width.
> Reading of characters stops either when this maximum is reached or when a
> nonmatching character is found, whichever happens first. Most conversions
> discard initial white space characters (the exceptions are noted below),
> and these discarded characters don't count toward the maximum field width.
> String input conversions store a terminating null byte ('\0') to mark the
> end of the input; the maximum field width does not include this terminator.
---
user/shared/shared_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/user/shared/shared_main.c b/user/shared/shared_main.c
index 8dec945..44a3d54 100644
--- a/user/shared/shared_main.c
+++ b/user/shared/shared_main.c
@@ -186,7 +186,7 @@ int have_ip_ipv6(const char *ip)
while (fscanf
(if_inet6,
- X32(08) X32(08) X32(08) X32(08) " %*02x %*02x %*02x %*02x %s",
+ X32(08) X32(08) X32(08) X32(08) " %*x %*x %*x %*x %s",
b, b + 1, b + 2, b + 3, name) > 0) {
for (i = 0; i < 4; i++)
addr6.s6_addr32[i] = cpu_to_be32(b[i]);
--
1.9.1
next reply other threads:[~2014-11-16 14:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-16 14:35 Dirk Tilger [this message]
2014-11-17 12:28 ` [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256 Roland Kammerer
2014-11-17 14:14 ` Roland Kammerer
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=20141116143543.GA26665@miriup.de \
--to=dirk@systemication.com \
--cc=drbd-dev@lists.linbit.com \
/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