svn commit: trunk/busybox/archival: libunarchive

vda at busybox.net vda at busybox.net
Sat Nov 25 23:47:32 UTC 2006


Author: vda
Date: 2006-11-25 15:47:32 -0800 (Sat, 25 Nov 2006)
New Revision: 16668

Log:
tar: small fix and small optimization


Modified:
   trunk/busybox/archival/libunarchive/get_header_tar.c
   trunk/busybox/archival/tar.c


Changeset:
Modified: trunk/busybox/archival/libunarchive/get_header_tar.c
===================================================================
--- trunk/busybox/archival/libunarchive/get_header_tar.c	2006-11-25 14:49:04 UTC (rev 16667)
+++ trunk/busybox/archival/libunarchive/get_header_tar.c	2006-11-25 23:47:32 UTC (rev 16668)
@@ -152,9 +152,11 @@
 	if (!longname && parse_names) {
 		/* we trash mode[0] here, it's ok */
 		tar.name[sizeof(tar.name)] = '\0';
-		if (tar.prefix[0])
+		if (tar.prefix[0]) {
+			/* and padding[0] */
+			tar.prefix[sizeof(tar.prefix)] = '\0';
 			file_header->name = concat_path_file(tar.prefix, tar.name);
-		else
+		} else
 			file_header->name = xstrdup(tar.name);
 	}
 

Modified: trunk/busybox/archival/tar.c
===================================================================
--- trunk/busybox/archival/tar.c	2006-11-25 14:49:04 UTC (rev 16667)
+++ trunk/busybox/archival/tar.c	2006-11-25 23:47:32 UTC (rev 16668)
@@ -150,9 +150,8 @@
 
 /* Put an octal string into the specified buffer.
  * The number is zero padded and possibly null terminated.
- * Stores low-order bits only if whole value does not fit.
- * Returns FALSE if that happens.  */
-static int putOctal(char *cp, int len, off_t value)
+ * Stores low-order bits only if whole value does not fit. */
+static void putOctal(char *cp, int len, off_t value)
 {
 	char tempBuffer[sizeof(off_t)*3+1];
 	char *tempString = tempBuffer;
@@ -169,10 +168,6 @@
 
 	/* Copy the string to the field */
 	memcpy(cp, tempString, len);
-
-	/* If after shift we have zero - value did not overflow, */
-	/* return 1 (TRUE) then */
-	return (value >> (len*3)) == 0;
 }
 
 /* Write out a tar header for the specified file/directory/whatever */
@@ -239,14 +234,15 @@
 	} else if (S_ISFIFO(statbuf->st_mode)) {
 		header.typeflag = FIFOTYPE;
 	} else if (S_ISREG(statbuf->st_mode)) {
-		header.typeflag = REGTYPE;
-		if ((PUT_OCTAL(header.size, statbuf->st_size) == FALSE)
-		 && sizeof(statbuf->st_size) > 4
+		if (sizeof(statbuf->st_size) > 4
+		 && statbuf->st_size > (off_t)0777777777777LL
 		) {
 			bb_error_msg_and_die("cannot store file '%s' "
 				"of size %"OFF_FMT"d, aborting",
 				fileName, statbuf->st_size);
 		}
+		header.typeflag = REGTYPE;
+		PUT_OCTAL(header.size, statbuf->st_size);
 	} else {
 		bb_error_msg("%s: unknown file type", fileName);
 		return FALSE;




More information about the busybox-cvs mailing list