Module Name:    src
Committed By:   mhitch
Date:           Mon Jul 23 00:49:20 UTC 2012

Modified Files:
        src/sys/lib/libsa: cd9660.c

Log Message:
Fix cd9660_read() to not read past the end of the file.  This would result
in incorrect resid values, and causes the read of /boot.cfg to ignore the
file.  If the requested transfer extends past the end of the file, force
the internal buffer to be used, and when transferring data from the
internal buffer, limit the transfer to what's left in the file.  CDROM
boot will now process the /boot.cfg file.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libsa/cd9660.c
diff -u src/sys/lib/libsa/cd9660.c:1.28 src/sys/lib/libsa/cd9660.c:1.29
--- src/sys/lib/libsa/cd9660.c:1.28	Sun Dec 25 06:09:08 2011
+++ src/sys/lib/libsa/cd9660.c	Mon Jul 23 00:49:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.28 2011/12/25 06:09:08 tsutsui Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.29 2012/07/23 00:49:20 mhitch Exp $	*/
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -318,6 +318,7 @@ cd9660_read(struct open_file *f, void *s
 			break;
 		bno = fp->off / ISO_DEFAULT_BLOCK_SIZE + fp->bno;
 		if (fp->off & (ISO_DEFAULT_BLOCK_SIZE - 1)
+		    || (fp->off + ISO_DEFAULT_BLOCK_SIZE) > fp->size
 		    || size < ISO_DEFAULT_BLOCK_SIZE)
 			dp = buf;
 		else
@@ -336,6 +337,8 @@ cd9660_read(struct open_file *f, void *s
 			if (nread > off + size)
 				nread = off + size;
 			nread -= off;
+			if (nread > fp->size - fp->off)
+				nread = fp->size - fp->off;
 			memcpy(start, buf + off, nread);
 			start = (char *)start + nread;
 			fp->off += nread;

Reply via email to