rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | LICENSE

commit 77cfd99a75372cb70788a836f1319c16d93112da
parent b5c203aa92d700eef63dd5d983322dc24fc8a37a
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 20 Jun 2015 19:54:16 +0200

Sieve now halts on invalid netspec and _DEFAULT_SOURCE is added.

Diffstat:
config.mk | 2+-
net.c | 1+
sieve.c | 18++++++++++++------
3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/config.mk b/config.mk @@ -14,7 +14,7 @@ INCS = -I. -I/usr/include LIBS = -L/usr/lib -lc -lssl -lcrypto -lz -ldl # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600 -D_SVID_SOURCE -D_GNU_SOURCE +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_GNU_SOURCE CFLAGS = -g -std=gnu99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} LDFLAGS = -g ${LIBS} #LDFLAGS = -s ${LIBS} diff --git a/net.c b/net.c @@ -57,6 +57,7 @@ net_new(char *desc) state = -1; toks = NULL; + ret = NULL; buf = memdup(desc, strlen(desc)+1); tok = strtok_r(buf, "!", &toks); diff --git a/sieve.c b/sieve.c @@ -115,6 +115,9 @@ int sieve_connect(sieve_t *sieve) { sieve->fd = net_new(sieve->netspec); + if (sieve->fd == NULL) + return 1; + if (net_connect(sieve->fd)) { net_free(sieve->fd); sieve->fd = NULL; @@ -389,23 +392,26 @@ sieve_init(sieve_t *sieve) llistelem_t *result; if (sieve_connect(sieve)) - edie("sieve_connect"); + die("sieve_connect: Netspec or credentials invalid.\n"); if (sieve_capabilities(sieve)) - edie("sieve_capabilities"); + die("sieve_capabilities: Could not get capabilities.\n"); result = llist_get(sieve->caps, "STARTTLS"); if (result != NULL) { if (sieve_starttls(sieve)) { - edie("sieve_starttls"); + die("sieve_starttls: Could not setupt STARTTLS.\n"); } else { - if (sieve_capabilities(sieve)) - edie("sieve_capabilities"); + if (sieve_capabilities(sieve)) { + die("sieve_capabilities: Could not get "\ + "capabilities after "\ + "STARTTLS\n"); + } } } if (sieve_authenticate(sieve)) - sieve_die("sieve_authenticatie"); + sieve_die("sieve_authenticate"); sieve->state = LOGGEDIN; }