Open Bug 760209 Opened 14 years ago Updated 3 years ago

nsIZipWriter should fail if none of PR_WRONLY, PR_RDONLY, PR_RDWR are given

Categories

(Core :: Networking: JAR, defect, P5)

defect

Tracking

()

People

(Reporter: ttaubert, Unassigned)

Details

(Whiteboard: [necko-would-take])

Attachments

(1 obsolete file)

Attached patch patch v1 (obsolete) — Splinter Review
It took me quite some time to find out I was accidentally passing a read-only file to nsIZipWriter.open(). ftruncate (on Linux) fails when calling zw.close() and the file is empty. I was not passing any of RDONLY and WRONLY so I think we should extend the check at the beginning of the method.
Attachment #628822 - Flags: review?(dtownsend+bugmail)
Attachment #628822 - Attachment is obsolete: true
Attachment #628822 - Flags: review?(dtownsend+bugmail)
(Forget the summary please.) I want to create a ZipWriter that creates a file if it doesn't exist, yet. If it exists I want to add/modify entries in that file. I'm now using: > nsIZipWriter.open(file, PR_CREATE); I add some entries and call nsIZipWriter.close(). Now ftruncate() in nsFileStreamBase::SetEOF() fails somehow and leaves a broken zip file. If I use: > nsIZipWriter.open(file, PR_CREATE | PR_WRONLY); it all works well but it overwrites the file every time which isn't what I want. ftruncate() returns EINVAL which (as offset == 0) can only mean that "The fildes argument is not a file descriptor open for writing." > ---------------------------------------- Ok, so I totally forgot about PR_RDWR. I of course need to specify that... ZW.open() should bail if none of the Read/Write flags is given.
Summary: nsIZipWriter.open() should fail if a read-only file is passed → nsIZipWriter should fail if none of PR_WRONLY, PR_RDONLY, PR_RDWR are given
Whiteboard: [necko-would-take]
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: