]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix strlower_m() to return an error indication.
authorJeremy Allison <jra@samba.org>
Wed, 8 Aug 2012 22:56:58 +0000 (15:56 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 9 Aug 2012 19:07:41 +0000 (12:07 -0700)
source3/include/proto.h
source3/lib/util_str.c

index bfb9b37fd589066dc8d378737f75246b0a6e3a61..9af72a190bf26b1f1faad92571509ef782fd8fe3 100644 (file)
@@ -701,7 +701,7 @@ char *strchr_m(const char *src, char c);
 char *strrchr_m(const char *s, char c);
 char *strnrchr_m(const char *s, char c, unsigned int n);
 char *strstr_m(const char *src, const char *findstr);
-void strlower_m(char *s);
+bool strlower_m(char *s);
 bool strupper_m(char *s);
 size_t strlen_m(const char *s);
 size_t strlen_m_term(const char *s);
index 446838a0b9f3104730c4ed5d155dfccc59294abe..8962b23da0d8738e9c390016a440a9b0d2754657 100644 (file)
@@ -463,10 +463,11 @@ _PUBLIC_ void strlower_m(char *s)
  Convert a string to lower case.
 **/
 
-void strlower_m(char *s)
+bool strlower_m(char *s)
 {
        size_t len;
        int errno_save;
+       bool ret = false;
 
        /* this is quite a common operation, so we want it to be
           fast. We optimise for the ascii case, knowing that all our
@@ -479,18 +480,21 @@ void strlower_m(char *s)
        }
 
        if (!*s)
-               return;
+               return true;
 
        /* I assume that lowercased string takes the same number of bytes
         * as source string even in UTF-8 encoding. (VIV) */
        len = strlen(s) + 1;
        errno_save = errno;
        errno = 0;
-       unix_strlower(s,len,s,len);
+       ret = unix_strlower(s,len,s,len);
        /* Catch mb conversion errors that may not terminate. */
-       if (errno)
+       if (errno) {
                s[len-1] = '\0';
+               ret = false;
+       }
        errno = errno_save;
+       return ret;
 }
 
 static bool unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)