From patchwork Tue Dec 8 03:26:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rini X-Patchwork-Id: 553689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D62001402BD for ; Tue, 8 Dec 2015 14:26:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EB22F4B68A; Tue, 8 Dec 2015 04:26:28 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xo-jh0c5YyYK; Tue, 8 Dec 2015 04:26:28 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 412364B67D; Tue, 8 Dec 2015 04:26:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 816714B67D for ; Tue, 8 Dec 2015 04:26:23 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hjToIMq9sCUD for ; Tue, 8 Dec 2015 04:26:23 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qg0-f48.google.com (mail-qg0-f48.google.com [209.85.192.48]) by theia.denx.de (Postfix) with ESMTPS id 22ECC4B67C for ; Tue, 8 Dec 2015 04:26:18 +0100 (CET) Received: by qgea14 with SMTP id a14so6430206qge.0 for ; Mon, 07 Dec 2015 19:26:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=/DcfH6n/mqh1L1h9YNH3tI7J9aRBG31CwVxz1MvlH6w=; b=QLH0VIqzUtWbitq3EI3WC4k6v+fzlVq8Dih7y6ak0c4IpCwxqkNs9yhBwbmMnNkxS/ wqAwtxU49zqPh+Q02AQvVL3vrFwratzw182wjp5OmkDVVyCKutmduwMomWzjyvpl6cAP T+kL/QHvWKjJglpLX9ki68ZbQvbhBqoK/yzWgq0AzZS0sP4HwRvQNCL8PariJfu+ZOeB 9opISGMonM7rJpcjU7Td4nvQzh1R/UleRiXtc9cyz1jTvQcMZCImzK4/cMuCtQi5Z5AE Ne+d/Dw2oeoayeuGae56rw5eZGCnCuExbHQjvHEyFfrgbVTlgaFgx6HioDnBu8Bftz1N 7CGA== X-Received: by 10.140.89.113 with SMTP id u104mr1587235qgd.98.1449545177266; Mon, 07 Dec 2015 19:26:17 -0800 (PST) Received: from localhost.localdomain (cpe-75-180-230-22.ec.res.rr.com. [75.180.230.22]) by smtp.gmail.com with ESMTPSA id p4sm604343qhp.45.2015.12.07.19.26.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2015 19:26:15 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Date: Mon, 7 Dec 2015 22:26:33 -0500 Message-Id: <1449545195-18195-1-git-send-email-trini@konsulko.com> X-Mailer: git-send-email 1.7.9.5 Subject: [U-Boot] [PATCH 1/3] serial-uclass.c: Copy at most sdev.name - 1 characters into the buffer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Coverity notes that we do not ensure a NULL terminated string here as we could fill the entire buffer with our strncpy call. Fix this by subtracting one. Reported-by: Coverity (CID 131093) Cc: Simon Glass Signed-off-by: Tom Rini Reviewed-by: Simon Glass --- drivers/serial/serial-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 842f78b..2ef82b0 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -324,7 +324,7 @@ static int serial_post_probe(struct udevice *dev) return 0; memset(&sdev, '\0', sizeof(sdev)); - strncpy(sdev.name, dev->name, sizeof(sdev.name)); + strncpy(sdev.name, dev->name, sizeof(sdev.name) - 1); sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT; sdev.priv = dev; sdev.putc = serial_stub_putc;