Closed Bug 1488452 Opened 7 years ago Closed 7 years ago

Avoid writing past the logical length of a string in FileUtilsWin.h

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file)

The call to GetLogicalDriveStringsW first writes and then sets length.
Blocks: 1472113
I misunderstood the semantics of GetLogicalDriveStringsW. There's still a bug somewhere around here.
Also rewrote some code around the actual problem to be more obviously correct and comprehensible. MozReview-Commit-ID: FF2hSjQ4U1x
I took a look of the our other uses of PromiseFlatString and PromiseFlatCString and, fortunately, this seems to be a unique misuse of PromiseFlatString.
https://searchfox.org/mozilla-central/source/gfx/vr/gfxVROculus.cpp#658 started asserting about non-ASCII. I don't know why it started now, but using AppendPrintf to build a Windows file path seems suspicious to begin with.
(In reply to Henri Sivonen (:hsivonen) from comment #5) > https://searchfox.org/mozilla-central/source/gfx/vr/gfxVROculus.cpp#658 > started asserting about non-ASCII. I don't know why it started now, but > using AppendPrintf to build a Windows file path seems suspicious to begin > with. Ah, that code also has the write-past-mLength pattern, but I failed to find it on searchfox, because it's #ifdefed out as far as searchfox can tell.
(In reply to Henri Sivonen (:hsivonen) from comment #6) > (In reply to Henri Sivonen (:hsivonen) from comment #5) > > https://searchfox.org/mozilla-central/source/gfx/vr/gfxVROculus.cpp#658 > > started asserting about non-ASCII. I don't know why it started now, but > > using AppendPrintf to build a Windows file path seems suspicious to begin > > with. > > Ah, that code also has the write-past-mLength pattern, but I failed to find > it on searchfox, because it's #ifdefed out as far as searchfox can tell. Bug 1489462.
Comment on attachment 9006947 [details] Bug 1488452 - Remove incorrect use of PromiseFlatString in FileUtilsWin. Nathan Froyd [:froydnj] has approved the revision.
Attachment #9006947 - Flags: review+
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/36ee80fc14ae Remove incorrect use of PromiseFlatString in FileUtilsWin. r=froydnj
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: