From patchwork Sat Jul 26 21:26:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 373981 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A531B140108 for ; Sun, 27 Jul 2014 07:26:10 +1000 (EST) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 67A031A093A for ; Sun, 27 Jul 2014 07:26:10 +1000 (EST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 17EEF1A073A for ; Sun, 27 Jul 2014 07:25:30 +1000 (EST) Received: by mail-wg0-f48.google.com with SMTP id x13so5614140wgg.7 for ; Sat, 26 Jul 2014 14:25:26 -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=L1eOaFnFMDAo5vgas/XGKFth7BCq8SiheZflvpY6ss0=; b=C6LppVGb7H3XXuSUS3aDXsDGOLx6B8YUKhp92jEx0MZ2It5Ru79+xRykS81p1jeV6o cZwdbu0al6s9/0lTigo+OFnAvImnIrykLf0SO80ww4RPik0rjITJM/qqIb+ADoKvqzRP VcO6SnriikYlUXJELy9OK8uDjaHPEIKhaTHZZJ3ss7V5T4BfAn9dNvHYT+6ddKu/B0g0 9Jzm3POVuhaxn5tpGyvO67Zbh2WHky2gGnDv/Yn37crhYKkVsC3MgCdC6BA7eo3n/DaH DELbhTcPATdsDanB3CnTcjPMMFvxvL63fwsaKmAGRRVIi0PNfUxbMYW4USo6cUFjuOKQ VvBA== X-Gm-Message-State: ALoCoQnJQMOGSuy05Ccbuti10xo71p0kRHvA75BRrsdV2G5h3Xtd9qTAlZ0dn+MglR74JCMhWD6T X-Received: by 10.180.86.199 with SMTP id r7mr16025230wiz.20.1406409926093; Sat, 26 Jul 2014 14:25:26 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id xn12sm11524176wib.13.2014.07.26.14.25.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Jul 2014 14:25:25 -0700 (PDT) From: Rickard Strandqvist To: Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCH] arch: powerpc: sysdev: qe_lib: qe.c: Cleaning up in conjunction with strncpy and strcpy Date: Sat, 26 Jul 2014 23:26:51 +0200 Message-Id: <1406410011-6522-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Cc: devicetree@vger.kernel.org, Rickard Strandqvist , linux-kernel@vger.kernel.org, Rob Herring , Grant Likely , linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Replacing strcpy and strncpy with strlcpy to avoid strings that ar to big, or lacks null terminate. Signed-off-by: Rickard Strandqvist --- arch/powerpc/sysdev/qe_lib/qe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c index 238a07b..9f19e6c 100644 --- a/arch/powerpc/sysdev/qe_lib/qe.c +++ b/arch/powerpc/sysdev/qe_lib/qe.c @@ -498,7 +498,7 @@ int qe_upload_firmware(const struct qe_firmware *firmware) * saved microcode information and put in the new. */ memset(&qe_firmware_info, 0, sizeof(qe_firmware_info)); - strcpy(qe_firmware_info.id, firmware->id); + strlcpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id)); qe_firmware_info.extended_modes = firmware->extended_modes; memcpy(qe_firmware_info.vtraps, firmware->vtraps, sizeof(firmware->vtraps)); @@ -584,8 +584,8 @@ struct qe_firmware_info *qe_get_firmware_info(void) /* Copy the data into qe_firmware_info*/ sprop = of_get_property(fw, "id", NULL); if (sprop) - strncpy(qe_firmware_info.id, sprop, - sizeof(qe_firmware_info.id) - 1); + strlcpy(qe_firmware_info.id, sprop, + sizeof(qe_firmware_info.id)); prop = of_find_property(fw, "extended-modes", NULL); if (prop && (prop->length == sizeof(u64))) {