diff options
author | andreast <andreast@FreeBSD.org> | 2011-01-05 21:38:02 +0000 |
---|---|---|
committer | andreast <andreast@FreeBSD.org> | 2011-01-05 21:38:02 +0000 |
commit | caa5bbfa02a8836700c177bb93d1146f3c5314b7 (patch) | |
tree | 7f09d992a275d3bbec23229c669822a35cd29cde | |
parent | a7e43fe5f9923142d069bb3decfd9e8ee2799cc4 (diff) | |
download | FreeBSD-src-caa5bbfa02a8836700c177bb93d1146f3c5314b7.zip FreeBSD-src-caa5bbfa02a8836700c177bb93d1146f3c5314b7.tar.gz |
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)
-rw-r--r-- | sys/powerpc/ofw/ofw_real.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/powerpc/ofw/ofw_real.c b/sys/powerpc/ofw/ofw_real.c index 963e96c..617f9be 100644 --- a/sys/powerpc/ofw/ofw_real.c +++ b/sys/powerpc/ofw/ofw_real.c @@ -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 *buf, size_t len) 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 package, const char *previous, 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); } |