Closed Bug 522767 Opened 15 years ago Closed 15 years ago

Off by one error in nsDataObj::GetFile() triggers assert

Categories

(Core :: Widget: Win32, defect, P2)

x86_64
Windows 7
defect

Tracking

()

RESOLVED FIXED
Tracking Status
status1.9.2 --- beta4-fixed
status1.9.1 --- unaffected

People

(Reporter: khuey, Assigned: khuey)

Details

(Keywords: assertion)

Attachments

(1 file)

nsDataObj::GetFile() has an off by one error on the data flavors array.  Because it increments the counter before reading it skips the first element of the array and tries to read one past the last.  This triggers an assert at xpcom/glue/nsTArray.h at line 317 when it tries to read.

This bug is encountered when trying to drag a file to the desktop when it does not support the type "application/x-moz-nativeimage".

I don't think this is security-sensitive but just covering the bases.
Attached patch PatchSplinter Review
Pretty trivial.
Attachment #406742 - Flags: review?
Attachment #406742 - Flags: review? → review?(jmathies)
Attachment #406742 - Flags: review?(jmathies) → review+
(In reply to comment #0)
> I don't think this is security-sensitive but just covering the bases.

Good call.  Generally, unless it's immediately obvious, err on the side of caution.  In this case, since nsTArray has no fenceposting behavior to fill the last spot with some "safe" value (e.g. NULL if it were an array of pointers, or conceivably nsCString() in this case), it's not obvious things couldn't go wrong in attacker-controllable ways.  Exactly what bad would happen if execution continued past that point isn't obvious, so paranoia is desirable.
Comment on attachment 406742 [details] [diff] [review]
Patch

We'll want to take this on 1.9.2 as well.  This doesn't affect 1.9.1.
Attachment #406742 - Flags: approval1.9.2?
Flags: blocking1.9.2?
Attachment #406742 - Flags: superreview?(roc)
Comment on attachment 406742 [details] [diff] [review]
Patch

As per our review policy (http://www.mozilla.org/hacking/reviewers.html), all security bugs require superreview for patches.
Keywords: checkin-needed
(In reply to comment #5)
> (From update of attachment 406742 [details] [diff] [review])
> As per our review policy (http://www.mozilla.org/hacking/reviewers.html), all
> security bugs require superreview for patches.

Ah I was not aware of this policy.  Thanks for fixing things up for me.
Attachment #406742 - Flags: superreview?(roc)
Attachment #406742 - Flags: superreview+
Attachment #406742 - Flags: approval1.9.2?
Attachment #406742 - Flags: approval1.9.2+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/13f0f58e3d5c

Thanks!!
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Flags: blocking1.9.2? → blocking1.9.2+
Priority: -- → P2
Keywords: checkin-needed
Whiteboard: [needs 192 landing]
Keywords: checkin-needed
Whiteboard: [needs 192 landing]
Group: core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: