shithub: plan9front

Download patch

ref: 546f8cfeca6fca0b6b246c8dbf035027e3f15f8c
parent: e2796993445b62379e908564e900e6955b30b830
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Sep 11 08:26:35 EDT 2021

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.

--- a/sys/src/boot/efi/iso.c	Fri Sep 10 17:03:47 2021
+++ b/sys/src/boot/efi/iso.c	Sat Sep 11 08:26:35 2021
@@ -129,15 +129,19 @@
 		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<d.namelen; i++){
 			c = name[i];
 			if(c >= 'A' && c <= 'Z'){
--- a/sys/src/boot/pc/iso.c	Fri Sep 10 17:03:47 2021
+++ b/sys/src/boot/pc/iso.c	Sat Sep 11 08:26:35 2021
@@ -111,15 +111,19 @@
 	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<d.namelen; i++){
 			c = name[i];
 			if(c >= 'A' && c <= 'Z'){