From: Steven Miao Date: Wed, 1 Jun 2011 07:52:41 +0000 (+0800) Subject: Blackfin: strncpy: fix handling of zero lengths X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5ff6197f828d5ea051b3abf77cb61f8a34480e8d;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.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 f3931d50b4a7..2c07dddac995 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*/