diff options
author | Jeremy Allison <jra@samba.org> | 2012-08-08 15:56:58 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-08-09 12:07:41 -0700 |
commit | ce21d0804012da27cec72abe896352d7f0e7e1e5 (patch) | |
tree | 158e7f694b475fdb6d0ccea44e09ec11c2ee53f1 /source3 | |
parent | c13887defc4c05b6b87f8f40ae0cf981a497f443 (diff) | |
download | samba-ce21d0804012da27cec72abe896352d7f0e7e1e5.tar.gz samba-ce21d0804012da27cec72abe896352d7f0e7e1e5.tar.bz2 samba-ce21d0804012da27cec72abe896352d7f0e7e1e5.zip |
Fix strlower_m() to return an error indication.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/lib/util_str.c | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index bfb9b37fd5..9af72a190b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 446838a0b9..8962b23da0 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -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) |