Closed
Bug 733981
Opened 12 years ago
Closed 12 years ago
B2G SMS: potential errors in GsmPDUHelper.calculateUserDataLength()
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
FIXED
mozilla13
People
(Reporter: vicamo, Assigned: vicamo)
References
Details
Attachments
(2 files)
7.83 KB,
patch
|
philikon
:
review+
|
Details | Diff | Splinter Review |
2.12 KB,
patch
|
philikon
:
review+
|
Details | Diff | Splinter Review |
There might be other potential errors in GsmPDUHelper.calculateUserDataLength(): 01 calculateUserDataLength: function calculateUserDataLength(options) { 02 ... 03 for (...) { 04 ... 05 // Calculate full user data length, note the extra byte is for header len 06 let userDataLength = length + (headerLen ? headerLen + 1 : 0); 07 ... 08 if (userDataLength <= options.body.length) { 09 // Found minimum user data length already 10 return; 11 } 12 } 13 ... 14 } In line 6, the unit of `headerLen` is octet, while that of `length` is septet. Under some situations, the result may vary. In line 8~10, when it comes with a string with numerous ineffective characters like <escape>, the calculated encoded string length may be much less than options.body.length, and it is therefore possible for another encoding to have an even shorter result. For example, an input string of length 10 might get calculated cost 8 with several characters encoded with single shift mechanism. But another encoding might get cost 5 with all characters encoded with locking shift mechanism. This should be a minor issue because users cannot key-in \uffff and \ufffe, which are internally assigned to ineffective characters <escape> and <resctl>.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → vyang
Assignee | ||
Comment 1•12 years ago
|
||
This issue was first addressed in https://bugzilla.mozilla.org/show_bug.cgi?id=733300#c4 , and had already fixes in attachment 603660 [details] [diff] [review]. Should also add test cases for them.
Assignee | ||
Comment 2•12 years ago
|
||
1) rename related variables, functions to have more clear meaning. 2) add test case
Attachment #603972 -
Flags: review?(philipp)
Assignee | ||
Comment 3•12 years ago
|
||
1) remove early return condition 2) add test case
Attachment #603973 -
Flags: review?(philipp)
Updated•12 years ago
|
Attachment #603972 -
Flags: review?(philipp) → review+
Updated•12 years ago
|
Attachment #603973 -
Flags: review?(philipp) → review+
Comment 4•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/f20ede6f964a https://hg.mozilla.org/mozilla-central/rev/c2d1c97a8a2f
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in
before you can comment on or make changes to this bug.
Description
•