* [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256
@ 2014-11-16 14:35 Dirk Tilger
2014-11-17 12:28 ` Roland Kammerer
0 siblings, 1 reply; 3+ messages in thread
From: Dirk Tilger @ 2014-11-16 14:35 UTC (permalink / raw)
To: drbd-dev
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256
2014-11-16 14:35 [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256 Dirk Tilger
@ 2014-11-17 12:28 ` Roland Kammerer
2014-11-17 14:14 ` Roland Kammerer
0 siblings, 1 reply; 3+ messages in thread
From: Roland Kammerer @ 2014-11-17 12:28 UTC (permalink / raw)
To: drbd-dev
On Sun, Nov 16, 2014 at 06:35:43PM +0400, Dirk Tilger wrote:
> - 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",
Are numbers larger than 0xff even possible?
We read the string from "/proc/net/if_inet6", and to me it looks like
the interfaces limits the input range to values <= 255 [1].
Would be great if you could provide an example where it really makes a
difference, i.e. how to get lager values than 255 in the ignored format
string positions.
Regards, rck
[1] http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/proc-net.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256
2014-11-17 12:28 ` Roland Kammerer
@ 2014-11-17 14:14 ` Roland Kammerer
0 siblings, 0 replies; 3+ messages in thread
From: Roland Kammerer @ 2014-11-17 14:14 UTC (permalink / raw)
To: drbd-dev
On Mon, Nov 17, 2014 at 01:28:36PM +0100, Roland Kammerer wrote:
> On Sun, Nov 16, 2014 at 06:35:43PM +0400, Dirk Tilger wrote:
> > - 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",
>
> Are numbers larger than 0xff even possible?
>
Yes, it is possible...
Thank you Dirk for the hint and the patch. Applied to our internal repo.
Regards, rck
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-17 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-16 14:35 [Drbd-dev] [PATCH] Correctly skip interface indexes larger than 256 Dirk Tilger
2014-11-17 12:28 ` Roland Kammerer
2014-11-17 14:14 ` Roland Kammerer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox