Kang Kai
2014-May-13 01:26 UTC
[syslinux] [PATCH] isohybrid: fix overflow on 32 bit system
On 2014?05?12? 22:38, H. Peter Anvin wrote:> That is because it needs to use fseeko() and use off_t.Do you mean it does need a patch for isohybrid.c. And the patch looks like: #if _FILE_OFFSET_BITS == 64 fseeko(...) #else fseek(...) Regards, Kai> > On May 11, 2014 11:53:17 PM PDT, Kang Kai <Kai.Kang at windriver.com> wrote: >> On 2014?05?12? 10:49, H. Peter Anvin wrote: >>> On 05/11/2014 06:56 PM, Kai Kang wrote: >>>> When call isohybrid with option '-u', it overflows on a 32 bits >> host. It >>>> seeks to 512 bytes before the end of the image to install gpt >> header. If >>>> the size of image is larger than LONG_MAX, it overflows fseek() and >>>> cause error: >>>> >>>> isohybrid: wrlinux-image-x86-64-20140505110100.iso: seek error - 8: >> Invalid argument >>>> Check the offset and call fseek() multi-times if offset is too >> large. >>>> Signed-off-by: Kai Kang <kai.kang at windriver.com> >>> NAK. >>> >>> The right thing to do is compile it with #define _FILE_OFFSET_BITS 64 >>> and change fseek to fseeko with the appropriate type being off_t. >>> >>> -hpa >> Hi hpa, >> >> Thanks for your reply. >> >> In utils/Makefile, -D_FILE_OFFSET_BITS=64 is added to CFLAGS. isohybrid >> >> is compiled with -D_FILE_OFFSET_BITS=64 but it still fails to handle >> the >> large offset. >> >> make[3]: Entering directory >> `/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/bios/utils' >> gcc >> -isystem/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/sysroots/i686-linux/usr/include >> >> -O2 -pipe -Wp,-MT,isohybrid.o,-MMD,./.isohybrid.o.d -W -Wall >> -Wstrict-prototypes -Os -fomit-frame-pointer *-D_FILE_OFFSET_BITS=64* >> -I/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/utils >> >> -c -o isohybrid.o >> /home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/utils/isohybrid.c >> >> I build it on RedHat Enterprise Linux 6.2 with glibc 2.12. >> >> Regards, >> Kai >>-- Regards, Neil | Kai Kang
H. Peter Anvin
2014-May-13 01:29 UTC
[syslinux] [PATCH] isohybrid: fix overflow on 32 bit system
No #if. On May 12, 2014 6:26:18 PM PDT, Kang Kai <Kai.Kang at windriver.com> wrote:>On 2014?05?12? 22:38, H. Peter Anvin wrote: >> That is because it needs to use fseeko() and use off_t. > >Do you mean it does need a patch for isohybrid.c. And the patch looks >like: > >#if _FILE_OFFSET_BITS == 64 > fseeko(...) >#else > fseek(...) > > >Regards, >Kai > >> >> On May 11, 2014 11:53:17 PM PDT, Kang Kai <Kai.Kang at windriver.com> >wrote: >>> On 2014?05?12? 10:49, H. Peter Anvin wrote: >>>> On 05/11/2014 06:56 PM, Kai Kang wrote: >>>>> When call isohybrid with option '-u', it overflows on a 32 bits >>> host. It >>>>> seeks to 512 bytes before the end of the image to install gpt >>> header. If >>>>> the size of image is larger than LONG_MAX, it overflows fseek() >and >>>>> cause error: >>>>> >>>>> isohybrid: wrlinux-image-x86-64-20140505110100.iso: seek error - >8: >>> Invalid argument >>>>> Check the offset and call fseek() multi-times if offset is too >>> large. >>>>> Signed-off-by: Kai Kang <kai.kang at windriver.com> >>>> NAK. >>>> >>>> The right thing to do is compile it with #define _FILE_OFFSET_BITS >64 >>>> and change fseek to fseeko with the appropriate type being off_t. >>>> >>>> -hpa >>> Hi hpa, >>> >>> Thanks for your reply. >>> >>> In utils/Makefile, -D_FILE_OFFSET_BITS=64 is added to CFLAGS. >isohybrid >>> >>> is compiled with -D_FILE_OFFSET_BITS=64 but it still fails to handle >>> the >>> large offset. >>> >>> make[3]: Entering directory >>> >`/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/bios/utils' >>> gcc >>> >-isystem/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/sysroots/i686-linux/usr/include >>> >>> -O2 -pipe -Wp,-MT,isohybrid.o,-MMD,./.isohybrid.o.d -W -Wall >>> -Wstrict-prototypes -Os -fomit-frame-pointer >*-D_FILE_OFFSET_BITS=64* >>> >-I/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/utils >>> >>> -c -o isohybrid.o >>> >/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/utils/isohybrid.c >>> >>> I build it on RedHat Enterprise Linux 6.2 with glibc 2.12. >>> >>> Regards, >>> Kai >>>-- Sent from my mobile phone. Please pardon brevity and lack of formatting.
Kang Kai
2014-May-13 01:32 UTC
[syslinux] [PATCH] isohybrid: fix overflow on 32 bit system
On 2014?05?13? 09:29, H. Peter Anvin wrote:> No #if.OK. I'll send V2. Thanks, Kai> > On May 12, 2014 6:26:18 PM PDT, Kang Kai <Kai.Kang at windriver.com> wrote: >> On 2014?05?12? 22:38, H. Peter Anvin wrote: >>> That is because it needs to use fseeko() and use off_t. >> Do you mean it does need a patch for isohybrid.c. And the patch looks >> like: >> >> #if _FILE_OFFSET_BITS == 64 >> fseeko(...) >> #else >> fseek(...) >> >> >> Regards, >> Kai >> >>> On May 11, 2014 11:53:17 PM PDT, Kang Kai <Kai.Kang at windriver.com> >> wrote: >>>> On 2014?05?12? 10:49, H. Peter Anvin wrote: >>>>> On 05/11/2014 06:56 PM, Kai Kang wrote: >>>>>> When call isohybrid with option '-u', it overflows on a 32 bits >>>> host. It >>>>>> seeks to 512 bytes before the end of the image to install gpt >>>> header. If >>>>>> the size of image is larger than LONG_MAX, it overflows fseek() >> and >>>>>> cause error: >>>>>> >>>>>> isohybrid: wrlinux-image-x86-64-20140505110100.iso: seek error - >> 8: >>>> Invalid argument >>>>>> Check the offset and call fseek() multi-times if offset is too >>>> large. >>>>>> Signed-off-by: Kai Kang <kai.kang at windriver.com> >>>>> NAK. >>>>> >>>>> The right thing to do is compile it with #define _FILE_OFFSET_BITS >> 64 >>>>> and change fseek to fseeko with the appropriate type being off_t. >>>>> >>>>> -hpa >>>> Hi hpa, >>>> >>>> Thanks for your reply. >>>> >>>> In utils/Makefile, -D_FILE_OFFSET_BITS=64 is added to CFLAGS. >> isohybrid >>>> is compiled with -D_FILE_OFFSET_BITS=64 but it still fails to handle >>>> the >>>> large offset. >>>> >>>> make[3]: Entering directory >>>> >> `/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/bios/utils' >>>> gcc >>>> >> -isystem/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/sysroots/i686-linux/usr/include >>>> -O2 -pipe -Wp,-MT,isohybrid.o,-MMD,./.isohybrid.o.d -W -Wall >>>> -Wstrict-prototypes -Os -fomit-frame-pointer >> *-D_FILE_OFFSET_BITS=64* >> -I/home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/utils >>>> -c -o isohybrid.o >>>> >> /home/neil/wrlinux/builds/install-x86-64/bitbake_build/tmp/work/i686-linux/syslinux-native/6.01-r0/syslinux-6.01/utils/isohybrid.c >>>> I build it on RedHat Enterprise Linux 6.2 with glibc 2.12. >>>> >>>> Regards, >>>> Kai >>>>-- Regards, Neil | Kai Kang