Almost all uses of atoi/strtol/strtoul() in dom/media/webrtc should be replaced
Categories
(Core :: WebRTC: Signaling, defect, P5)
Tracking
()
| backlog | webrtc/webaudio+ |
People
(Reporter: jesup, Assigned: vinitjangir)
References
Details
(Keywords: good-first-bug, Whiteboard: [lang=c++])
Attachments
(2 files, 2 obsolete files)
Updated•13 years ago
|
Comment 1•13 years ago
|
||
Comment 2•13 years ago
|
||
Comment 3•13 years ago
|
||
Updated•13 years ago
|
Comment 4•13 years ago
|
||
Updated•13 years ago
|
Comment 5•13 years ago
|
||
| Reporter | ||
Comment 6•13 years ago
|
||
Comment 7•13 years ago
|
||
Updated•13 years ago
|
Comment 8•13 years ago
|
||
| Reporter | ||
Comment 9•13 years ago
|
||
| Reporter | ||
Comment 10•12 years ago
|
||
| Reporter | ||
Updated•11 years ago
|
Updated•11 years ago
|
Updated•11 years ago
|
Comment 11•11 years ago
|
||
| Reporter | ||
Updated•11 years ago
|
Comment 12•11 years ago
|
||
| Reporter | ||
Comment 13•11 years ago
|
||
Comment 14•11 years ago
|
||
Updated•6 years ago
|
Comment 15•5 years ago
|
||
This good-first-bug hasn't had any activity for 6 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.
Comment 16•3 years ago
|
||
Hello,
I would like to take up this issue . Restating the issue for my understand:
- instances of atoi() have been removed. (#comment 7)
- need to change strtol/strtoul -> create a helper functions in signaling to parse long/unsigned long using PR_sscanf() and replace uses of strtol/strtoul with those. (#comment 8)
Please confirm if I understood it rightly and assign me this issue
Comment 17•3 years ago
|
||
Also NI'ing Nico in case jesup hasn't looked at this code in a while.
To share some context, kokopo is an Outreachy applicant and is looking at this good-first-bug as part of their application round.
Thanks.
Comment 18•3 years ago
|
||
Forgot to ask, is this still a problem? The bug was last touched 8 years ago.
Updated•3 years ago
|
| Reporter | ||
Comment 19•3 years ago
|
||
It still should be. strtoll/strtoull are dependent on LOCALE, and virtually all our uses of it should not be.
If we can use glib-specific functions, we can use ascii_strtoll/ascii_strtoull(). Or use PR_sscanf() (likely by making a wrapper).
Comment 20•3 years ago
|
||
Hi,
I would like to take up this issue. Can you assign me to it ?
Updated•3 years ago
|
Comment 21•3 years ago
|
||
Is this issue still active? I would love to take up this issue as my first bug! Can someone assign me to it?
Comment 22•3 years ago
|
||
Sure! There are still some cases of strtoul around in dom/media/webrtc, and a few atoi in nicer. I don't see strtol anywhere.
Comment 23•3 years ago
|
||
Here's the quick-start guide, happy patching!
Comment 24•3 years ago
|
||
Ok, thank you for assigning Byron. Working on it...
Comment 25•3 years ago
|
||
Hey, Byron went through all lines of code in webrctc/signaling folder in the code base...But found no occurence of atoi/strtol/strtoul()
Comment 26•3 years ago
|
||
All that code has moved to dom/media/webrtc:
https://searchfox.org/mozilla-central/search?q=strtoul&path=dom%2Fmedia%2Fwebrtc&case=false®exp=false
https://searchfox.org/mozilla-central/search?q=atoi&path=dom%2Fmedia%2Fwebrtc&case=false®exp=false
Comment 27•3 years ago
|
||
Ok thank you very much. Working on it
Comment 28•3 years ago
|
||
This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.
Comment 29•3 years ago
|
||
Are we sure PR_sscanf is locale-independent? I looked at the implementation of PR_sscanf and it uses isspace and isdigit. Technically those are also locale-dependent. POSIX-2008 specifies _l variants. Also: does PR_sscanf check for underflow/overflow? I don't think it does??!
Source: https://searchfox.org/mozilla-central/source/nsprpub/pr/src/io/prscanf.c#618
| Reporter | ||
Comment 30•3 years ago
|
||
Using a gecko wrapper around PR_sscanf is a valid step forward; while in theory it's locale-dependent, it avoids most or all of the current issues. See Froyd's comment
| Assignee | ||
Comment 31•2 months ago
|
||
Good evening. I have found 5 places where atoi, strtoul, and strtoull are used in the WebRTC folders:
- dom/media/webrtc/transport/test/turn_unittest.cpp:203: r = nr_str_port_to_transport_addr(host.c_str(), atoi(port.c_str()),
- dom/media/webrtc/transport/test/turn_unittest.cpp:283: r = nr_str_port_to_transport_addr(host.c_str(), atoi(port.c_str()),
- dom/media/webrtc/sdp/SdpHelper.cpp:630: unsigned long pt = strtoul(ptString.c_str(), &end, 10);
- dom/media/webrtc/sdp/SipccSdp.cpp:77: uint64_t sessId = strtoull(sdp_get_owner_sessionid(sdp), nullptr, 10);
- dom/media/webrtc/sdp/SipccSdp.cpp:78: uint64_t sessVer = strtoull(sdp_get_owner_version(sdp), nullptr, 10);
I am new to this code and I want to update these correctly. Could you please show me an example of the code I should use and how to handle errors? Thank you.
Comment 32•2 months ago
|
||
I think we want to replace these with std::from_chars. Some of these cases start with a std::string, so passing first and last will be trivial. There are a couple of others that are based on a c-string, so you'll just need to use strlen to find the end.
| Assignee | ||
Comment 33•2 months ago
|
||
Good evening, Byron,
Thank you for the guidance! I have understood.
I have successfully changed all the instances across the dom/media/webrtc folder and verified everything builds cleanly. Submitting the patch via Phabricator now.
| Assignee | ||
Comment 34•2 months ago
|
||
Updated•2 months ago
|
Updated•2 months ago
|
Comment 35•2 months ago
|
||
Comment 36•2 months ago
|
||
| bugherder | ||
Updated•1 month ago
|
Comment 37•1 month ago
|
||
Reverted from Beta for 152.0b8 for causing bug 2044894.
Comment 38•1 month ago
|
||
Comment 39•1 month ago
•
|
||
The better error checking caught an internal error, breaking Vonage, although that error is of no consequence.
Comment 40•1 month ago
|
||
This was only backed out from Beta, so the bug should remain closed.
Description
•