[PATCH] lib:charset: Fix error messages from charset conversion

Jeremy Allison jra at samba.org
Fri Jul 6 23:02:38 UTC 2018


On Thu, Jun 28, 2018 at 11:50:13AM -0700, Christof Schmitt via samba-technical wrote:
> From 8754648a2931741bb0246e74a24cb657b00da486 Mon Sep 17 00:00:00 2001
> From: Christof Schmitt <cs at samba.org>
> Date: Thu, 28 Jun 2018 11:44:51 -0700
> Subject: [PATCH] lib:charset: Fix error messages from charset conversion
> 
> When e.g. trying to access a filename through Samba that does not adhere
> to the encoding configured in 'unix charset', the log will show the
> encoding problem, followed by "strstr_m: src malloc fail". The problem
> is that strstr_m assumes that any failure from push/pull_ucs2_talloc is
> a memory allocation problem, which is not correct.
> 
> Address this by removing the misleading messages and add a missing
> message in convert_string_talloc_handle.

Good catch ! RB+ and pushed.

Thanks,

	Jeremy.

> Signed-off-by: Christof Schmitt <cs at samba.org>
> ---
>  lib/util/charset/convert_string.c | 1 +
>  lib/util/charset/util_str.c       | 3 ---
>  2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/lib/util/charset/convert_string.c b/lib/util/charset/convert_string.c
> index 50065f8..196302a 100644
> --- a/lib/util/charset/convert_string.c
> +++ b/lib/util/charset/convert_string.c
> @@ -375,6 +375,7 @@ bool convert_string_talloc_handle(TALLOC_CTX *ctx, struct smb_iconv_handle *ic,
>  		}
>  		ob = talloc_zero_array(ctx, char, destlen);
>  		if (ob == NULL) {
> +			DBG_ERR("Could not talloc destination buffer.\n");
>  			errno = ENOMEM;
>  			return false;
>  		}
> diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
> index 6feed17..3f5b247 100644
> --- a/lib/util/charset/util_str.c
> +++ b/lib/util/charset/util_str.c
> @@ -570,13 +570,11 @@ char *strstr_m(const char *src, const char *findstr)
>  	frame = talloc_stackframe();
>  
>  	if (!push_ucs2_talloc(frame, &src_w, src, &converted_size)) {
> -		DBG_WARNING("src malloc fail\n");
>  		TALLOC_FREE(frame);
>  		return NULL;
>  	}
>  
>  	if (!push_ucs2_talloc(frame, &find_w, findstr, &converted_size)) {
> -		DBG_WARNING("find malloc fail\n");
>  		TALLOC_FREE(frame);
>  		return NULL;
>  	}
> @@ -591,7 +589,6 @@ char *strstr_m(const char *src, const char *findstr)
>  	*p = 0;
>  	if (!pull_ucs2_talloc(frame, &s2, src_w, &converted_size)) {
>  		TALLOC_FREE(frame);
> -		DEBUG(0,("strstr_m: dest malloc fail\n"));
>  		return NULL;
>  	}
>  	retp = discard_const_p(char, (s+strlen(s2)));
> -- 
> 1.8.3.1
> 



More information about the samba-technical mailing list