Closed Bug 375259 Opened 19 years ago Closed 8 years ago

Directory service can return uninitialized nsILocalFiles

Categories

(Core :: XPCOM, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

References

()

Details

Attachments

(1 file)

From bug 373640 comment 2: var file = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties) .get("Drivs", Components.interfaces.nsILocalFile); alert(file.path); // Shows empty string alert(file.parent); // Throws NS_ERROR_FILE_UNRECOGNIZED PATH For "Drivs" |folder| at the provided URL is CSIDL_DRIVES, and Windows returns the empty string. This causes NS_NewLocalFile to return an uninitialized file (empty path), but code which calls the directory service certainly expects to get back an initialized file. |GetWindowsFolder| should return an error if the returned path is empty, because the empty path circumvents the Windows nsLocalFile's path-checking code. The patch is untested; I assume NS_ERROR_FILE_UNRECOGNIZED_PATH is included somewhere in the file.
Attachment #259568 - Flags: review?(benjamin)
Maybe it'd be a better idea just to remove "Drivs" from the recognized keys. Thoughts?
Attachment #259568 - Flags: review?(benjamin) → review+
Hello, How could i help to solve this issue? Thanks,
(In reply to jbonnafo from comment #2) > How could i help to solve this issue? This issue already has a patch, and it looks like the patch still applies. So I don't think there's anything for you to do here; Waldo does need to be poked to land his patch, though. ;)
Flags: needinfo?(jwalden+bmo)
Pushed by jwalden@mit.edu: https://hg.mozilla.org/integration/mozilla-inbound/rev/353bb6fbb683 The directory service shouldn't return an uninitialized (safely) nsILocalFile for the "Drivs" key. r=bsmedberg 11 years ago
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.9alpha4 → mozilla60
Best guess is I held off, initially, on landing the patch because I wanted to resolve comment 1 first. But really, I have no idea what precisely I was thinking here. :-) Thanks for the poke, and the opportunity for possibly my bestest commit message evar.
Flags: needinfo?(jwalden+bmo)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: