From patchwork Wed May 30 07:46:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Meyering X-Patchwork-Id: 161885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 89849B703C for ; Wed, 30 May 2012 18:41:27 +1000 (EST) Received: from localhost ([::1]:58585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZddb-0001e5-LP for incoming@patchwork.ozlabs.org; Wed, 30 May 2012 03:48:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZdct-0008NE-Ax for qemu-devel@nongnu.org; Wed, 30 May 2012 03:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SZdcr-0001ft-Jh for qemu-devel@nongnu.org; Wed, 30 May 2012 03:47:26 -0400 Received: from mx.meyering.net ([88.168.87.75]:49303 helo=hx.meyering.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZdcr-0001fO-1s for qemu-devel@nongnu.org; Wed, 30 May 2012 03:47:25 -0400 Received: from hx.meyering.net (hx.meyering.net [127.0.0.1]) by hx.meyering.net (8.14.5/8.14.5) with ESMTP id q4U7lMe4013984; Wed, 30 May 2012 09:47:23 +0200 Received: (from meyering@localhost) by hx.meyering.net (8.14.5/8.14.5/Submit) id q4U7lMr6013983; Wed, 30 May 2012 09:47:22 +0200 From: Jim Meyering To: qemu-devel@nongnu.org Date: Wed, 30 May 2012 09:46:26 +0200 Message-Id: <1338364001-13892-8-git-send-email-jim@meyering.net> X-Mailer: git-send-email 1.7.10.2.605.gbefc5ed In-Reply-To: <1338364001-13892-1-git-send-email-jim@meyering.net> References: <1338364001-13892-1-git-send-email-jim@meyering.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 88.168.87.75 Cc: Jim Meyering Subject: [Qemu-devel] [PATCHv2 07/22] lm32: avoid buffer overrun X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jim Meyering Actually do what the comment says, using pstrcpy NUL-terminate: strncpy does not always do that. Signed-off-by: Jim Meyering --- hw/lm32_hwsetup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/lm32_hwsetup.h b/hw/lm32_hwsetup.h index 8fc285e..70dc61f 100644 --- a/hw/lm32_hwsetup.h +++ b/hw/lm32_hwsetup.h @@ -96,7 +96,7 @@ static inline void hwsetup_add_tag(HWSetup *hw, enum hwsetup_tag t) static inline void hwsetup_add_str(HWSetup *hw, const char *str) { - strncpy(hw->ptr, str, 31); /* make sure last byte is zero */ + pstrcpy(hw->ptr, 32, str); hw->ptr += 32; }