From: Steven Miao Date: Wed, 1 Jun 2011 07:52:41 +0000 (+0800) Subject: Blackfin: strncpy: fix handling of zero lengths X-Git-Tag: v3.0~351^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ff6197f828d5ea051b3abf77cb61f8a34480e8d;p=platform%2Fkernel%2Flinux-amlogic.git Blackfin: strncpy: fix handling of zero lengths 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 Signed-off-by: Mike Frysinger --- 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*/