From e0f5d84e9d4c7eb396d48117ebb1b116e19e0700 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 May 2001 23:17:46 +0000 Subject: Fix for problem with "" string in trim_string(). Pointed out by Ben Winslow . Jeremy. (This used to be commit df2e306171f0a71af77dbaafc7ccbf78e27befb8) --- source3/lib/util_str.c | 8 +++++--- 1 file 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; -- cgit