summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/rtld_printf.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-03-09 16:21:40 +0000
committerkib <kib@FreeBSD.org>2012-03-09 16:21:40 +0000
commit777fe4aad20d933a0ada87680499bede1ef705e2 (patch)
treefaa1511811f184f6d5dafa2f1220f2fa1e1ebb8e /libexec/rtld-elf/rtld_printf.c
parent2a4043fb20f4500df11de0c9064a26176be0c849 (diff)
downloadFreeBSD-src-777fe4aad20d933a0ada87680499bede1ef705e2.zip
FreeBSD-src-777fe4aad20d933a0ada87680499bede1ef705e2.tar.gz
Remove the use of toupper() from rtld_printf.c. Use of the libc function
relies on working TLS, which is particulary not true for LD_DEBUG uses. MFC after: 1 week
Diffstat (limited to 'libexec/rtld-elf/rtld_printf.c')
-rw-r--r--libexec/rtld-elf/rtld_printf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libexec/rtld-elf/rtld_printf.c b/libexec/rtld-elf/rtld_printf.c
index b9aadc3..eb4514a 100644
--- a/libexec/rtld-elf/rtld_printf.c
+++ b/libexec/rtld-elf/rtld_printf.c
@@ -36,7 +36,6 @@
*/
#include <sys/param.h>
-#include <ctype.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stddef.h>
@@ -90,8 +89,10 @@ snprintf_func(int ch, struct snprintf_arg *const info)
}
}
-static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-#define hex2ascii(hex) (hex2ascii_data[hex])
+static char const hex2ascii_lower[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+static char const hex2ascii_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+#define hex2ascii(hex) (hex2ascii_lower[hex])
+#define hex2ascii_upper(hex) (hex2ascii_upper[hex])
static __inline int
imax(int a, int b)
@@ -108,8 +109,9 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
p = nbuf;
*p = '\0';
do {
- c = hex2ascii(num % base);
- *++p = upper ? toupper(c) : c;
+ c = upper ? hex2ascii_upper(num % base) :
+ hex2ascii(num % base);
+ *++p = c;
} while (num /= base);
if (lenp)
*lenp = p - nbuf;
OpenPOWER on IntegriCloud