All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: linuxppc-dev@ozlabs.org
Cc: Steven Rostedt <rostedt@goodmis.org>, Christian_Sellars@symantec.com
Subject: [PATCH] powerpc: fix handling of strnlen with zero len
Date: Thu, 25 Feb 2010 13:49:46 -0500	[thread overview]
Message-ID: <4B86C64A.2050508@suse.com> (raw)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 Commit 0119536c, which added the assembly version of strncmp to
 powerpc, mentions that it adds two instructions to the version from
 boot/string.S to allow it to handle len=0. Unfortunately, it doesn't
 always return 0 when that is the case. The length is passed in r5, but
 the return value is passed back in r3. In certain cases, this will
 happen to work. Otherwise it will pass back the address of the first
 string as the return value.

 This patch lifts the len <= 0 handling code from memcpy to handle that case.

Reported by: Christian_Sellars@symantec.com
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
- ---
 arch/powerpc/lib/string.S |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

- --- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -71,7 +71,7 @@ _GLOBAL(strcmp)
 
 _GLOBAL(strncmp)
 	PPC_LCMPI r5,0
- -	beqlr
+	ble-	2f
 	mtctr	r5
 	addi	r5,r3,-1
 	addi	r4,r4,-1
@@ -82,6 +82,8 @@ _GLOBAL(strncmp)
 	beqlr	1
 	bdnzt	eq,1b
 	blr
+2:	li	r3,0
+	blr
 
 _GLOBAL(strlen)
 	addi	r4,r3,-1
- -- 
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/

iEYEARECAAYFAkuGxkoACgkQLPWxlyuTD7LzfQCeKAaKtyEfbabuGzZyAEEnb8Mq
KEsAn1tKZtVSQ2A68TjwU/JN2LC3Mop7
=/CaR
-----END PGP SIGNATURE-----

                 reply	other threads:[~2010-02-25 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B86C64A.2050508@suse.com \
    --to=jeffm@suse.com \
    --cc=Christian_Sellars@symantec.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.