[linux-lvm] [PATCH] dmsetup: fix sscanf return check
Alasdair G Kergon
agk at redhat.com
Thu Aug 23 20:27:38 UTC 2012
On Thu, Aug 23, 2012 at 02:31:02PM +0100, Matthew Booth wrote:
> - if (sscanf(ptr, "%llu %llu %s %n",
> - &start, &size, ttype, &n) < 3) {
> + if (sscanf(ptr, "%llu %llu %s %n", &start, &size, ttype, &n) != 4) {
Did you test this?
According to the sscanf man page:
n Nothing is expected; instead, the number of characters consumed
thus far from the input is stored through the next pointer,
which must be a pointer to int. This is not a conversion,
although it can be suppressed with the * assignment-suppression
character. The C standard says: "Execution of a %n directive
does not increment the assignment count returned at the comple-
tion of execution" but the Corrigendum seems to contradict this.
Probably it is wise not to make any assumptions on the effect of
%n conversions on the return value.
Alasdair
More information about the linux-lvm
mailing list