Bug 185496

Summary: Fix some -Wstring-op-truncation warnings
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: Tools / TestsAssignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, commit-queue, darin, lforschler, mcatanzaro, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch none

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
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
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
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.