From owner-svn-src-all@FreeBSD.ORG Sat Nov 20 19:23:16 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75544106566B; Sat, 20 Nov 2010 19:23:16 +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 6420A8FC15; Sat, 20 Nov 2010 19:23:16 +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 oAKJNGkw022984; Sat, 20 Nov 2010 19:23:16 GMT (envelope-from andreast@svn.freebsd.org) Received: (from andreast@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAKJNG2t022982; Sat, 20 Nov 2010 19:23:16 GMT (envelope-from andreast@svn.freebsd.org) Message-Id: <201011201923.oAKJNG2t022982@svn.freebsd.org> From: Andreas Tobler Date: Sat, 20 Nov 2010 19:23:16 +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: r215577 - head/sys/boot/ofw/libofw X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Nov 2010 19:23:16 -0000 Author: andreast Date: Sat Nov 20 19:23:16 2010 New Revision: 215577 URL: http://svn.freebsd.org/changeset/base/215577 Log: Check the OF_getprop() return value before proceeding. Allocate only as much space as needed for the mode buffer. Use strcmp, relying on OF giving back NULL terminated strings. Submitted by: marius Approved by: nwhitehorn (mentor) Modified: head/sys/boot/ofw/libofw/openfirm.c Modified: head/sys/boot/ofw/libofw/openfirm.c ============================================================================== --- head/sys/boot/ofw/libofw/openfirm.c Sat Nov 20 18:40:50 2010 (r215576) +++ head/sys/boot/ofw/libofw/openfirm.c Sat Nov 20 19:23:16 2010 (r215577) @@ -77,7 +77,7 @@ void OF_init(int (*openfirm)(void *)) { phandle_t options; - char mode[8]; + char mode[sizeof("true")]; openfirmware = openfirm; @@ -93,13 +93,13 @@ OF_init(int (*openfirm)(void *)) if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1) OF_exit(); - /* + /* * Check if we run in real mode. If so, we do not need to map * memory later on. */ options = OF_finddevice("/options"); - OF_getprop(options, "real-mode?", mode, sizeof(mode)); - if (strncmp(mode, "true", 4) == 0) + if (OF_getprop(options, "real-mode?", mode, sizeof(mode)) > 0 && + strcmp(mode, "true") == 0) real_mode = 1; }