This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/15301] New: scanf family misbehaves on %m when zero characters are read


http://sourceware.org/bugzilla/show_bug.cgi?id=15301

             Bug #: 15301
           Summary: scanf family misbehaves on %m when zero characters are
                    read
           Product: glibc
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
        AssignedTo: unassigned@sourceware.org
        ReportedBy: repentinus@fsfe.org
    Classification: Unclassified


Demonstration at <http://ideone.com/1l4qWb> (11 lines). After the sscanf call b
should point to otherwise empty null-terminated string (e.g., ""). However, as
can be seen from the example, b becomes a null pointer.

The POSIX specification states: "The %c , %s , and %[ conversion specifiers
shall accept an optional assignment-allocation character 'm' , which shall
cause a memory buffer to be allocated to hold the string converted including a
terminating null character. [â] The system shall allocate a buffer as if
malloc() had been called. [â] If there is insufficient memory to allocate a
buffer, the function shall set errno to [ENOMEM] and a conversion error shall
result. If the function returns EOF, any memory successfully allocated for
parameters using assignment-allocation character 'm' by this call shall be
freed before the function returns."
<http://pubs.opengroup.org/onlinepubs/9699919799/>

In the example case there is neither insufficient memory nor is EOF returned.
Thus, b should point to "", and should not be null.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]