[PATCH] wpa_debug: Remove 2048 byte message length limit

Anders Kaseorg andersk
Wed Feb 19 04:09:48 PST 2014


On Wed, 19 Feb 2014, Jouni Malinen wrote:
> How portable is this? SUSv2 seems to imply that n==0 would result in 
> undefined behavior, so this may not work without being compliant with 
> C99. There are some strange targets that wpa_supplicant is used on, so 
> I'm not sure whether there would be enough justification for this change 
> if there is risk of breaking debugging on such platforms.

This was corrected in SUSv3.  According to the Autoconf manual,

https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Function-Portability.html#index-g_t_0040code_007bsnprintf_007d-357

?The C99 standard says that if the output array isn't big enough and if no 
other errors occur, snprintf and vsnprintf truncate the output and return 
the number of bytes that ought to have been produced. Some older systems 
return the truncated length (e.g., GNU C Library 2.0.x or IRIX 6.5), some 
a negative value (e.g., earlier GNU C Library versions), and some the 
buffer length without truncation (e.g., 32-bit Solaris 7). Also, some 
buggy older systems ignore the length and overrun the buffer (e.g., 64-bit 
Solaris 7).?

glibc 2.0.x and Solaris 7 have been obsolete for at least 14 years, and I 
can?t find any evidence of wpa_supplicant being used on IRIX, but you 
would know better than me.  If any of these platforms are a concern, we 
could work around these problems by checking for potential truncation and 
redoubling the buffer length until there?s enough space?  (Except 64-bit 
Solaris 7, which just sounds completely hopeless.)

Keep in mind that snprintf isn?t even part of C89 at all, so we have to 
draw a line somewhere.

Anders



More information about the Hostap mailing list