[PATCH] xauth: improve to handle FamilyWild necessary for GDM/XDMCP/SSH. #43425

Alan Coopersmith alan.coopersmith at oracle.com
Fri Aug 24 23:11:11 PDT 2012


Whatever mail client you used totally corrupted the patch.   I was able to
seemingly repair it by stripping ^M and then undoing line wraps, but git
still hit a bunch of whitespace errors that had to be corrected.

On 08/14/12 05:38 AM, Volkel, Stefan (EXT-Other - DE/Ulm) wrote:
> -static Bool
> +static Bool 

Please don't add spaces to the end of lines, it makes git unhappy and introduces
hard to spot diff mismatches in future patches.

> +static int 
> +match_authwild_dpy(register Xauth *a, const char *displayname)
> +{
> +    int family;
> +    char *host = NULL, *rest = NULL;
> +    int dpynum, scrnum;
> +    char dpynumbuf[40];			/* want to hold largest
> display num */
> +
> +    if ( a->family != FamilyWild ) {
> +	return False;
> +    }
> +
> +    if (!parse_displayname (displayname,
> +			    &family, &host, &dpynum, &scrnum, &rest)) {
> +	if (host) free(host);
> +	if (rest) free(rest);

You can drop the "if (host)" and "if (rest)" - we're working through purging the
unnecessary checks for NULL values before free() from the rest of the X code
base and I'd rather not introduce more for us to come clean up.

Also, this seems to be the only case in which you free those instead of letting
them leak - why aren't you freeing them in the rest of the function?

> +	return False;
> +    }
> +
> +    dpynumbuf[0] = '\0';
> +    sprintf (dpynumbuf, "%d", dpynum);
> +
> +    if (a->address_length != strlen(host) || a->number_length !=
> strlen(dpynumbuf))
> +	    return False;
> +
> +    if (memcmp(a->address, host, a->address_length) == 0 &&
> +	    memcmp(a->number, dpynumbuf, a->number_length) == 0)
> +	    return True;
> +    else
> +	    return False;

Please be consistent in indent levels - don't use 4 space indents for if
and else, then add 8 for the return clauses inside.

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list