From 6bce3d81e146bc6adeb7cff124a78f818aa6fbe0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 12 Sep 2014 08:46:06 -0700 Subject: [PATCH] s3: utils: Don't directly manipulate errno inside strupper_m(). Let the internal character conversion routines set it. Caller code paths don't depend on this (checked by David Disseldorp ddiss@suse.de). Bug 10775 - smbd crashes when accessing garbage filenames https://bugzilla.samba.org/show_bug.cgi?id=10775 Signed-off-by: Jeremy Allison Reviewed-by: David Disseldorp --- source3/lib/util_str.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index cfc495d6702..2b0830c2ff4 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -551,7 +551,6 @@ _PUBLIC_ void strupper_m(char *s) bool strupper_m(char *s) { size_t len; - int errno_save; bool ret = false; /* this is quite a common operation, so we want it to be @@ -570,14 +569,11 @@ bool strupper_m(char *s) /* I assume that lowercased string takes the same number of bytes * as source string even in multibyte encoding. (VIV) */ len = strlen(s) + 1; - errno_save = errno; - errno = 0; ret = unix_strupper(s,len,s,len); /* Catch mb conversion errors that may not terminate. */ - if (errno) { + if (!ret) { s[len-1] = '\0'; } - errno = errno_save; return ret; } -- 2.11.4.GIT