Closed Bug 553586 Opened 15 years ago Closed 15 years ago

Heap corruption in windows ShowNativePrintDialog

Categories

(Core :: Printing: Setup, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.9.3a4

People

(Reporter: jacek, Assigned: jacek)

References

Details

Attachments

(1 file)

Attached patch fixSplinter Review
While filling DEVNAMES structure, we overwrite allocated buffer. An offset is set to sizeof(DEVNAMES): pDevNames->wDriverOffset = sizeof(DEVNAMES); The offset is supposed to be set in chars (wchar_t in this case). We tread it as offset later: wchar_t* device = &(((wchar_t*)pDevNames)[pDevNames->wDeviceOffset]); but the offset doesn't point at the end of an DEVNAMES structure, so there is an overwrite. The DEVNAMES structure contains four WORDs, so it's safe to set an offset to sizeof(DEVNAMES)/sizeof(wchar_t). There is another bug in wOutputOffset: pDevNames->wOutputOffset = sizeof(DEVNAMES)+len+1; It points to the place *after* filled buffer, but it was probably meant to point to the null byte, so the +1 is wrong. The attached patch fixes the problem and cleans up a little (a simple memcpy is way cleaner than current addres-of-array-element magic IMO). While I was at this I've also fixed a few compiler warnings about unused variables and const char* -> char* casts.
Attachment #433554 - Attachment is patch: true
Attachment #433554 - Flags: review?(vladimir)
Severity: normal → major
Comment on attachment 433554 [details] [diff] [review] fix could've sworn I r+'d this already, sorry! Really wish this wasn't as magic as it looks, but the DEVNAMES API looks awful to begin with.
Attachment #433554 - Flags: review?(vladimir) → review+
Keywords: checkin-needed
Assignee: nobody → jacek
Status: NEW → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: