svn commit: samba r21740 - in branches/SAMBA_4_0/source/lib/util: .

simo idra at samba.org
Fri Mar 9 14:29:22 GMT 2007


On Wed, 2007-03-07 at 10:00 +0000, tridge at samba.org wrote:
> Author: tridge
> Date: 2007-03-07 10:00:14 +0000 (Wed, 07 Mar 2007)
> New Revision: 21740
> 
> WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21740
> 
> Log:
> 
> this fixes the real cause of the large log files we had. The problem
> was we were not checking the result of a convert_string() call, and it
> was giving -1. We then passed -1 to fwrite() on stdout, which on aix
> and macosx wrote all of available memory to stdout :)
> 
> To fix this, replace non-printing chars with ? in d_printf if the
> string cannot be converted
> 
> Modified:
>    branches/SAMBA_4_0/source/lib/util/dprintf.c
> 
> 
> Changeset:
> Modified: branches/SAMBA_4_0/source/lib/util/dprintf.c
> ===================================================================
> --- branches/SAMBA_4_0/source/lib/util/dprintf.c	2007-03-07 05:29:12 UTC (rev 21739)
> +++ branches/SAMBA_4_0/source/lib/util/dprintf.c	2007-03-07 10:00:14 UTC (rev 21740)
> @@ -30,6 +30,7 @@
>  */
>  
>  #include "includes.h"
> +#include "system/locale.h"
>  
>  _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0)
>  {
> @@ -54,7 +55,23 @@
>  		return -1;
>  	}
>  	clen = convert_string(CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen);
> +        if (clen == -1) {
> +		/* the string can't be converted - do the best we can,
> +		   filling in non-printing chars with '?' */
> +		int i;
> +		for (i=0;i<ret;i++) {
> +			if (isprint(p[i]) || isspace(p[i])) {
> +				fwrite(p+i, 1, 1, f);
> +			} else {
> +				fwrite("?", 1, 1, f);
> +			}
> +		}
> +		SAFE_FREE(p);
> +		SAFE_FREE(p2);
> +		return ret;
> +        }
>  
> +
>  	if (clen >= maxlen) {
>  		/* it didn't fit - try a larger buffer */
>  		maxlen *= 2;

Tridge, according to my man pages isprint() includes spaces, is this not
true on some platforms?

Also why do you put '?' wouldn't it be better to put something like \XX
with XX the hex rep of the byte we cannot print? At least this way we
have a change to understand what was there by hand inspection.

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org



More information about the samba-technical mailing list