Replace PL_strcpy/PL_strncpy with a safer Gecko string class or function
Categories
(Core :: XPCOM, defect, P5)
Tracking
()
Tracking | Status | |
---|---|---|
firefox83 | --- | fixed |
People
(Reporter: cpeterson, Assigned: smurfd)
References
(Blocks 1 open bug)
Details
(Whiteboard: [lang=c++][ele:1b])
Attachments
(1 file)
Reporter | ||
Comment 1•9 years ago
|
||
Reporter | ||
Comment 3•8 years ago
|
||
Updated•6 years ago
|
Reporter | ||
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
Hey, I will take this, it looks fairly straight forward.
These 3 calls(or is it just the 1 call from dom/media ?) have data in them, so they should not be Nullptrs in or out, so simply remove PL_ should be ok.
Is it the same here, that dom/plugins/base/nsPluginHost.cpp code will also go away soon?
dom/media/webrtc/RTCCertificate.cpp is there a webrtc reviewer group?
Assignee | ||
Updated•5 years ago
|
Reporter | ||
Comment 5•5 years ago
|
||
(In reply to Nicklas Boman [:smurfd] from comment #4)
Hey, I will take this, it looks fairly straight forward.
Thanks!
(In reply to Nicklas Boman [:smurfd] from comment #4)
Is it the same here, that dom/plugins/base/nsPluginHost.cpp code will also go away soon?
Yes. No need to bother updating dom/plugins/base/nsPluginHost.cpp. :)
dom/media/webrtc/RTCCertificate.cpp is there a webrtc reviewer group?
I don't see a webrtc or media group. For future reference, here is a list of all the Phabricator reviewer groups:
https://phabricator.services.mozilla.com/project/query/all/
Checking the Mozilla module owner wiki, looks like Randell Jesup is the WebRTC module owner, so just send your review request to r?jesup
:
Assignee | ||
Comment 6•5 years ago
|
||
Comment 8•5 years ago
|
||
Backed out changeset 3895daa47180 (bug 1308101) for linux hazard bustages.
https://hg.mozilla.org/integration/autoland/rev/d646a7e2621160609635b056871e2c0a6799eea7
Failure log:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=315798299&repo=autoland&lineNumber=14918
Assignee | ||
Comment 9•5 years ago
|
||
Looks like i need to add a :
buf[2] = '\0';
Reporter | ||
Comment 10•5 years ago
|
||
Failure log:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=315798299&repo=autoland&lineNumber=14918
[task 2020-09-16T00:56:59.583Z] 15:34.07 In function 'char* strncpy(char*, const char*, size_t)',
[task 2020-09-16T00:56:59.583Z] 15:34.07 inlined from 'static CERTName* mozilla::dom::GenerateRTCCertificateTask::GenerateRandomName(PK11SlotInfo*)' at /builds/worker/checkouts/gecko/dom/media/webrtc/RTCCertificate.cpp:75:12:
[task 2020-09-16T00:56:59.583Z] 15:34.07 /usr/include/x86_64-linux-gnu/bits/string3.h:120:34: error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation]
[task 2020-09-16T00:56:59.583Z] 15:34.07 120 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
(In reply to Nicklas Boman [:smurfd] from comment #9)
Looks like i need to add a :
buf[2] = '\0';
Looks like gcc is complaining about the source buffer, not the destination buf
. It doesn't like that PL_strncpy(buf, "CN=", 3);
is not copying the NUL terminator of the "CN=" string literal. Copying 4 characters instead of 3 might address the warning.
Assignee | ||
Comment 11•5 years ago
|
||
Thanks.
funny enough https://en.cppreference.com/w/c/string/byte/strncpy that sites example had that exact same error. so i could easily verify.
Reporter | ||
Comment 12•5 years ago
|
||
Nicklas, do you have a Linux build environment? Or access to Mozilla's "Try" servers? It would be good to verify the Linux strncpy error is fixed before landing on mozilla-central again.
Getting access to the Try Server:
https://wiki.mozilla.org/ReleaseEngineering/TryServer#Getting_access_to_the_Try_Server
Assignee | ||
Comment 13•5 years ago
|
||
Hey, no i do not have access (that i know :)) to the try server.
i do however have a Linux build env. Is there something i can do then?
And yes i would really like to verify "locally" before making another attempt.
Reporter | ||
Comment 14•5 years ago
|
||
(In reply to Nicklas Boman [:smurfd] from comment #13)
i do however have a Linux build env. Is there something i can do then?
And yes i would really like to verify "locally" before making another attempt.
When you build Firefox for Linux, are you using clang or gcc? AFAIK, Mozilla's official Linux builds use gcc (while Windows and macOS use clang). gcc might be reporting warnings about strncpy that clang doesn't. If you're using clang, can you try gcc?
You can override the default compiler in your mozconfig file using something like (this snippet from my mozconfig on macOS):
export CC="/path/to/your/gcc"
export CXX="/path/to/your/g++"
Assignee | ||
Comment 15•5 years ago
•
|
||
Thanks, yeah i have been using Clang as default on linux.
export CC="/usr/bin/gcc-9"
export CXX="/usr/bin/g++-9"
mk_add_options PYTHON=/usr/bin/python3.6
ac_add_options --enable-optimize
#ac_add_options --enable-linker=lld
ac_add_options --disable-elf-hack
# Debug builds
ac_add_options --enable-debug
ac_add_options --enable-debug-symbols
# Stricter builds
#### ac_add_options --enable-warnings-as-errors
thats pretty much my mozconfig file now, had clang as CC and clang++ as CXX before.
I have also tried to enable the --enable-warnings-as-errors as you suggested earlier but have struggled to get it to build, not becuase of my changes ... will digg deeper into that during the weekend. ;)
-- edit --
also if i wont succeed, ill try in like a Ubuntu vm ... (not opensuse that i have created the bootstrap for :))
Assignee | ||
Comment 16•5 years ago
|
||
Thanks Chris! YES, not sure if it was adding CC=gcc or combined that with the debug build option, now i get to see the errors shown in the try builds :)
Comment 17•5 years ago
|
||
Comment 18•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Description
•