Closed
Bug 1229804
Opened 9 years ago
Closed 9 years ago
Incorrect string length specified in Windows sandbox logging.
Categories
(Core :: Security: Process Sandboxing, defect)
Tracking
()
RESOLVED
FIXED
mozilla45
Tracking | Status | |
---|---|---|
firefox45 | --- | fixed |
People
(Reporter: bobowen, Assigned: bobowen)
Details
Attachments
(1 file)
3.22 KB,
patch
|
TimAbraldes
:
review+
|
Details | Diff | Splinter Review |
It seems that the Length in UNICODE_STRING that I use is in bytes, even though the buffer pointer in the same structure is effectively a wchar_t* (which is always 2 bytes on Windows).
Assignee | ||
Comment 1•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Attachment #8694797 -
Flags: review?(tabraldes)
Assignee | ||
Comment 2•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=bb231036fe2d
Comment 3•9 years ago
|
||
Comment on attachment 8694797 [details] [diff] [review] Use the correct string length in Windows sandbox logging Review of attachment 8694797 [details] [diff] [review]: ----------------------------------------------------------------- ::: security/sandbox/chromium-shim/sandbox/win/sandboxLogging.cpp @@ +65,5 @@ > { > if (sLogFunction) { > // Skip an extra frame to allow for this function. > LogBlocked(aFunctionName, > + base::WideToUTF8(std::wstring(aContext, aLengthInBytes / sizeof(wchar_t))).c_str(), I think we could take advantage of the `std::wstring(const_pointer _First, const_pointer _Last)` constructor [1] to rewrite this instead as `base::WideToUTF8(std::wstring(aContext, aContext + aLengthInBytes)).c_str(),` [1] https://msdn.microsoft.com/en-us/library/y22b7w38.aspx
Attachment #8694797 -
Flags: review?(tabraldes) → review+
Comment 4•9 years ago
|
||
(In reply to Tim Abraldes [:TimAbraldes] [:tabraldes] from comment #3) > Comment on attachment 8694797 [details] [diff] [review] > Use the correct string length in Windows sandbox logging > > Review of attachment 8694797 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: security/sandbox/chromium-shim/sandbox/win/sandboxLogging.cpp > @@ +65,5 @@ > > { > > if (sLogFunction) { > > // Skip an extra frame to allow for this function. > > LogBlocked(aFunctionName, > > + base::WideToUTF8(std::wstring(aContext, aLengthInBytes / sizeof(wchar_t))).c_str(), > > I think we could take advantage of the `std::wstring(const_pointer _First, > const_pointer _Last)` constructor [1] to rewrite this instead as > `base::WideToUTF8(std::wstring(aContext, aContext + > aLengthInBytes)).c_str(),` > > [1] https://msdn.microsoft.com/en-us/library/y22b7w38.aspx There might be an off-by-one error in this suggestion. It might need to be `aContext + aLengthInBytes - 1`. I'm not sure from the documentation that I've read
Assignee | ||
Comment 5•9 years ago
|
||
Thanks Tim. (In reply to Tim Abraldes [:TimAbraldes] [:tabraldes] from comment #3) > > + base::WideToUTF8(std::wstring(aContext, aLengthInBytes / sizeof(wchar_t))).c_str(), > > I think we could take advantage of the `std::wstring(const_pointer _First, > const_pointer _Last)` constructor [1] to rewrite this instead as > `base::WideToUTF8(std::wstring(aContext, aContext + > aLengthInBytes)).c_str(),` But aContext is a wchar_t* (wchar_t is 2 bytes on Windows), so with pointer arithmetic, as the length is in bytes _Last would be at a point double the length of the string.
Comment 7•9 years ago
|
||
(In reply to Bob Owen (:bobowen) from comment #5) > Thanks Tim. > > (In reply to Tim Abraldes [:TimAbraldes] [:tabraldes] from comment #3) > > > > + base::WideToUTF8(std::wstring(aContext, aLengthInBytes / sizeof(wchar_t))).c_str(), > > > > I think we could take advantage of the `std::wstring(const_pointer _First, > > const_pointer _Last)` constructor [1] to rewrite this instead as > > `base::WideToUTF8(std::wstring(aContext, aContext + > > aLengthInBytes)).c_str(),` > > But aContext is a wchar_t* (wchar_t is 2 bytes on Windows), so with pointer > arithmetic, as the length is in bytes _Last would be at a point double the > length of the string. Ah, good point. We'd have to do some casting or do the exact same math for that approach to work.
Comment 8•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/29408f18b82e
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in
before you can comment on or make changes to this bug.
Description
•