예제 #1
0
파일: 20100423-2_1.c 프로젝트: 0day-ci/gcc
int get_method(int in)
{
  char magic[2];
  if (force && to_stdout)
    magic[0] = (char)(inptr < insize ? inbuf[inptr++] : fill_inbuf(1));
  else
    magic[1] = (char)(inptr < insize ? inbuf[inptr++] : fill_inbuf(0));
}
예제 #2
0
파일: misc_lzma.c 프로젝트: janfj/dd-wrt
static int lzma_unzip(void)
{

    unsigned int i;
    unsigned char *workspace;
    unsigned int lc, lp, pb;
    if (inptr >= insize)
        fill_inbuf();

    // lzma args
    i = get_byte();
    lc = i % 9, i = i / 9;
    lp = i % 5, pb = i / 5;

    // skip dictionary size
    for (i = 0; i < 4; i++)
        get_byte();
    // get uncompressed size
    int a, b, c, d;
    a = get_byte();
    b = get_byte();
    c = get_byte();
    d = get_byte();
    uncompressedSize = (a) + (b << 8) + (c << 16) + (d << 24);
    if (uncompressedSize > 0x400000 || lc > 3 || pb > 3 || lp > 3) {
        if (disaster) {
            error
            ("\ndata corrupted in recovery RedBoot too, this is a disaster condition. please re-jtag\n");
        }
        disaster = 1;
        puts("\ndata corrupted!\nswitching to recovery RedBoot\nloading");
        inbuf = input_data;
        insize = &input_data_end[0] - &input_data[0];
        inptr = 0;
        output_data = (uch *) 0x80000400;
        bootoffset = 0x800004bc;
        return lzma_unzip();

    }
    workspace = output_data + uncompressedSize;
    // skip high order bytes
    for (i = 0; i < 4; i++)
        get_byte();
    // decompress kernel
    if (LzmaDecode
            (workspace, ~0, lc, lp, pb, (unsigned char *)output_data,
             uncompressedSize, &i) == LZMA_RESULT_OK) {
        if (i != uncompressedSize) {
            if (disaster) {
                error
                ("data corrupted in recovery RedBoot too, this is a disaster condition. please re-jtag\n");
            }
            disaster = 1;
            puts("\ndata corrupted!\nswitching to recovery RedBoot\nloading");
            inbuf = input_data;
            insize = &input_data_end[0] - &input_data[0];
            inptr = 0;
            output_data = (uch *) 0x80000400;
            bootoffset = 0x800004bc;
            return lzma_unzip();
        }
        //copy it back to low_buffer
        bytes_out = i;
        output_ptr = i;
        return 0;
    }
    return 1;
}