This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: Debug mode output broken


Jonathan Wakely wrote:

First of all, please note that __n is not the buffer size here, it's the
length of the word to be copied. snprintf() is not used to prevent __buf
from being overflowed, it's used to prevent the whole of __s being copied.


Please have a look to the whole debug.cc: most of the times, according to a very
common practice, snprintf is passed exactly __bufsize.


There is only *one* case, _M_print_string, where the second parameter of snprintf
is used for the other purpose that you are emphasizing above.


That's why we have a bug: someone replaced snprintf (when not available) with
sprintf considering only the former uses of _M_format_word. We have to deal
correctly with the exception represented by _M_print_string.


Paolo.


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