Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jan 2011 21:38:03 +0000 (UTC)
From:      Andreas Tobler <andreast@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r217027 - head/sys/powerpc/ofw
Message-ID:  <201101052138.p05Lc3e2091822@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andreast
Date: Wed Jan  5 21:38:02 2011
New Revision: 217027
URL: http://svn.freebsd.org/changeset/base/217027

Log:
  Fix null string handling in ofw_real_nextprop function. Pass the right
  length to ofw_real_map in case of a null string.
  This makes ofwdump(8) work correctly when trying to print all properties
  with ofwdump -p.
  
  Approved by:	nwhitehorn (mentor)

Modified:
  head/sys/powerpc/ofw/ofw_real.c

Modified: head/sys/powerpc/ofw/ofw_real.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_real.c	Wed Jan  5 21:23:26 2011	(r217026)
+++ head/sys/powerpc/ofw/ofw_real.c	Wed Jan  5 21:38:02 2011	(r217027)
@@ -266,7 +266,11 @@ ofw_real_map(const void *buf, size_t len
 		return 0;
 	}
 
-	memcpy(of_bounce_virt + of_bounce_offset, buf, len);
+	if (buf != NULL)
+		memcpy(of_bounce_virt + of_bounce_offset, buf, len);
+	else
+		return (0);
+
 	phys = of_bounce_phys + of_bounce_offset;
 
 	of_bounce_offset += len;
@@ -282,6 +286,9 @@ ofw_real_unmap(cell_t physaddr, void *bu
 	if (of_bounce_virt == NULL)
 		return;
 
+	if (physaddr == 0)
+		return;
+
 	memcpy(buf,of_bounce_virt + (physaddr - of_bounce_phys),len);
 }
 
@@ -546,11 +553,10 @@ ofw_real_nextprop(ofw_t ofw, phandle_t p
 	ofw_real_start();
 
 	args.package = package;
-	args.previous = ofw_real_map(previous, strlen(previous) + 1);
+	args.previous = ofw_real_map(previous, (previous != NULL) ? (strlen(previous) + 1) : 0);
 	args.buf = ofw_real_map(buf, size);
 	argsptr = ofw_real_map(&args, sizeof(args));
-	if (args.previous == 0 || args.buf == 0 ||
-	    openfirmware((void *)argsptr) == -1) {
+	if (args.buf == 0 || openfirmware((void *)argsptr) == -1) {
 		ofw_real_stop();
 		return (-1);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101052138.p05Lc3e2091822>