Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Mar 2012 16:21:40 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232729 - head/libexec/rtld-elf
Message-ID:  <201203091621.q29GLecE015054@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Mar  9 16:21:40 2012
New Revision: 232729
URL: http://svn.freebsd.org/changeset/base/232729

Log:
  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

Modified:
  head/libexec/rtld-elf/rtld_printf.c

Modified: head/libexec/rtld-elf/rtld_printf.c
==============================================================================
--- head/libexec/rtld-elf/rtld_printf.c	Fri Mar  9 16:17:46 2012	(r232728)
+++ head/libexec/rtld-elf/rtld_printf.c	Fri Mar  9 16:21:40 2012	(r232729)
@@ -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_ar
 	}
 }
 
-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 
 	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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203091621.q29GLecE015054>