avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] [bug #22593] vfscanf improperly scans string parameters w


From: brent sirna
Subject: [avr-libc-dev] [bug #22593] vfscanf improperly scans string parameters with a width option by 1 character
Date: Fri, 14 Mar 2008 17:58:01 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12

URL:
  <http://savannah.nongnu.org/bugs/?22593>

                 Summary: vfscanf improperly scans string parameters with a
width option by 1 character
                 Project: AVR C Runtime Library
            Submitted by: bsirna
            Submitted on: Friday 03/14/2008 at 17:58
                Category: Library
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

The following code illustrates the bug.

    char
        s1[5],
        s2[5];

    int
        result;

    s1[0] = 0;
    s2[0] = 0;
    result = sscanf_P( ",ABCD,EFGH,", PSTR( ",%4s,%4s," ), &s1, &s2 );
    printf_P( PSTR( "%d %s %s\r\n" ), result, s1, s2 );

    s1[0] = 0;
    s2[0] = 0;
    result = sscanf_P( ",ABCD,EFGH,", PSTR( ",%3s,%3s," ), &s1, &s2 );
    printf_P( PSTR( "%d %s %s\r\n" ), result, s1, s2 );

results from executing this code.

1 ABCD 
2 ABC EFG

Had a quick look at the code and I believe the problem is that when the loop
is exited in the case statement for the 's' one extra character has been
removed from the stream;

Best regards

Brent






    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?22593>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]