Closed Bug 710989 Opened 13 years ago Closed 11 years ago

Possible memset underflow in Time::Explode()

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: Dolske, Assigned: charles.wh.chan)

References

Details

(Whiteboard: [pvs-studio][good first bug][lang=c++])

Attachments

(1 file)

From http://www.viva64.com/en/a/0078/,
6th section in http://www.viva64.com/external-pictures/txt/mozilla-test.txt

V512 A call of the 'memset' function will lead to underflow of the buffer '(exploded)'.
time_win.cc 198

void Time::Explode(bool is_local, Exploded* exploded) const {
  ...
  ZeroMemory(exploded, sizeof(exploded));
  ...
}

I think there could be written like this.
ZeroMemory(exploded, sizeof(*exploded));
Blocks: 710966
Whiteboard: [pvs-studio] → [pvs-studio][good first bug][lang=c++]
I don't think we use Time for anything in gecko, but this is probably fixed upstream in chromium.  If not we should file there too.
(In reply to Chris Jones [:cjones] [:warhammer] from comment #1)
> I don't think we use Time for anything in gecko, but this is probably fixed
> upstream in chromium.  If not we should file there too.

Yes. It appears the issue has already been resolved in Chromium. See ~Line 255
http://src.chromium.org/viewvc/chrome/trunk/src/base/time_win.cc?view=annotate
Just out of curiosity, why is there a copy of the Chromium src within the Mozilla source code?
Fix the ZeroMemory() issue in the Mozilla src tree, please review.
Attachment #608963 - Flags: review?(dolske)
Comment on attachment 608963 [details] [diff] [review]
Bug 710989: Patch-1

This is in Chris's area, so moving review.

Thanks for the patch!
Attachment #608963 - Flags: review?(dolske) → review?(jones.chris.g)
(In reply to Charles Chan from comment #3)
> Just out of curiosity, why is there a copy of the Chromium src within the
> Mozilla source code?

Gecko uses Chromium's inter-process communication library. Here is a link to a list of third-party code located in the tree: https://wiki.mozilla.org/ThirdPartyCode
Comment on attachment 608963 [details] [diff] [review]
Bug 710989: Patch-1

Sorry for the review latency.
Attachment #608963 - Flags: review?(jones.chris.g) → review+
Oops. I'll see if this is still valid on trunk.
Assignee: nobody → charles.wh.chan
https://hg.mozilla.org/mozilla-central/rev/4de05e48b784
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: