From patchwork Sat Oct 11 23:52:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 5069881 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D96A8C11AC for ; Sat, 11 Oct 2014 23:50:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5C5E20149 for ; Sat, 11 Oct 2014 23:50:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12AFC2013D for ; Sat, 11 Oct 2014 23:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752133AbaJKXu1 (ORCPT ); Sat, 11 Oct 2014 19:50:27 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:59904 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033AbaJKXuZ (ORCPT ); Sat, 11 Oct 2014 19:50:25 -0400 Received: by mail-la0-f46.google.com with SMTP id gi9so5113401lab.33 for ; Sat, 11 Oct 2014 16:50:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ssx0OyypJAPXfcgBR1y3CNEOv8bhImuwzoZjREQ1Ick=; b=UOqiiAjKZvY4G6WSXvdecUbYKTfayihkJUQBRvxTiVWMTys+VcTinYui6l3WqFHkdk FWruucD4/fWFGX6ch2iaiaKTUxDgvflwT9KaHtDEJsFRRSTixABZfsfozkxhd04pdnJz hhW0a3Aq4c9luiVYUn7d6ANMjxRmkcLwVl5IlqeReJak/cCnS+u8HleO9p6Y4NhTe3s8 e5JD0+4W9Fq5iWQqH+xeDCHLUsr98cbXef5C/NkAuONBj5MX1RIumG5FieC3RTbNsDA0 3OOy5RQJrxLOZXffPKixU9z9Rdm2TumYcTLnUR7M25XOhBNtjwhGpEyuEa/aLJankrJw +8OA== X-Gm-Message-State: ALoCoQlSmMNQQoob/b60+5coG5q3Q26Ai7focEnpn5OBYZcO3RlVJb/gYLet7vli8/K17nyKqjJc X-Received: by 10.152.37.135 with SMTP id y7mr14263068laj.66.1413071423249; Sat, 11 Oct 2014 16:50:23 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id w8sm3131488lbp.46.2014.10.11.16.50.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Oct 2014 16:50:22 -0700 (PDT) From: Rickard Strandqvist To: Brett Rudley , Arend van Spriel Cc: Rickard Strandqvist , Hante Meuleman , "John W. Linville" , Pieter-Paul Giesberts , Daniel Kim , linux-wireless@vger.kernel.org, brcm80211-dev-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: wireless: brcm80211: brcmfmac: dhd_sdio.c: Cleaning up missing null-terminate in conjunction with strncpy Date: Sun, 12 Oct 2014 01:52:31 +0200 Message-Id: <1413071551-15372-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_RHS_DOB autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replacing strncpy with strlcpy to avoid strings that lacks null terminate. And changed from using strncpy to strlcpy to simplify code. Signed-off-by: Rickard Strandqvist Acked-by: Arend van Spriel --- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index f55f625..d20d4e6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -670,7 +670,6 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci, struct brcmf_sdio_dev *sdiodev) { int i; - uint fw_len, nv_len; char end; for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) { @@ -684,25 +683,25 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci, return -ENODEV; } - fw_len = sizeof(sdiodev->fw_name) - 1; - nv_len = sizeof(sdiodev->nvram_name) - 1; /* check if firmware path is provided by module parameter */ if (brcmf_firmware_path[0] != '\0') { - strncpy(sdiodev->fw_name, brcmf_firmware_path, fw_len); - strncpy(sdiodev->nvram_name, brcmf_firmware_path, nv_len); - fw_len -= strlen(sdiodev->fw_name); - nv_len -= strlen(sdiodev->nvram_name); + strlcpy(sdiodev->fw_name, brcmf_firmware_path, + sizeof(sdiodev->fw_name)); + strlcpy(sdiodev->nvram_name, brcmf_firmware_path, + sizeof(sdiodev->nvram_name)); end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1]; if (end != '/') { - strncat(sdiodev->fw_name, "/", fw_len); - strncat(sdiodev->nvram_name, "/", nv_len); - fw_len--; - nv_len--; + strlcat(sdiodev->fw_name, "/", + sizeof(sdiodev->fw_name)); + strlcat(sdiodev->nvram_name, "/", + sizeof(sdiodev->nvram_name)); } } - strncat(sdiodev->fw_name, brcmf_fwname_data[i].bin, fw_len); - strncat(sdiodev->nvram_name, brcmf_fwname_data[i].nv, nv_len); + strlcat(sdiodev->fw_name, brcmf_fwname_data[i].bin, + sizeof(sdiodev->fw_name)); + strlcat(sdiodev->nvram_name, brcmf_fwname_data[i].nv, + sizeof(sdiodev->nvram_name)); return 0; }