From 546f8cfeca6fca0b6b246c8dbf035027e3f15f8c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 11 Sep 2021 12:26:35 +0000 Subject: [PATCH] 9boot: fix isowalk() for directories spanning multiple sectors directory entries cannot span sector boundaries, meaning that the end of a sector would be zero padded until the next sector. we have to skip over these zero paddings to fully read the directory. --- sys/src/boot/efi/iso.c | 12 ++++++++---- sys/src/boot/pc/iso.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sys/src/boot/efi/iso.c b/sys/src/boot/efi/iso.c index 74e414a19..6a878667b 100644 --- a/sys/src/boot/efi/iso.c +++ b/sys/src/boot/efi/iso.c @@ -129,15 +129,19 @@ Foundpvd: return 0; for(;;){ - if(readn(ex, &d, Dirsz) != Dirsz) + if(read(ex, &d.dirlen, 1) != 1) break; if(d.dirlen == 0) + continue; /* zero padding to next sector */ + if(read(ex, &d.dirlen + 1, Dirsz-1) != Dirsz-1) break; - if(readn(ex, name, d.namelen) != d.namelen) + if(read(ex, name, d.namelen) != d.namelen) break; i = d.dirlen - (Dirsz + d.namelen); - while(i-- > 0) - read(ex, &c, 1); + while(i-- > 0){ + if(read(ex, &c, 1) != 1) + break; + } for(i=0; i= 'A' && c <= 'Z'){ diff --git a/sys/src/boot/pc/iso.c b/sys/src/boot/pc/iso.c index e6a483902..d43ad4231 100644 --- a/sys/src/boot/pc/iso.c +++ b/sys/src/boot/pc/iso.c @@ -111,15 +111,19 @@ isowalk(Extend *ex, int drive, char *path) ex->len = *((ulong*)(ex->buf + 156 + 10)); for(;;){ - if(readn(ex, &d, Dirsz) != Dirsz) + if(read(ex, &d.dirlen, 1) != 1) break; if(d.dirlen == 0) + continue; /* zero padding to next sector */ + if(read(ex, &d.dirlen + 1, Dirsz-1) != Dirsz-1) break; - if(readn(ex, name, d.namelen) != d.namelen) + if(read(ex, name, d.namelen) != d.namelen) break; i = d.dirlen - (Dirsz + d.namelen); - while(i-- > 0) - read(ex, &c, 1); + while(i-- > 0){ + if(read(ex, &c, 1) != 1) + break; + } for(i=0; i= 'A' && c <= 'Z'){