Пример #1
0
/**
* @attention 本注释得到了"核高基"科技重大专项2012年课题“开源操作系统内核分析和安全性评估
*(课题编号:2012ZX01039-004)”的资助。
*
* @copyright 注释添加单位:清华大学——03任务(Linux内核相关通用基础软件包分析)承担单位
*
* @author 注释添加人员:谢文学
*
* @date 注释添加日期:2013年5月10日
*
* @note 注释详细内容:
* 
* 本函数实现gunzip的解压缩数据块的功能。
*/
static void
inflate_window (void)
{
  /* initialize window */
  wp = 0;

  /*
   *  Main decompression loop.
   */

  while (wp < WSIZE && !errnum)
    {
      if (!block_len)
	{
	  if (last_block)
	    break;

	  get_new_block ();
	}

      if (block_type > INFLATE_DYNAMIC)
	errnum = ERR_BAD_GZIP_DATA;

      if (errnum)
	return;

      /*
       *  Expand stored block here.
       */
      if (block_type == INFLATE_STORED)
	{
	  int w = wp;

	  /*
	   *  This is basically a glorified pass-through
	   */

	  while (block_len && w < WSIZE && !errnum)
	    {
	      slide[w++] = get_byte ();
	      block_len--;
	    }

	  wp = w;

	  continue;
	}

      /*
       *  Expand other kind of block.
       */

      if (inflate_codes_in_window ())
	reset_linalloc ();
    }

  saved_filepos += WSIZE;

  /* XXX do CRC calculation here! */
}
Пример #2
0
static void
inflate_window (grub_file_t file)
{
  grub_gzio_t gzio = file->data;

  /* initialize window */
  gzio->wp = 0;

  /*
   *  Main decompression loop.
   */

  while (gzio->wp < WSIZE && grub_errno == GRUB_ERR_NONE)
    {
      if (! gzio->block_len)
	{
	  if (gzio->last_block)
	    break;

	  get_new_block (file);
	}

      if (gzio->block_type > INFLATE_DYNAMIC)
	grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
		    "unknown block type %d", gzio->block_type);

      if (grub_errno != GRUB_ERR_NONE)
	return;

      /*
       *  Expand stored block here.
       */
      if (gzio->block_type == INFLATE_STORED)
	{
	  int w = gzio->wp;

	  /*
	   *  This is basically a glorified pass-through
	   */

	  while (gzio->block_len && w < WSIZE && grub_errno == GRUB_ERR_NONE)
	    {
	      gzio->slide[w++] = get_byte (file);
	      gzio->block_len--;
	    }

	  gzio->wp = w;

	  continue;
	}

      /*
       *  Expand other kind of block.
       */

      if (inflate_codes_in_window (file))
	{
	  huft_free (gzio->tl);
	  huft_free (gzio->td);
	  gzio->tl = 0;
	  gzio->td = 0;
	}
    }

  gzio->saved_offset += WSIZE;

  /* XXX do CRC calculation here! */
}