summaryrefslogtreecommitdiff
path: root/lib/libc/arch/mips64
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2021-07-24 05:35:57 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2021-07-24 05:35:57 +0000
commitd1aba607b982a1a1107d18c44c750c52fe627460 (patch)
tree059246e3cddff3696d776019a5d7c7d3baf3c94a /lib/libc/arch/mips64
parent50fab5723926b96f5c5f22d2c24b3e2a2ab98164 (diff)
Fix strchr() and strrchr() on mips64
Truncate the character arguments of strchr() and strrchr() to eight bits so that the implied char conversion would work correctly. Otherwise the functions would always return NULL when the character argument is negative. OK miod@
Diffstat (limited to 'lib/libc/arch/mips64')
-rw-r--r--lib/libc/arch/mips64/string/strchr.S3
-rw-r--r--lib/libc/arch/mips64/string/strrchr.S3
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/arch/mips64/string/strchr.S b/lib/libc/arch/mips64/string/strchr.S
index 05f50f0da73..fb85f700e8e 100644
--- a/lib/libc/arch/mips64/string/strchr.S
+++ b/lib/libc/arch/mips64/string/strchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strchr.S,v 1.3 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: strchr.S,v 1.4 2021/07/24 05:35:56 visa Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,6 +37,7 @@ WEAK_ALIAS(index, strchr)
LEAF(strchr, 0)
.set reorder
+ andi a1, 0xff
0:
lbu a2, 0(a0) # get a byte
daddu a0, a0, 1
diff --git a/lib/libc/arch/mips64/string/strrchr.S b/lib/libc/arch/mips64/string/strrchr.S
index ad35b84cb95..a7a4a5996c1 100644
--- a/lib/libc/arch/mips64/string/strrchr.S
+++ b/lib/libc/arch/mips64/string/strrchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strrchr.S,v 1.3 2015/08/31 02:53:56 guenther Exp $ */
+/* $OpenBSD: strrchr.S,v 1.4 2021/07/24 05:35:56 visa Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -38,6 +38,7 @@ WEAK_ALIAS(rindex, strrchr)
LEAF(strrchr, 0)
.set reorder
move v0, zero # default if not found
+ andi a1, 0xff
1:
lbu a3, 0(a0) # get a byte
daddu a0, a0, 1