svn commit: r264302 - head/usr.sbin/bhyve

Tycho Nightingale tychon at FreeBSD.org
Wed Apr 9 14:50:55 UTC 2014


Author: tychon
Date: Wed Apr  9 14:50:55 2014
New Revision: 264302
URL: http://svnweb.freebsd.org/changeset/base/264302

Log:
  Constrain the amount of data returned to what is actually available
  not the size of the buffer.
  
  Approved by:	grehan (co-mentor)

Modified:
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- head/usr.sbin/bhyve/pci_ahci.c	Wed Apr  9 13:35:52 2014	(r264301)
+++ head/usr.sbin/bhyve/pci_ahci.c	Wed Apr  9 14:50:55 2014	(r264302)
@@ -543,12 +543,14 @@ write_prdt(struct ahci_port *p, int slot
 	for (i = 0; i < hdr->prdtl && len; i++) {
 		uint8_t *ptr;
 		uint32_t dbcsz;
+		int sublen;
 
 		dbcsz = (prdt->dbc & DBCMASK) + 1;
 		ptr = paddr_guest2host(ahci_ctx(p->pr_sc), prdt->dba, dbcsz);
-		memcpy(ptr, from, dbcsz);
-		len -= dbcsz;
-		from += dbcsz;
+		sublen = len < dbcsz ? len : dbcsz;
+		memcpy(ptr, from, sublen);
+		len -= sublen;
+		from += sublen;
 		prdt++;
 	}
 	hdr->prdbc = size - len;


More information about the svn-src-head mailing list