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);
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to