Closed
Bug 1335075
Opened 8 years ago
Closed 8 years ago
RTCCertificate.cpp: output truncated before the last format character
Categories
(Core :: WebRTC, defect, P3)
Core
WebRTC
Tracking
()
RESOLVED
FIXED
mozilla54
Tracking | Status | |
---|---|---|
firefox54 | --- | fixed |
backlog | webrtc/webaudio+ |
People
(Reporter: Sylvestre, Assigned: Sylvestre)
References
Details
Attachments
(1 file)
0:25.93 /root/firefox-gcc-last/dom/media/webrtc/RTCCertificate.cpp: In member function 'nsresult mozilla::dom::GenerateRTCCertificateTask::GenerateCertificate()':
0:25.93 /root/firefox-gcc-last/dom/media/webrtc/RTCCertificate.cpp:85:12: error: output truncated before the last format character [-Werror=format-truncation=]
0:25.93 nsresult GenerateCertificate()
0:25.93 ^~~~~~~~~~~~~~~~~~~
0:25.93 /root/firefox-gcc-last/dom/media/webrtc/RTCCertificate.cpp:78:15: note: format output 3 bytes into a destination of size 2
0:25.93 snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
0:25.93 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Should be 3:
uint8 to hexa is 2 bytes + terminating nul
Comment hidden (mozreview-request) |
Comment 2•8 years ago
|
||
mozreview-review |
Comment on attachment 8831730 [details]
Bug 1335075 - RTCCertificate.cpp: output truncated before the last format character
https://reviewboard.mozilla.org/r/108284/#review109440
This will result in a bunch of unneeded nul-byte writes... IIRC snprintf truncates the output (thus the warning), but the code follows the loop with adding a trailing nul. I'd prefer to change it to something else that also avoids the writes, or suppress the warning. The code is correct as-is. Can we leave it, or suppress?
In practice, the writes will tend to get whomped in the cache before hitting memory, but still...
Attachment #8831730 -
Flags: review?(rjesup) → review+
Updated•8 years ago
|
backlog: --- → webrtc/webaudio+
Rank: 35
Priority: -- → P3
Assignee | ||
Comment 3•8 years ago
|
||
Randell, what about?
- snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
+ sprintf(&buf[i * 2 + 3], "%.2x", randomName[i]);
Flags: needinfo?(rjesup)
Comment 4•8 years ago
|
||
(In reply to Sylvestre Ledru [:sylvestre] from comment #3)
> Randell, what about?
>
> - snprintf(&buf[i * 2 + 3], 2, "%.2x", randomName[i]);
> + sprintf(&buf[i * 2 + 3], "%.2x", randomName[i]);
If you did that, you could remove the extra nul write at the end... but it basically has the same problem, writing many nuls and then overwriting them. land the patch you originally gave; snprintf to make hex values isn't efficient in the first place, so it's not a big deal.
Flags: needinfo?(rjesup)
Assignee | ||
Comment 5•8 years ago
|
||
thanks!
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/369da2e22d43
RTCCertificate.cpp: output truncated before the last format character r=jesup
Comment 8•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in
before you can comment on or make changes to this bug.
Description
•