diff options
author | Jeremy Allison <jra@samba.org> | 2001-05-10 23:17:46 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-05-10 23:17:46 +0000 |
commit | e0f5d84e9d4c7eb396d48117ebb1b116e19e0700 (patch) | |
tree | 182a9bc123ea4235151c1f0bb9fd5641a5beb663 /source3 | |
parent | 3e125823cf967988a51a06644febbf164c8596d3 (diff) | |
download | samba-e0f5d84e9d4c7eb396d48117ebb1b116e19e0700.tar.gz samba-e0f5d84e9d4c7eb396d48117ebb1b116e19e0700.tar.bz2 samba-e0f5d84e9d4c7eb396d48117ebb1b116e19e0700.zip |
Fix for problem with "" string in trim_string(). Pointed out by Ben Winslow <rain@bluecherry.net>.
Jeremy.
(This used to be commit df2e306171f0a71af77dbaafc7ccbf78e27befb8)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_str.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index b517d93dd8..78366fceb7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -545,9 +545,11 @@ BOOL trim_string(char *s,const char *front,const char *back) size_t back_len; char *sP; - if ( !s ) { + /* Ignore null or empty strings. */ + + if ( !s || (s[0] == '\0')) return False; - } + sP = s; s_len = strlen( s ) + 1; front_len = (front) ? strlen( front ) + 1 : 0; @@ -589,7 +591,7 @@ BOOL trim_string(char *s,const char *front,const char *back) * Kenichi Okuyama. */ - if ( back && back_len > 1 ) { + if ( back && back_len > 1 && s_len > back_len) { char *bP = sP + s_len - back_len; long b_len = s_len; |