masqmail

diff src/address.c @ 411:9b93c0a3bd8c

Ensure lvals, rvals and components of address strucs are stripped.
author markus schnalke <meillo@marmaro.de>
date Wed, 29 Feb 2012 12:06:33 +0100
parents bc9a7845b53a
children
line diff
     1.1 --- a/src/address.c	Wed Feb 29 12:05:47 2012 +0100
     1.2 +++ b/src/address.c	Wed Feb 29 12:06:33 2012 +0100
     1.3 @@ -37,7 +37,7 @@
     1.4  	address *addr = create_address(path, is_rfc821);
     1.5  
     1.6  	if (addr && !addr->domain) {
     1.7 -		addr->domain = g_strdup(domain);
     1.8 +		addr->domain = g_strstrip(g_strdup(domain));
     1.9  	}
    1.10  	return addr;
    1.11  }
    1.12 @@ -50,8 +50,8 @@
    1.13  
    1.14  	if (addr) {
    1.15  		memset(addr, 0, sizeof(address));
    1.16 -		addr->address = g_strchomp(g_strdup(path));
    1.17 -		addr->local_part = g_strdup(addr->address);
    1.18 +		addr->address = g_strstrip(g_strdup(path));
    1.19 +		addr->local_part = g_strstrip(g_strdup(addr->address));
    1.20  		addr->domain = g_strdup("localhost");  /* quick hack */
    1.21  	}
    1.22  	return addr;
    1.23 @@ -78,10 +78,11 @@
    1.24  	if (!(addr = g_malloc(sizeof(address)))) {
    1.25  		return NULL;
    1.26  	}
    1.27 -	addr->address = g_strdup(orig->address);
    1.28 -	addr->local_part = l_part ? g_strdup(l_part) :
    1.29 -			g_strdup(orig->local_part);
    1.30 -	addr->domain = dom ? g_strdup(dom) : g_strdup(orig->domain);
    1.31 +	addr->address = g_strstrip(g_strdup(orig->address));
    1.32 +	addr->local_part = g_strstrip(l_part ? g_strdup(l_part) :
    1.33 +			g_strdup(orig->local_part));
    1.34 +	addr->domain = g_strstrip(dom ? g_strdup(dom) :
    1.35 +			g_strdup(orig->domain));
    1.36  	addr->flags = 0;
    1.37  	addr->children = NULL;
    1.38  	addr->parent = NULL;
    1.39 @@ -164,14 +165,12 @@
    1.40  {
    1.41  	static gchar *buffer = NULL;
    1.42  
    1.43 -	if (!addr) {
    1.44 -		g_free(buffer);
    1.45 -		buffer = NULL;
    1.46 -		return NULL;
    1.47 -	}
    1.48  	if (buffer) {
    1.49  		g_free(buffer);
    1.50  	}
    1.51 +	if (!addr) {
    1.52 +		return NULL;
    1.53 +	}
    1.54  	if (!*addr->local_part) {
    1.55  		buffer = g_strdup("<>");
    1.56  	} else {