commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (COMPRESS-55) CpioArchiveEntry ignores invalid modes
Date Thu, 26 Mar 2009 15:00:51 GMT

    [ https://issues.apache.org/jira/browse/COMPRESS-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12689501#action_12689501
] 

Sebb edited comment on COMPRESS-55 at 3/26/09 8:00 AM:
-------------------------------------------------------

Further investigation shows that the test file *does* have FFFFFFFF in it.

The file (bla.cpio) is a temporary archive created by the test case.

It looks like the problem may be that the CpioArchiveEntry class initialises the mode to -1.

I can get the test cases to pass by:

1) Allowing setMode(0)
2) defaulting mode to 0 rather than -1.

But I'm not sure that this is the correct approach - does 0 make sense as a mode? 
Perhaps only for the trailer, in which case using a default of 0 would make more sense.
The finish() method would not need to call setMode(0) if the default were 0.
However, when reading a trailer the mode will be read as 0.

I suppose it might be worth throwing an Exception if the mode is zero but the record is not
the trailer record.

Also, I suspect the "mtime" field should be initialised to 0 rather than -1.

      was (Author: sebb@apache.org):
    Further investigation shows that the test file *does* have FFFFFFFF in it.

The file (bla.cpio) is a temporary archive created by the test case.

It looks like the problem may be that the CpioArchiveEntry class initialises the mode to -1.

I can get the test cases to pass by:

1) Allowing setMode(0)
2) defaulting mode to 0 rather than -1.

But I'm not sure that this is the correct approach - does 0 make sense as a mode? 
Perhaps only for the trailer, in which case using a default of 0, and disallowing setMode(0)
would make more sense.
[The finish() method would not need to call setMode(0) if the default was 0]

Also, I suspect the "mtime" field should be initialised to 0 rather than -1.
  
> CpioArchiveEntry ignores invalid modes
> --------------------------------------
>
>                 Key: COMPRESS-55
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-55
>             Project: Commons Compress
>          Issue Type: Bug
>            Reporter: Sebb
>
> CpioArchiveEntry has the following code:
> {code}
>         default:
>             // FIXME: testCpioUnarchive fails if I change the line to
>             // actually throw the excpetion
>             new IllegalArgumentException("Unknown mode (full mode: " + mode
>                     + ", masked mode: " + (mode & S_IFMT));
>         }
> {code}
> As the comment says, rejecting invalid modes causes test failures.
> These appear to be caused by the code
> {bq}        this.cpioEntry.setMode(0);
> in the method CpioArchiveOutputStream.finish()
> Is a mode of 0 allowed? If so, then setMode needs to allow it, otherwise the method call
needs to change to something else.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message