Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id AFECA200BFD for ; Sun, 15 Jan 2017 20:48:33 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id AE8EC160B32; Sun, 15 Jan 2017 19:48:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 093CB160B2B for ; Sun, 15 Jan 2017 20:48:32 +0100 (CET) Received: (qmail 61148 invoked by uid 500); 15 Jan 2017 19:48:32 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 61136 invoked by uid 99); 15 Jan 2017 19:48:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Jan 2017 19:48:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A73A3180BD0 for ; Sun, 15 Jan 2017 19:48:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id nwzw3gEoCW29 for ; Sun, 15 Jan 2017 19:48:30 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 90DD75F610 for ; Sun, 15 Jan 2017 19:48:29 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 8F744E0479 for ; Sun, 15 Jan 2017 19:48:28 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 79ED525288 for ; Sun, 15 Jan 2017 19:48:26 +0000 (UTC) Date: Sun, 15 Jan 2017 19:48:26 +0000 (UTC) From: =?utf-8?Q?Guillaume_Bou=C3=A9_=28JIRA=29?= To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (COMPRESS-379) isUnixSymlink returns true for Zip entries with Unix permissions 177777 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 15 Jan 2017 19:48:33 -0000 [ https://issues.apache.org/jira/browse/COMPRESS-379?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D15= 823230#comment-15823230 ]=20 Guillaume Bou=C3=A9 edited comment on COMPRESS-379 at 1/15/17 7:48 PM: ------------------------------------------------------------------ What is the flag indicating that a symlink is set? I interpreted the {{?}} = inside {{?rwsrwsrwt}} to mean "unknown file type" (like what {{ls -l}} outp= uts) rather than "symbolic link". Octal permissions of a symbolic link shou= ld be of the form {{12xxxx}}. I think {{getUnixMode}} does the right job of returning the Unix permission= s as an octal number, but {{isUnixSymlink}} sometimes returns {{true}} when= that number is higher than {{120000}} (like {{177777}} in the description = where all bits are set). It does correctly return {{false}} for permissions= of {{147777}} for example. was (Author: gboue): What is the flag indicating that a symlink is set? I interpreted the {{?}} = inside {{?rwsrwsrwt}} to mean "unknown file type" (like what {{ls -l}} outp= uts) rather than "symbolic link". Octal permissions of a symbolic link shou= ld be of the form {{12xxxx}}. I think {{getUnixMode}} does the right job of returning the Unix permission= s as an octal number, but {{isUnixSymlink}} always returns {{true}} when th= at number is higher than {{120000}}. > isUnixSymlink returns true for Zip entries with Unix permissions 177777 > ----------------------------------------------------------------------- > > Key: COMPRESS-379 > URL: https://issues.apache.org/jira/browse/COMPRESS-379 > Project: Commons Compress > Issue Type: Bug > Components: Archivers > Affects Versions: 1.13 > Reporter: Guillaume Bou=C3=A9 > Attachments: invalid-entry.jar > > > This issue was originally reported in MASSEMBLY-842, but it seems the roo= t cause in inside Commons Compress. > Consider the attached {{invalid-entry.jar}}, whose contents, as shown by = the {{zipinfo}} utility, is: > {noformat} > ?rwsrwsrwt 2.0 unx 0 b- stor 17-Jan-15 16:06 META-INF/maven/ > drwxr-xr-x 2.0 unx 0 b- stor 17-Jan-15 16:06 META-INF/ > {noformat} > There are some JAR files created by the Maven Assembly Plugin with conten= t similar to this, and the entry {{META-INF/maven/}} has permissions 177777= (octal). Constructing a {{ZipFile}} from this file, the method {{isUnixSym= link}} incorrectly returns {{true}} for the entry {{META-INF/maven/}} (and = it correctly returns {{false}} for the entry {{META-INF/}}. > Here is a sample Java code that can be used to see the behaviour: > {code:java} > public static void main(String[] args) throws IOException { > try (ZipFile zipFile =3D new ZipFile(new File("invalid-entry.jar"))) = { > printAttributes(zipFile, "META-INF/"); > printAttributes(zipFile, "META-INF/maven/"); > } > } > private static void printAttributes(ZipFile zipFile, String name) { > ZipArchiveEntry entry =3D zipFile.getEntriesInPhysicalOrder(name).ite= rator().next(); > System.out.printf("%-17s: symlink:%-5s - unixMode:%s%n", name, entry.= isUnixSymlink(), entry.getUnixMode()); > } > {code} > This code outputs: > {noformat} > META-INF/ : symlink:false - unixMode:16877 > META-INF/maven/ : symlink:true - unixMode:65535 > {noformat} > The {{?rwsrwsrwt}} permissions show that the Zip entry is broken in the f= irst place, but I think {{isUnixSymlink}} should still return {{false}} in = that case, and not consider this entry to be a symlink. > It seems the fix would be to update {{isUnixSymlink}} and check whether t= he unix mode is equal to {{SHORT_MASK}}, and return {{false}} in that case = as it would indicate a broken entry. This change does not break any existin= g tests, but I'm not sure if this is the proper fix. > {code:java} > public boolean isUnixSymlink() { > int unixMode =3D getUnixMode(); > return unixMode =3D=3D SHORT_MASK ? false : (unixMode & UnixStat.LINK= _FLAG) =3D=3D UnixStat.LINK_FLAG; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)