aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-11-25 23:47:32 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-11-25 23:47:32 +0000
commit4250ba3f536c66fa7caeb4e2a7110e69f69925de (patch)
treeba572c8880643df14a9803c30fd710ec8f9feedf
parent6e9494a9770cc90bda5da0025c96b29805fa6e88 (diff)
downloadbusybox-w32-4250ba3f536c66fa7caeb4e2a7110e69f69925de.tar.gz
busybox-w32-4250ba3f536c66fa7caeb4e2a7110e69f69925de.tar.bz2
busybox-w32-4250ba3f536c66fa7caeb4e2a7110e69f69925de.zip
tar: small fix and small optimization
git-svn-id: svn://busybox.net/trunk/busybox@16668 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--archival/libunarchive/get_header_tar.c6
-rw-r--r--archival/tar.c16
2 files changed, 10 insertions, 12 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index a49081f40..b785d631d 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -152,9 +152,11 @@ char get_header_tar(archive_handle_t *archive_handle)
152 if (!longname && parse_names) { 152 if (!longname && parse_names) {
153 /* we trash mode[0] here, it's ok */ 153 /* we trash mode[0] here, it's ok */
154 tar.name[sizeof(tar.name)] = '\0'; 154 tar.name[sizeof(tar.name)] = '\0';
155 if (tar.prefix[0]) 155 if (tar.prefix[0]) {
156 /* and padding[0] */
157 tar.prefix[sizeof(tar.prefix)] = '\0';
156 file_header->name = concat_path_file(tar.prefix, tar.name); 158 file_header->name = concat_path_file(tar.prefix, tar.name);
157 else 159 } else
158 file_header->name = xstrdup(tar.name); 160 file_header->name = xstrdup(tar.name);
159 } 161 }
160 162
diff --git a/archival/tar.c b/archival/tar.c
index d875805b0..c870d53c2 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -150,9 +150,8 @@ static HardLinkInfo *findHardLinkInfo(HardLinkInfo * hlInfo, struct stat *statbu
150 150
151/* Put an octal string into the specified buffer. 151/* Put an octal string into the specified buffer.
152 * The number is zero padded and possibly null terminated. 152 * The number is zero padded and possibly null terminated.
153 * Stores low-order bits only if whole value does not fit. 153 * Stores low-order bits only if whole value does not fit. */
154 * Returns FALSE if that happens. */ 154static void putOctal(char *cp, int len, off_t value)
155static int putOctal(char *cp, int len, off_t value)
156{ 155{
157 char tempBuffer[sizeof(off_t)*3+1]; 156 char tempBuffer[sizeof(off_t)*3+1];
158 char *tempString = tempBuffer; 157 char *tempString = tempBuffer;
@@ -169,10 +168,6 @@ static int putOctal(char *cp, int len, off_t value)
169 168
170 /* Copy the string to the field */ 169 /* Copy the string to the field */
171 memcpy(cp, tempString, len); 170 memcpy(cp, tempString, len);
172
173 /* If after shift we have zero - value did not overflow, */
174 /* return 1 (TRUE) then */
175 return (value >> (len*3)) == 0;
176} 171}
177 172
178/* Write out a tar header for the specified file/directory/whatever */ 173/* Write out a tar header for the specified file/directory/whatever */
@@ -239,14 +234,15 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
239 } else if (S_ISFIFO(statbuf->st_mode)) { 234 } else if (S_ISFIFO(statbuf->st_mode)) {
240 header.typeflag = FIFOTYPE; 235 header.typeflag = FIFOTYPE;
241 } else if (S_ISREG(statbuf->st_mode)) { 236 } else if (S_ISREG(statbuf->st_mode)) {
242 header.typeflag = REGTYPE; 237 if (sizeof(statbuf->st_size) > 4
243 if ((PUT_OCTAL(header.size, statbuf->st_size) == FALSE) 238 && statbuf->st_size > (off_t)0777777777777LL
244 && sizeof(statbuf->st_size) > 4
245 ) { 239 ) {
246 bb_error_msg_and_die("cannot store file '%s' " 240 bb_error_msg_and_die("cannot store file '%s' "
247 "of size %"OFF_FMT"d, aborting", 241 "of size %"OFF_FMT"d, aborting",
248 fileName, statbuf->st_size); 242 fileName, statbuf->st_size);
249 } 243 }
244 header.typeflag = REGTYPE;
245 PUT_OCTAL(header.size, statbuf->st_size);
250 } else { 246 } else {
251 bb_error_msg("%s: unknown file type", fileName); 247 bb_error_msg("%s: unknown file type", fileName);
252 return FALSE; 248 return FALSE;