[Bug 1829980] [NEW] sscanf %02x and "0x" behaviour
Zibri Soft
1829980 at bugs.launchpad.net
Wed May 22 07:17:51 UTC 2019
Public bug reported:
I wrote this routine to convert a hex string to binary:
https://gist.github.com/Zibri/992b38baa520eb478ef7fa15fd950a7a/raw/2ea3634b31d6c90d74dc2a987a3dfe3b57e6fbcc/hex2bin_by_zibri.c
The routine works nicely but I noticed one thing:
sscanf("%02x",&char)
accepts:
1
02
Aa
aA
but it also accepts
0x which it translates to 00
There's no real harm in that, but I think that should be corrected.
In a loop if the input string (check my routine) is
"0x 0x 12 34 0x 1x 12 34"
The routine translates
00 00 12 34 00
Because for sscanf 0x is not an error but 1x is.
IMHO they should both be treated the same way in "%x"...
Regards,
Zibri
** Affects: glibc (Ubuntu)
Importance: Undecided
Status: New
** Tags: input sscanf unintended
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/1829980
Title:
sscanf %02x and "0x" behaviour
Status in glibc package in Ubuntu:
New
Bug description:
I wrote this routine to convert a hex string to binary:
https://gist.github.com/Zibri/992b38baa520eb478ef7fa15fd950a7a/raw/2ea3634b31d6c90d74dc2a987a3dfe3b57e6fbcc/hex2bin_by_zibri.c
The routine works nicely but I noticed one thing:
sscanf("%02x",&char)
accepts:
1
02
Aa
aA
but it also accepts
0x which it translates to 00
There's no real harm in that, but I think that should be corrected.
In a loop if the input string (check my routine) is
"0x 0x 12 34 0x 1x 12 34"
The routine translates
00 00 12 34 00
Because for sscanf 0x is not an error but 1x is.
IMHO they should both be treated the same way in "%x"...
Regards,
Zibri
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1829980/+subscriptions
More information about the foundations-bugs
mailing list