s3: utils: Don't directly manipulate errno inside strupper_m().
authorJeremy Allison <jra@samba.org>
Fri, 12 Sep 2014 15:46:06 +0000 (08:46 -0700)
committerDavid Disseldorp <ddiss@samba.org>
Mon, 15 Sep 2014 23:56:54 +0000 (01:56 +0200)
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 <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
source3/lib/util_str.c

index cfc495d67021ec3543a45c92a83b9f74938e0907..2b0830c2ff42cb56bf6b354c58d4fafbad1edf67 100644 (file)
@@ -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;
 }