Ejemplo n.º 1
0
static char FAST_FUNC get_header_tar_Z(archive_handle_t *archive_handle)
{
	/* Can't lseek over pipes */
	archive_handle->seek = seek_by_read;

	/* do the decompression, and cleanup */
	if (xread_char(archive_handle->src_fd) != 0x1f
	 || xread_char(archive_handle->src_fd) != 0x9d
	) {
		bb_error_msg_and_die("invalid magic");
	}

	open_transformer(archive_handle->src_fd, unpack_Z_stream, "uncompress");
	archive_handle->offset = 0;
	while (get_header_tar(archive_handle) == EXIT_SUCCESS)
		continue;

	/* Can only do one file at a time */
	return EXIT_FAILURE;
}
Ejemplo n.º 2
0
void check_header_gzip(int src_fd)
{
    union {
        unsigned char raw[8];
        struct {
            unsigned char method;
            unsigned char flags;
            unsigned int mtime;
            unsigned char xtra_flags;
            unsigned char os_flags;
        } formatted;
    } header;

    xread(src_fd, header.raw, 8);

    /* Check the compression method */
    if (header.formatted.method != 8)
/*        error_die("Unknown compression method %d", header.formatted.method);*/
        error_die("Unknown compression method");

    if (header.formatted.flags & 0x04)
    {
        /* bit 2 set: extra field present */
        unsigned char extra_short;

        extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
        while (extra_short > 0)
        {
            /* Ignore extra field */
            xread_char(src_fd);
            extra_short--;
        }
    }

    /* Discard original name if any */
    if (header.formatted.flags & 0x08)
        /* bit 3 set: original file name present */
        while(xread_char(src_fd) != 0) ;

    /* Discard file comment if any */
    if (header.formatted.flags & 0x10)
        /* bit 4 set: file comment present */
        while(xread_char(src_fd) != 0) ;

    /* Read the header checksum */
    if (header.formatted.flags & 0x02)
    {
        xread_char(src_fd);
        xread_char(src_fd);
    }
}