From patchwork Tue Nov 6 16:19:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 197498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 74C002C0091 for ; Wed, 7 Nov 2012 03:19:36 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TVlsF-0006iH-AK; Tue, 06 Nov 2012 16:19:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TVlsB-0006hZ-Ks for fwts-devel@lists.ubuntu.com; Tue, 06 Nov 2012 16:19:31 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1TVlsB-0006s3-Ip for fwts-devel@lists.ubuntu.com; Tue, 06 Nov 2012 16:19:31 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] pci: maxreadreq: ensure we don't overflow with strncpy Date: Tue, 6 Nov 2012 16:19:30 +0000 Message-Id: <1352218770-13472-3-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1352218770-13472-1-git-send-email-colin.king@canonical.com> References: <1352218770-13472-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Alex Hung --- src/pci/maxreadreq/maxreadreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pci/maxreadreq/maxreadreq.c b/src/pci/maxreadreq/maxreadreq.c index a570b37..e5ace46 100644 --- a/src/pci/maxreadreq/maxreadreq.c +++ b/src/pci/maxreadreq/maxreadreq.c @@ -88,7 +88,8 @@ static int maxreadreq_test1(fwts_framework *fw) break; } snprintf(current_device, sizeof(current_device), "pci://00:%s", line); - strncpy(current_type, line+8, 511); + strncpy(current_type, line+8, sizeof(current_type)-1); + current_type[sizeof(current_type)-1] = '\0'; c = strchr(current_type, ':'); if (c) *c='\0';