Closed Bug 283565 Opened 20 years ago Closed 19 years ago

Improper use of Realloc (mlk/crash) and silly return value for OOM

Categories

(Core Graveyard :: Security: UI, defect)

Other Branch
x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: timeless, Assigned: timeless)

References

()

Details

(4 keywords, Whiteboard: [kerh-cuz] [sg:low?])

Attachments

(1 file, 1 obsolete file)

Assignee: kaie → dewildt
Status: NEW → ASSIGNED
Attachment #176371 - Flags: review?(timeless)
Attachment #176371 - Flags: superreview?(dveditz)
Attachment #176371 - Flags: review?(timeless)
Attachment #176371 - Flags: review+
Product: PSM → Core
Whiteboard: [kerh-cuz]
Comment on attachment 176371 [details] [diff] [review]
Handle realloc correct and return correct error

As long as we're touching this code we should clean it up.
combine the Realloc/Alloc cases by dropping the if (mData) test.

There's also no way for len to be < 0 so the final
else assertion/return is just silly.

  if (len)
    if (mLen < len)
      realloc...
    memcpy
  else if (mData)
      free
Attachment #176371 - Flags: superreview?(dveditz) → superreview-
*** Bug 334188 has been marked as a duplicate of this bug. ***
When realloc decides to move the data, the existing code creates a dangling-pointer situation, so it could be a security hole.
Group: security
Flags: blocking1.8.0.3?
Whiteboard: [kerh-cuz] → [kerh-cuz] [sg:critical?]
Assignee: dewildt → timeless
Attachment #176371 - Attachment is obsolete: true
Attachment #218583 - Flags: superreview?(dveditz)
Attachment #218583 - Flags: review?(jruderman)
Flags: blocking1.8.0.3? → blocking1.8.0.3+
Comment on attachment 218583 [details] [diff] [review]
consistently use realloc

sr=dveditz
Attachment #218583 - Flags: superreview?(dveditz)
Attachment #218583 - Flags: superreview+
Attachment #218583 - Flags: review?(kengert)
Attachment #218583 - Flags: review?(jruderman)
Comment on attachment 218583 [details] [diff] [review]
consistently use realloc

r=kengert
Attachment #218583 - Flags: review?(kengert) → review+
Comment on attachment 218583 [details] [diff] [review]
consistently use realloc

approved for 1.8.0 branch, a=dveditz for drivers
Attachment #218583 - Flags: approval1.8.0.4+
Attachment #218583 - Flags: approval-branch-1.8.1+
Checked in on trunk and 1.8/1.8.0 branches:
> new revision: 1.9.28.1.2.1; previous revision: 1.9.28.1
> new revision: 1.9.28.2; previous revision: 1.9.28.1
> new revision: 1.12; previous revision: 1.11
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
The only use of nsNSSASN1PrintableItem::SetData I can find in Mozilla code is from buildASN1ObjectFromDER

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/security/manager/ssl/src/nsNSSASN1Object.cpp&rev=1.12&mark=204,209#203

Since that creates a fresh new printableItem and calls SetData on it once this must have used the alloc path and not the realloc path, thus this wasn't exploitable in practice. Perhaps in a non-Mozilla PSM client, if there is such a thing.

Kai: am I missing another use of this object?
Whiteboard: [kerh-cuz] [sg:critical?] → [kerh-cuz] [sg:low?]
Group: security
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: