Re: [PATCH] Add compat/vsnprintf.c for systems that returns -1 on maxsize reached

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

 



Finn Arne Gangstad schrieb:
> On Tue, Mar 04, 2008 at 02:59:28PM +0100, Michal Rokos wrote:
> 
>> +	while ( ret == -1 )
>> +	{
>> +		maxsize = (maxsize*3)/2;
>> +		s = realloc(s, maxsize);
>> +		if (! s) return -1;
>> +		ret = vsnprintf(s, maxsize, format, ap);  /* <--- UNSAFE! */
>> +	}
> 
> This is not generally safe, you cannot call vsnprintf multiple times
> with the same ap on all architectures. You need va_copy (or __va_copy,
> or VA_COPY, differs a bit between different architectures, especially
> one the ones with a broken vsnprintf I guess..)

True. But...

This replacement of vsnprintf will not be needed on all architectures, but
only on some. And on these we can test in advance whether we can get away
without va_copy (et.al.). A note next to the configuration setting about
this would be in order, I think.

Furthermore, on systems where vsnprintf is broken in this way, va_copy is
likely not available.

-- Hannes

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux