You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2015/05/09 20:58:14 UTC
ant git commit: make tar package deal with bigger gid/uids
Repository: ant
Updated Branches:
refs/heads/master 8a8ebf595 -> ef6cad6a1
make tar package deal with bigger gid/uids
Port of fixes for https://issues.apache.org/jira/browse/COMPRESS-314 and
https://issues.apache.org/jira/browse/COMPRESS-315
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/ef6cad6a
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/ef6cad6a
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/ef6cad6a
Branch: refs/heads/master
Commit: ef6cad6a16581080ea8ea0e191dab031cd46bfa2
Parents: 8a8ebf5
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat May 9 20:57:19 2015 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat May 9 20:57:19 2015 +0200
----------------------------------------------------------------------
WHATSNEW | 5 ++
src/main/org/apache/tools/tar/TarEntry.java | 54 ++++++++++++++++++--
.../org/apache/tools/tar/TarInputStream.java | 4 +-
.../org/apache/tools/tar/TarOutputStream.java | 20 +++++---
4 files changed, 71 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/ef6cad6a/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index d617795..da0c8d1 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -121,6 +121,11 @@ Other changes:
<ftp> and <get>.
github pull requests #8 and #9
+ * The <tar> package can now deal with group and user ids bigger than
+ 0x80000000.
+ https://issues.apache.org/jira/browse/COMPRESS-314
+ https://issues.apache.org/jira/browse/COMPRESS-315
+
Changes from Ant 1.9.3 TO Ant 1.9.4
===================================
http://git-wip-us.apache.org/repos/asf/ant/blob/ef6cad6a/src/main/org/apache/tools/tar/TarEntry.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java
index dc9b64e..4b12237 100644
--- a/src/main/org/apache/tools/tar/TarEntry.java
+++ b/src/main/org/apache/tools/tar/TarEntry.java
@@ -119,10 +119,10 @@ public class TarEntry implements TarConstants {
private int mode;
/** The entry's user id. */
- private int userId;
+ private long userId;
/** The entry's group id. */
- private int groupId;
+ private long groupId;
/** The entry's size. */
private long size;
@@ -422,9 +422,12 @@ public class TarEntry implements TarConstants {
* Get this entry's user id.
*
* @return This entry's user id.
+ * @deprecated use #getLongUserId instead as user ids can be
+ * bigger than {@link Integer.MAX_INT}
*/
+ @Deprecated
public int getUserId() {
- return userId;
+ return (int) (userId & 0xffffffff);
}
/**
@@ -433,6 +436,26 @@ public class TarEntry implements TarConstants {
* @param userId This entry's new user id.
*/
public void setUserId(int userId) {
+ setUserId((long) userId);
+ }
+
+ /**
+ * Get this entry's user id.
+ *
+ * @return This entry's user id.
+ * @since 1.9.5
+ */
+ public long getLongUserId() {
+ return userId;
+ }
+
+ /**
+ * Set this entry's user id.
+ *
+ * @param userId This entry's new user id.
+ * @since 1.9.5
+ */
+ public void setUserId(long userId) {
this.userId = userId;
}
@@ -440,9 +463,12 @@ public class TarEntry implements TarConstants {
* Get this entry's group id.
*
* @return This entry's group id.
+ * @deprecated use #getLongGroupId instead as group ids can be
+ * bigger than {@link Integer.MAX_INT}
*/
+ @Deprecated
public int getGroupId() {
- return groupId;
+ return (int) (groupId & 0xffffffff);
}
/**
@@ -451,6 +477,26 @@ public class TarEntry implements TarConstants {
* @param groupId This entry's new group id.
*/
public void setGroupId(int groupId) {
+ setGroupId((long) groupId);
+ }
+
+ /**
+ * Get this entry's group id.
+ *
+ * @return This entry's group id.
+ * @since 1.9.5
+ */
+ public long getLongGroupId() {
+ return groupId;
+ }
+
+ /**
+ * Set this entry's group id.
+ *
+ * @param groupId This entry's new group id.
+ * @since 1.9.5
+ */
+ public void setGroupId(long groupId) {
this.groupId = groupId;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/ef6cad6a/src/main/org/apache/tools/tar/TarInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java
index 651f206..57827a2 100644
--- a/src/main/org/apache/tools/tar/TarInputStream.java
+++ b/src/main/org/apache/tools/tar/TarInputStream.java
@@ -484,11 +484,11 @@ public class TarInputStream extends FilterInputStream {
} else if ("linkpath".equals(key)){
currEntry.setLinkName(val);
} else if ("gid".equals(key)){
- currEntry.setGroupId(Integer.parseInt(val));
+ currEntry.setGroupId(Long.parseLong(val));
} else if ("gname".equals(key)){
currEntry.setGroupName(val);
} else if ("uid".equals(key)){
- currEntry.setUserId(Integer.parseInt(val));
+ currEntry.setUserId(Long.parseLong(val));
} else if ("uname".equals(key)){
currEntry.setUserName(val);
} else if ("size".equals(key)){
http://git-wip-us.apache.org/repos/asf/ant/blob/ef6cad6a/src/main/org/apache/tools/tar/TarOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarOutputStream.java b/src/main/org/apache/tools/tar/TarOutputStream.java
index 8162634..032f725 100644
--- a/src/main/org/apache/tools/tar/TarOutputStream.java
+++ b/src/main/org/apache/tools/tar/TarOutputStream.java
@@ -161,7 +161,7 @@ public class TarOutputStream extends FilterOutputStream {
/**
* Set the long file mode.
* This can be LONGFILE_ERROR(0), LONGFILE_TRUNCATE(1) or LONGFILE_GNU(2).
- * This specifies the treatment of long file names (names >= TarConstants.NAMELEN).
+ * This specifies the treatment of long file names (names >= TarConstants.NAMELEN).
* Default is LONGFILE_ERROR.
* @param longFileMode the mode to use
*/
@@ -512,7 +512,7 @@ public class TarOutputStream extends FilterOutputStream {
private String stripTo7Bits(String name) {
final int length = name.length();
- StringBuffer result = new StringBuffer(length);
+ StringBuilder result = new StringBuilder(length);
for (int i = 0; i < length; i++) {
char stripped = (char) (name.charAt(i) & 0x7F);
if (stripped != 0) { // would be read as Trailing null
@@ -538,12 +538,12 @@ public class TarOutputStream extends FilterOutputStream {
TarEntry entry) {
addPaxHeaderForBigNumber(paxHeaders, "size", entry.getSize(),
TarConstants.MAXSIZE);
- addPaxHeaderForBigNumber(paxHeaders, "gid", entry.getGroupId(),
+ addPaxHeaderForBigNumber(paxHeaders, "gid", entry.getLongGroupId(),
TarConstants.MAXID);
addPaxHeaderForBigNumber(paxHeaders, "mtime",
entry.getModTime().getTime() / 1000,
TarConstants.MAXSIZE);
- addPaxHeaderForBigNumber(paxHeaders, "uid", entry.getUserId(),
+ addPaxHeaderForBigNumber(paxHeaders, "uid", entry.getLongUserId(),
TarConstants.MAXID);
// star extensions by J\u00f6rg Schilling
addPaxHeaderForBigNumber(paxHeaders, "SCHILY.devmajor",
@@ -564,11 +564,11 @@ public class TarOutputStream extends FilterOutputStream {
private void failForBigNumbers(TarEntry entry) {
failForBigNumber("entry size", entry.getSize(), TarConstants.MAXSIZE);
- failForBigNumber("group id", entry.getGroupId(), TarConstants.MAXID);
+ failForBigNumberWithPosixMessage("group id", entry.getLongGroupId(), TarConstants.MAXID);
failForBigNumber("last modification time",
entry.getModTime().getTime() / 1000,
TarConstants.MAXSIZE);
- failForBigNumber("user id", entry.getUserId(), TarConstants.MAXID);
+ failForBigNumber("user id", entry.getLongUserId(), TarConstants.MAXID);
failForBigNumber("mode", entry.getMode(), TarConstants.MAXID);
failForBigNumber("major device number", entry.getDevMajor(),
TarConstants.MAXID);
@@ -577,6 +577,14 @@ public class TarOutputStream extends FilterOutputStream {
}
private void failForBigNumber(String field, long value, long maxValue) {
+ failForBigNumber(field, value, maxValue, "");
+ }
+
+ private void failForBigNumberWithPosixMessage(String field, long value, long maxValue) {
+ failForBigNumber(field, value, maxValue, " Use STAR or POSIX extensions to overcome this limit");
+ }
+
+ private void failForBigNumber(String field, long value, long maxValue, String additionalMsg) {
if (value < 0 || value > maxValue) {
throw new RuntimeException(field + " '" + value
+ "' is too big ( > "