[BusyBox] fdisk && attempt to access beyond end of device?

Vladimir N. Oleynik dzo at simtreas.ru
Fri Dec 19 08:33:19 UTC 2003


Pete,

>>> Okay, I've reproduced this on busybox 1.00-pre4, and it appears to be 
>>> an issue with Busybox fdisk.
>>
>>
>> Have you problem with busybox fdisk variant from 1.00-pre2?
> 
> 
> Sorry, haven't tried it with that.
> 
>> If not, then please try witch this changes:
>>
>> retval = syscall(__NR__llseek, f_d, ((unsigned long long) offset) >> 32,
>>         ((unsigned long long) offset) & 0xffffffff,
>>
>> to
>>
>> retval = syscall(__NR__llseek, f_d, (unsigned long)(((unsigned long 
>> long) offset) >> 32),
>>         (unsigned long)(((unsigned long long) offset) & 0xffffffff),
>>
>> This is idea only.
> 
> 
> Well, it seems to work.  Here's stock pre4 busybox:
> 
>> [root at denis busybox-1.00-pre4]# ./busybox-pre4 fdisk /dev/hdd
>> Unable to seek on /dev/hdd
>> [root at denis busybox-1.00-pre4]# 
> 
> 
> Fails as I've noted.  Here's the exact same build with just your fix:
> 
>> [root at denis busybox-1.00-pre4]# ./busybox fdisk /dev/hdd
> Works as expected!

Thanks for testing.
Erik, please back to your fdisk patch revison 1.13 or apply changes from this 
letter.

> So, GCC was passing the syscall args as (unsigned long longs), which was 
> probably causing problems, despite the shift/mask.  Casting back to 
> (unsigned longs) fixes the problem.   Interesting...

No. Its C standart: syscall() have declare as int only first argument: number 
syscall.
Other arguments may have any type and undeclared.
If argument is undeclared, any C compiler make type from first type 
variable/constant of expresion.


--w
vodz




More information about the busybox mailing list