WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
185496
Fix some -Wstring-op-truncation warnings
https://bugs.webkit.org/show_bug.cgi?id=185496
Summary
Fix some -Wstring-op-truncation warnings
Michael Catanzaro
Reported
2018-05-09 16:39:55 PDT
testAtomicStringNumber may not be null-terminated. Caught by -Wstringop-truncation: ../../Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp:67:17: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 100 equals destination size [-Wstringop-truncation]
Attachments
Patch
(4.49 KB, patch)
2018-05-09 20:02 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Michael Catanzaro
Comment 1
2018-05-09 16:52:09 PDT
Also, related: [415/2047] Building CXX object Tools/TestWebKitAPI/CMakeFiles/TestWTF.dir/Tests/WTF/WTFString.cpp.o ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp: In function ‘const char* TestWebKitAPI::testStringNumber(double)’: ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:169:17: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 100 equals destination size [-Wstringop-truncation] std::strncpy(testBuffer, String::numberToStringECMAScript(number).utf8().data(), 100); ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:169:17: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 100 equals destination size [-Wstringop-truncation] ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp: In function ‘const char* TestWebKitAPI::testStringNumberFixedWidth(double)’: ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:120:17: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 100 equals destination size [-Wstringop-truncation] std::strncpy(testBuffer, String::numberToStringFixedWidth(number, 6).utf8().data(), 100); ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:120:17: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 100 equals destination size [-Wstringop-truncation] ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp: In function ‘const char* TestWebKitAPI::testStringNumberFixedPrecision(double)’: ../../Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:71:17: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 100 equals destination size [-Wstringop-truncation] std::strncpy(testBuffer, String::number(number).utf8().data(), 100); ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael Catanzaro
Comment 2
2018-05-09 20:02:16 PDT
Created
attachment 340064
[details]
Patch
WebKit Commit Bot
Comment 3
2018-05-10 14:46:57 PDT
Comment on
attachment 340064
[details]
Patch Clearing flags on attachment: 340064 Committed
r231661
: <
https://trac.webkit.org/changeset/231661
>
WebKit Commit Bot
Comment 4
2018-05-10 14:46:58 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 5
2018-05-10 14:47:41 PDT
<
rdar://problem/40142604
>
Darin Adler
Comment 6
2018-05-12 21:41:56 PDT
Thanks for fixing this. For the record, changing the 100 to 99 was necessary, but adding the "= { }" was not since these are globals and initialized to zero in any case.
Michael Catanzaro
Comment 7
2018-05-13 07:32:59 PDT
(In reply to Darin Adler from
comment #6
)
> Thanks for fixing this. For the record, changing the 100 to 99 was > necessary, but adding the "= { }" was not since these are globals and > initialized to zero in any case.
Good point, you're right! I overlooked the static keyword.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug