Re: [PATCH 3/7] inflate pt1: clean up input logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 24, 2006 at 02:12:16PM -0600, Matt Mackall wrote:
> -static const u16 mask_bits[] = {
> -	0x0000,
> -	0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
> -	0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
> -};
> +static inline u32 readbits(u32 *b, u32 *k, int n)
> +{
> +	for( ; *k < n; *k += 8)
> +		*b |= (u32)get_byte() << *k;
> +	return *b & ((1 << n) - 1);
> +}
>  
> -#define NEXTBYTE()  ({ int v = get_byte(); if (v < 0) goto underrun; (u8)v; })

How does this change handle the case where we run out of input data?
This condition needs to be handled explicitly because the inflate
functions can infinitely loop.

Relying on a bit pattern returned by get_byte() is how this code
pre-fix used to work, and it caused several confused bug reports.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux