diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-25 23:47:32 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-25 23:47:32 +0000 |
commit | 87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010 (patch) | |
tree | ba572c8880643df14a9803c30fd710ec8f9feedf /archival/tar.c | |
parent | 43bddf31e95080abf7232952da9064207636f47b (diff) | |
download | busybox-w32-87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010.tar.gz busybox-w32-87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010.tar.bz2 busybox-w32-87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010.zip |
tar: small fix and small optimization
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 16 |
1 files changed, 6 insertions, 10 deletions
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. */ | 154 | static void putOctal(char *cp, int len, off_t value) |
155 | static 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; |