aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-11 03:53:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-11 03:53:57 +0200
commitbfa1b2e8e8aaddcf849011a12cb2ac634b27f339 (patch)
tree4a5fbaef1371fb8b2ca504e753fa2a31d25234d4 /libbb
parent6334390aef2eb52cc827a6d18f942b2b8a04ef59 (diff)
downloadbusybox-w32-bfa1b2e8e8aaddcf849011a12cb2ac634b27f339.tar.gz
busybox-w32-bfa1b2e8e8aaddcf849011a12cb2ac634b27f339.tar.bz2
busybox-w32-bfa1b2e8e8aaddcf849011a12cb2ac634b27f339.zip
randomtest fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/read.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/libbb/read.c b/libbb/read.c
index 21e005c6f..f3af144f0 100644
--- a/libbb/read.c
+++ b/libbb/read.c
@@ -321,44 +321,45 @@ int FAST_FUNC setup_unzip_on_fd(int fd /*, int fail_if_not_detected*/)
321 /* .gz and .bz2 both have 2-byte signature, and their 321 /* .gz and .bz2 both have 2-byte signature, and their
322 * unpack_XXX_stream wants this header skipped. */ 322 * unpack_XXX_stream wants this header skipped. */
323 xread(fd, &magic, 2); 323 xread(fd, &magic, 2);
324#if ENABLE_FEATURE_SEAMLESS_GZ 324 if (ENABLE_FEATURE_SEAMLESS_GZ
325 && magic[0] == 0x1f && magic[1] == 0x8b
326 ) {
325# if BB_MMU 327# if BB_MMU
326 xformer = unpack_gz_stream; 328 xformer = unpack_gz_stream;
327# else 329# else
328 xformer_prog = "gunzip"; 330 xformer_prog = "gunzip";
329# endif 331# endif
330#endif 332 goto found_magic;
331 if (!ENABLE_FEATURE_SEAMLESS_GZ 333 }
332 || magic[0] != 0x1f || magic[1] != 0x8b 334 if (ENABLE_FEATURE_SEAMLESS_BZ2
335 && magic[0] == 'B' && magic[1] == 'Z'
333 ) { 336 ) {
334 if (!ENABLE_FEATURE_SEAMLESS_BZ2 337# if BB_MMU
335 || magic[0] != 'B' || magic[1] != 'Z' 338 xformer = unpack_bz2_stream;
336 ) { 339# else
337 340 xformer_prog = "bunzip2";
341# endif
342 goto found_magic;
343 }
338// TODO: xz format support. rpm adopted it, "rpm -i FILE.rpm" badly needs this. 344// TODO: xz format support. rpm adopted it, "rpm -i FILE.rpm" badly needs this.
339// Signature: 0xFD, '7', 'z', 'X', 'Z', 0x00 345// Signature: 0xFD, '7', 'z', 'X', 'Z', 0x00
340// More info at: http://tukaani.org/xz/xz-file-format.txt 346// More info at: http://tukaani.org/xz/xz-file-format.txt
341 347
342 if (fail_if_not_detected) 348 /* No known magic seen */
343 bb_error_msg_and_die("no gzip" 349 if (fail_if_not_detected)
344 IF_FEATURE_SEAMLESS_BZ2("/bzip2") 350 bb_error_msg_and_die("no gzip"
345 " magic"); 351 IF_FEATURE_SEAMLESS_BZ2("/bzip2")
346 xlseek(fd, -2, SEEK_CUR); 352 " magic");
347 return fd; 353 xlseek(fd, -2, SEEK_CUR);
348 } 354 return fd;
349#if BB_MMU 355
350 xformer = unpack_bz2_stream; 356 found_magic:
351#else 357# if !BB_MMU
352 xformer_prog = "bunzip2"; 358 /* NOMMU version of open_transformer execs
353#endif 359 * an external unzipper that wants
354 } else { 360 * file position at the start of the file */
355#if !BB_MMU 361 xlseek(fd, -2, SEEK_CUR);
356 /* NOMMU version of open_transformer execs 362# endif
357 * an external unzipper that wants
358 * file position at the start of the file */
359 xlseek(fd, -2, SEEK_CUR);
360#endif
361 }
362 open_transformer(fd, xformer, xformer_prog); 363 open_transformer(fd, xformer, xformer_prog);
363 364
364 return fd; 365 return fd;