Closed
Bug 1229804
Opened 10 years ago
Closed 10 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•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Attachment #8694797 -
Flags: review?(tabraldes)
Assignee | ||
Comment 2•10 years ago
|
||
Comment 3•10 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•10 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•10 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•10 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•10 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in
before you can comment on or make changes to this bug.
Description
•