Re: [PATCH] dmsetup: fix sscanf return check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/08/12 21:27, Alasdair G Kergon wrote:
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?

No. My git-fu isn't good enough to point that out in the email without cluttering the commit message with it, but I pointed it out on IRC.

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.

Thanks for being thorough. I've now made another entry in my mental list of surprising interfaces :)

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/


[Index of Archives]     [Gluster Users]     [Kernel Development]     [Linux Clusters]     [Device Mapper]     [Security]     [Bugtraq]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]

  Powered by Linux