[syslinux] extlinux: missing text on serial output

H. Peter Anvin hpa at zytor.com
Sun Jun 22 15:30:01 PDT 2008


Ferenc Wagner wrote:
> 
> Hi,
> 
> Seems like the end of the config file is mistreated.  getc invokes
> getfssec with file_bytesleft==0, which it doesn't check for but reads
> nevertheless, then underflows.  The following most ugly patch fixes it
> for me:
> 
> But maybe this check whould be better done by getc itself.  Or maybe
> it does, but the info is lost somewhere...  What's the concept of EOF
> handling?

First of all, *thank you* for looking into this.

Yes, this check should have been done by getc itself.

In the Syslinux core, when a file reaches EOF, getfssec will return with 
CF=1 and SI=0.  *At this point the file is considered closed*, so 
anything calling getfssec on a file where there is nothing left is doing 
something wrong.

Given that one of the *big* changes in 3.70 is that the file size is no 
longer considered known ahead of time (thus supporting http transfers 
and tftp transfers without tsize), it's fairly easy to see how this 
could have gone wrong or, more likely, triggered a bug somewhere.

It looks to me that current git is doing the right thing in getc:

    132                  mov si,[di+gc_file]
    133                  and si,si
    134                  mov [di+gc_bufbytes],si ; In case SI == 0
    135                  jz .empty
    136                  mov cx,bytes_per_getc >> SECTOR_SHIFT
    137                  call getfssec

The EOF indication that getc uses is thus SI=0.

So the most likely cause of failure would be if getfssec gets to the end 
of a file without returning CF=1, SI=0.  Now look at getfssec:

   1509  .noteof:        sub [si+file_bytesleft],ecx
   1510                  ; Did we run out of file?
   1511                  cmp dword [si+file_bytesleft],1
   1512                  ; CF set if [SI] < 1, i.e. == 0
   1513                  pop edi
   1514                  pop edx
   1515                  pop eax
   1516                  pop ebp
   1517                  ret

[si+file_bytesleft] == 0 actually means that the file is closed, because 
of how the file structures are managed in Extlinux, but SI is never set 
to zero.  The attached patch should fix that; if you could try it out I 
would hugely appreciate it.

	-hpa



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff
URL: <http://www.zytor.com/pipermail/syslinux/attachments/20080622/0ccaa136/attachment.ksh>


More information about the Syslinux mailing list