masqmail
changeset 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 | cff967b2f51e |
children | 8a62bebda631 |
files | src/accept.c src/address.c src/conf.c |
diffstat | 3 files changed, 16 insertions(+), 17 deletions(-) [+] |
line diff
1.1 --- a/src/accept.c Wed Feb 29 12:05:47 2012 +0100 1.2 +++ b/src/accept.c Wed Feb 29 12:06:33 2012 +0100 1.3 @@ -199,8 +199,7 @@ 1.4 1.5 DEBUG(5) debugf("hdr->value = '%s'\n", hdr->value); 1.6 1.7 - addr = g_strdup(hdr->value); 1.8 - g_strchomp(addr); 1.9 + addr = g_strstrip(g_strdup(hdr->value)); 1.10 msg->return_path = create_address_qualified(addr, 1.11 FALSE, msg->received_host); 1.12 if (msg->return_path) {
2.1 --- a/src/address.c Wed Feb 29 12:05:47 2012 +0100 2.2 +++ b/src/address.c Wed Feb 29 12:06:33 2012 +0100 2.3 @@ -37,7 +37,7 @@ 2.4 address *addr = create_address(path, is_rfc821); 2.5 2.6 if (addr && !addr->domain) { 2.7 - addr->domain = g_strdup(domain); 2.8 + addr->domain = g_strstrip(g_strdup(domain)); 2.9 } 2.10 return addr; 2.11 } 2.12 @@ -50,8 +50,8 @@ 2.13 2.14 if (addr) { 2.15 memset(addr, 0, sizeof(address)); 2.16 - addr->address = g_strchomp(g_strdup(path)); 2.17 - addr->local_part = g_strdup(addr->address); 2.18 + addr->address = g_strstrip(g_strdup(path)); 2.19 + addr->local_part = g_strstrip(g_strdup(addr->address)); 2.20 addr->domain = g_strdup("localhost"); /* quick hack */ 2.21 } 2.22 return addr; 2.23 @@ -78,10 +78,11 @@ 2.24 if (!(addr = g_malloc(sizeof(address)))) { 2.25 return NULL; 2.26 } 2.27 - addr->address = g_strdup(orig->address); 2.28 - addr->local_part = l_part ? g_strdup(l_part) : 2.29 - g_strdup(orig->local_part); 2.30 - addr->domain = dom ? g_strdup(dom) : g_strdup(orig->domain); 2.31 + addr->address = g_strstrip(g_strdup(orig->address)); 2.32 + addr->local_part = g_strstrip(l_part ? g_strdup(l_part) : 2.33 + g_strdup(orig->local_part)); 2.34 + addr->domain = g_strstrip(dom ? g_strdup(dom) : 2.35 + g_strdup(orig->domain)); 2.36 addr->flags = 0; 2.37 addr->children = NULL; 2.38 addr->parent = NULL; 2.39 @@ -164,14 +165,12 @@ 2.40 { 2.41 static gchar *buffer = NULL; 2.42 2.43 - if (!addr) { 2.44 - g_free(buffer); 2.45 - buffer = NULL; 2.46 - return NULL; 2.47 - } 2.48 if (buffer) { 2.49 g_free(buffer); 2.50 } 2.51 + if (!addr) { 2.52 + return NULL; 2.53 + } 2.54 if (!*addr->local_part) { 2.55 buffer = g_strdup("<>"); 2.56 } else {
3.1 --- a/src/conf.c Wed Feb 29 12:05:47 2012 +0100 3.2 +++ b/src/conf.c Wed Feb 29 12:06:33 2012 +0100 3.3 @@ -380,8 +380,8 @@ 3.4 if (!read_lval(in, lval, lsize)) { 3.5 return FALSE; 3.6 } 3.7 - 3.8 - DEBUG(9) fprintf(stderr, " lval = %s\n", lval); 3.9 + g_strstrip(lval); 3.10 + DEBUG(9) fprintf(stderr, " lval = `%s'\n", lval); 3.11 if ((c = fgetc(in) != '=')) { 3.12 fprintf(stderr, "'=' expected after %s, char was '%c'\n", 3.13 lval, c); 3.14 @@ -389,7 +389,8 @@ 3.15 if (!read_rval(in, rval, rsize)) { 3.16 return FALSE; 3.17 } 3.18 - DEBUG(9) fprintf(stderr, " rval = %s\n", rval); 3.19 + g_strstrip(rval); 3.20 + DEBUG(9) fprintf(stderr, " rval = `%s'\n", rval); 3.21 return TRUE; 3.22 } 3.23