linux-mips
[Top] [All Lists]

Re: [PATCH] arch: mips: kernel: using strlcpy() instead of strncpy()

To: linux-mips@linux-mips.org
Subject: Re: [PATCH] arch: mips: kernel: using strlcpy() instead of strncpy()
From: John Crispin <blogic@openwrt.org>
Date: Mon, 27 May 2013 12:38:49 +0200
In-reply-to: <51A1C26E.5000609@asianux.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <51A1C26E.5000609@asianux.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12
On 26/05/13 10:06, Chen Gang wrote:
For NUL terminated string, need always be sure of ended by zero.

Or the next pr_info() will cause issue.


Signed-off-by: Chen Gang<gang.chen@asianux.com>
---
  arch/mips/kernel/prom.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index 5712bb5..7e95404 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -30,7 +30,7 @@ __init void mips_set_machine_name(const char *name)
        if (name == NULL)
                return;

-       strncpy(mips_machine_name, name, sizeof(mips_machine_name));
+       strlcpy(mips_machine_name, name, sizeof(mips_machine_name));
        pr_info("MIPS: machine is %s\n", mips_get_machine_name());
  }

Acked-by: John Crispin <blogic@openwrt.org>

<Prev in Thread] Current Thread [Next in Thread>