2011-06-03 15:09:31

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH] Blackfin: strncpy: fix handling of zero lengths

From: Steven Miao <[email protected]>

The jump to 4f will cause the NUL padding loop to run at least one time,
so if string length is zero just jump to the end. Otherwise we wrongly
write one NUL byte when size==0.

Signed-off-by: Steven Miao <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
arch/blackfin/lib/strncpy.S | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/blackfin/lib/strncpy.S b/arch/blackfin/lib/strncpy.S
index f3931d5..2c07ddd 100644
--- a/arch/blackfin/lib/strncpy.S
+++ b/arch/blackfin/lib/strncpy.S
@@ -25,7 +25,7 @@

ENTRY(_strncpy)
CC = R2 == 0;
- if CC JUMP 4f;
+ if CC JUMP 6f;

P2 = R2 ; /* size */
P0 = R0 ; /* dst*/
--
1.7.5.3


2011-06-03 22:36:17

by Greg KH

[permalink] [raw]
Subject: Re: [stable] [PATCH] Blackfin: strncpy: fix handling of zero lengths

On Fri, Jun 03, 2011 at 11:09:22AM -0400, Mike Frysinger wrote:
> From: Steven Miao <[email protected]>
>
> The jump to 4f will cause the NUL padding loop to run at least one time,
> so if string length is zero just jump to the end. Otherwise we wrongly
> write one NUL byte when size==0.
>
> Signed-off-by: Steven Miao <[email protected]>
> Signed-off-by: Mike Frysinger <[email protected]>
> ---
> arch/blackfin/lib/strncpy.S | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.

</formletter>