lib:charset: Fix error messages from charset conversion
authorChristof Schmitt via samba-technical <samba-technical@lists.samba.org>
Thu, 28 Jun 2018 18:50:13 +0000 (11:50 -0700)
committerRalph Boehme <slow@samba.org>
Sat, 7 Jul 2018 11:41:09 +0000 (13:41 +0200)
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.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/charset/convert_string.c
lib/util/charset/util_str.c

index 50065f8e07603ebcf43ea6f283ad599529735c18..196302aacfdd475b8a60bcbefd7c496af8228380 100644 (file)
@@ -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;
                }
index 6feed1742ac48b3177ee3d87596eac5007fca42e..3f5b247bd92e1d63c62116a843f4d5d99448aa33 100644 (file)
@@ -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)));