[PATCH] dhcpc.c: fix found_opts
Denys Vlasenko
vda.linux at googlemail.com
Tue Oct 11 15:33:58 UTC 2011
2011/10/11 Lambrecht Jürgen <J.Lambrecht at televic.com>:
> Hello,
>
> The patch below fixes a bug in networking/udhcp/dhcpc.c. Here my reasoning:
> There are 256 dhcp options supported, so 256 bits to store.
> You want to store that in an unsigned (BITMAP define), 32b in my case.
> So you need an unsigned array of 256/sizeoff(unsigned) == 8 elements.
sizeof(unsigned) is 4, because sizeof() measures size in bytes, not bits.
256/4 = 64.
> In
> the code, the define BBITS is used for this, and the bug is that *8 is
> added to that define, resulting in an array of only 1 element (32b) to
> store 256 bits.
I disassembled this:
memset(found_opts, 0, sizeof(found_opts));
and I see that this memset fills 8 words, not 1 word:
f: b9 08 00 00 00 mov $0x8,%ecx
14: 31 c0 xor %eax,%eax
16: f3 ab rep stos %eax,%es:(%edi)
--
vda
More information about the busybox
mailing list