Closed Bug 446692 Opened 17 years ago Closed 17 years ago

do_get_file fails on Windows with ".." in the file location.

Categories

(Testing :: XPCShell Harness, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: standard8, Assigned: standard8)

Details

(Keywords: regression)

Attachments

(1 file)

Now we are switching to comm-central, the windows buildbots (Thunderbird and SeaMonkey) are showing consistent errors on "make check": TEST-UNEXPECTED-FAIL | ../../../mozilla/_tests/xpcshell-simple/test_mailnewsbase/unit/test_searchJunk.js | test failed, see log ../../../mozilla/_tests/xpcshell-simple/test_mailnewsbase/unit/test_searchJunk.js.log: >>>>>>> *** test pending Wants directory: SysD Wants directory: MailD Wants directory: MFCaF Wants directory: DefRt *** test pending [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.append]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: d:/builds/slave/comm-central-win32/build/mozilla/tools/test-harness/xpcshell-simple/head.js :: do_get_file :: line 178" data: no] *** FAIL *** <<<<<<< If someone on Windows has chance to try this, then it would be interesting to look in: http://mxr.mozilla.org/comm-central/source/mozilla/tools/test-harness/xpcshell-simple/head.js#155 at the do_get_file function, and find out what lf.path is before the for loop, and what is the value of comps[i] when it fails.
Summary: Windows xpcshell unit tests failing on comm-central → Windows mailnews xpcshell unit tests failing on comm-central
In passing, I noticed that bug 443220 introduced a problem that causes check-one to give incorrect results. That is, it creates a new log file in the wrong directory, then scans the old log file for errors. I'll file a bug on that. The current failures in mailnews unit tests are coming from code like: var bugmail1 = do_get_file("../mailnews/test/data/bugmail1"); do_get_file is choking on the ".." in the file path. I see that was added as part of the switchover to comm-central. comps[i] is ".." when it fails. lf.path is "s:\hg\src\mozilla"
As rkent said, the problem is all of the instances of ".." in the calls to do_get_file. It turns out that the AppendInternal method of nsLocalFileWin.cpp (called by the Append method) returns NS_ERROR_FILE_UNRECOGNIZED_PATH if the parameter is ".." http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/io/nsLocalFileWin.cpp#1060 There is a possibly related note in nsILocalFile.idl that mentions not allowing .. for "security reasons" http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/io/nsILocalFile.idl#123 As a temporary workaround, I was able to make all tests in mailnews pass in Windows (and Linux) by changing the for loop in the do_get_file method http://mxr.mozilla.org/comm-central/source/mozilla/tools/test-harness/xpcshell-simple/head.js#155 To: for (var i = 0, sz = comps.length; i < sz; i++) { // avoids problems if either path ended with / if (comps[i].length > 0) if (comps[i] == "..") lf = lf.parent; else lf.append(comps[i]); } But I'm curious as to why nsLocalFileWin.cpp throws an error in this case but nsLocalFileUnix.cpp, for example, doesn't. http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/io/nsLocalFileUnix.cpp#1755
Moving to Testing/TUnit and updating summary to reflect the real problem. I'm going to attach a patch based on Josh's one in a moment.
Component: Build Config → TUnit
Product: Mozilla Application Suite → Testing
QA Contact: build-config → tunit
Summary: Windows mailnews xpcshell unit tests failing on comm-central → do_get_file fails on Windows with ".." in the file location.
Version: Trunk → unspecified
Attached patch The fixSplinter Review
Patch based on Josh's version. I think this should work (it works fine for me on mac).
Assignee: nobody → bugzilla
Status: NEW → ASSIGNED
Attachment #330929 - Flags: review?(ted.mielczarek)
Attachment #330929 - Attachment is patch: true
Attachment #330929 - Attachment mime type: application/octet-stream → text/plain
The proposed change also works for me on Windows 2003 Server x64 (which previously failed).
Comment on attachment 330929 [details] [diff] [review] The fix Can you add braces to that outer if statement? I'm not a fan of nested ifs without braces.
Attachment #330929 - Flags: review?(ted.mielczarek) → review+
(In reply to comment #6) > (From update of attachment 330929 [details] [diff] [review]) > Can you add braces to that outer if statement? I'm not a fan of nested ifs > without braces. > Definitely, I'd have probably done that myself had I not been copying another patch.
(In reply to comment #1) > In passing, I noticed that bug 443220 introduced a problem that causes > check-one to give incorrect results. That is, it creates a new log file in the > wrong directory, then scans the old log file for errors. I'll file a bug on > that. Bug 447043 ;-)
(In reply to comment #2) > But I'm curious as to why nsLocalFileWin.cpp throws an error in this case but > nsLocalFileUnix.cpp, for example, doesn't. That's bug 349090 ;-)
Comment on attachment 330929 [details] [diff] [review] The fix {{ changeset: 16178:fd1ba554c41d user/date: Mark Banner <bugzilla@standard8.plus.com> 2008-07-24 15:33:41 }} with comment 7 suggestion(s).
Attachment #330929 - Attachment description: The fix → The fix [Checkin: Comment 10]
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
(In reply to comment #10) > changeset: 16178:fd1ba554c41d > user/date: Mark Banner <bugzilla@standard8.plus.com> 2008-07-24 15:33:41 Let's use shared repository numbers :-> [ Mark Banner <bugzilla@standard8.plus.com> - Thu, 24 Jul 2008 16:33:41 +0100 - rev 16174 ]
Attachment #330929 - Attachment description: The fix [Checkin: Comment 10] → The fix
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: