RESOLVED FIXED 41553
Make StringExtras.h versions of snprintf and vsnprintf match the unix versions
https://bugs.webkit.org/show_bug.cgi?id=41553
Summary Make StringExtras.h versions of snprintf and vsnprintf match the unix versions
Sam Weinig
Reported 2010-07-02 17:48:00 PDT
Make StringExtras.h versions of snprintf and vsnprintf match the unix versions. MSVC does not ensure the buffers are null terminated as the unix versions do.
Attachments
Patch (3.80 KB, patch)
2010-07-02 17:50 PDT, Sam Weinig
no flags
Updated patch (4.14 KB, patch)
2010-07-02 18:05 PDT, Sam Weinig
no flags
Patch 3 (4.10 KB, patch)
2010-07-03 14:14 PDT, Sam Weinig
darin: review+
Sam Weinig
Comment 1 2010-07-02 17:50:45 PDT
Darin Adler
Comment 2 2010-07-02 17:53:39 PDT
Comment on attachment 60424 [details] Patch > + // In the case where the string entirely filled the buffer, _vsnprintf will not > + // null-terminate it, but vsnprintf must. > + if (count > 0) > + buffer[count - 1] = '\0'; But what about the case where Windows *does* have vsnprintf, but it has the wrong behavior and does not terminate the buffer with a nul character? As I understand it, this is the case with MSVC 8 and newer!
Sam Weinig
Comment 3 2010-07-02 18:05:24 PDT
Created attachment 60426 [details] Updated patch
WebKit Review Bot
Comment 4 2010-07-02 18:06:41 PDT
Attachment 60426 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1 JavaScriptCore/wtf/StringExtras.h:56: wtf_vsnprintf is incorrectly named. Don't use underscores in your identifier names. [readability/naming] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 5 2010-07-03 03:16:38 PDT
Darin Adler
Comment 6 2010-07-03 10:05:17 PDT
Comment on attachment 60426 [details] Updated patch > +// Work around a bug in Microsoft's implementation of vsnprintf, where > +// vsnprintf does not null terminate the buffer > +#define vsnprintf(x, y) wtf_vsnprintf(x, y) vsnprintf has 4 arguments, not 2, which is presumably why the bot is failing to build
Sam Weinig
Comment 7 2010-07-03 14:14:28 PDT
Created attachment 60457 [details] Patch 3
WebKit Review Bot
Comment 8 2010-07-03 14:17:29 PDT
Attachment 60457 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1 JavaScriptCore/wtf/StringExtras.h:56: wtf_vsnprintf is incorrectly named. Don't use underscores in your identifier names. [readability/naming] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Sam Weinig
Comment 9 2010-07-03 17:11:53 PDT
Landed in r62457.
Note You need to log in before you can comment on or make changes to this bug.