[Bug other/37080] New: vasprintf in libiberty fails for %llu on solaris
mark at easterbrook dot org dot uk
gcc-bugzilla@gcc.gnu.org
Mon Aug 11 14:58:00 GMT 2008
vasprintf(buffer, "%llu %s", ...)
The code is:
while (strchr ("hlL", *p))
++p;
/* Should be big enough for any format specifier except %s and
floats. */
total_width += 30;
switch (*p)
{
case 'd':
case 'i':
case 'o':
case 'u':
case 'x':
case 'X':
case 'c':
(void) va_arg (ap, int);
break;
It is ignoring the ll and processing the long long argument as an int.
Unfortunately this leaves the va-list pointer in the wrong place (4 bytes out I
think). The next argument is %s, so it takes the next thing, treats it as a
pointer, and strlen() it, but this is an invalid pointer (it is really the
second part of the long long) so it seg faults.
The above code needs to count l prefixes and use va_arg(ap, long) or va_arg(ap,
long long) as appropriate.
(The h is safe as a short will be promoted to int in the variable arg list,
just the l prefix needs fixing).
--
Summary: vasprintf in libiberty fails for %llu on solaris
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mark at easterbrook dot org dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37080
More information about the Gcc-bugs
mailing list