From 8e1fec05cbab33fae372794f3dff1cb5fccac809 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 2 Aug 2006 09:32:18 +0000 Subject: r17375: If a field containts only whitespace, we need to do base64 as well. Volker (This used to be commit 795d06f427061536c6e3a3eb5b5d60a27f5ec70d) --- source3/utils/net_rpc_samsync.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_samsync.c') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 4f7209cdb5..bbe09a3b35 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -1433,6 +1433,7 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name, va_list ap; char *value, *p, *base64; DATA_BLOB base64_blob; + BOOL do_base64 = False; int res; va_start(ap, fmt); @@ -1443,12 +1444,29 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name, for (p=value; *p; p++) { if (*p & 0x80) { + do_base64 = True; break; } } - if (*p == 0) { - /* Found no high bit set */ + if (!do_base64) { + BOOL only_whitespace = True; + for (p=value; *p; p++) { + /* + * I know that this not multibyte safe, but we break + * on the first non-whitespace character anyway. + */ + if (!isspace(*p)) { + only_whitespace = False; + break; + } + } + if (only_whitespace) { + do_base64 = True; + } + } + + if (!do_base64) { res = fprintf(add_fd, "%s: %s\n", attr_name, value); TALLOC_FREE(value); return res; -- cgit