From owner-svn-src-head@FreeBSD.ORG Wed Jan 5 21:38:03 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FA0F1065781; Wed, 5 Jan 2011 21:38:03 +0000 (UTC) (envelope-from andreast@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3EA278FC1B; Wed, 5 Jan 2011 21:38:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p05Lc31Q091824; Wed, 5 Jan 2011 21:38:03 GMT (envelope-from andreast@svn.freebsd.org) Received: (from andreast@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p05Lc3e2091822; Wed, 5 Jan 2011 21:38:03 GMT (envelope-from andreast@svn.freebsd.org) Message-Id: <201101052138.p05Lc3e2091822@svn.freebsd.org> From: Andreas Tobler Date: Wed, 5 Jan 2011 21:38:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217027 - head/sys/powerpc/ofw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2011 21:38:03 -0000 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); }