summaryrefslogtreecommitdiff
path: root/sys/src/cmd/upas/fs
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-09-14 19:19:08 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-09-14 19:19:08 +0200
commit56836bfdbdca9fd6a5b608d249d178a22d3337d8 (patch)
tree75b84ef6650f92a48ba70823cb1e22f27d1d39bd /sys/src/cmd/upas/fs
parentbe5992955d4e417ca625b07af93a800464d4c11f (diff)
tls: fix various tlsClient()/tlsServer() related bugs
- TLSconn structure on stack but not initialized (zeroed) - original filedescriptor double closed in error case - original filedescriptor leaked in success case - leaked TLSconn.sessionID and TLSconn.cert - clarify in pushtls(2) and pushssl(2)
Diffstat (limited to 'sys/src/cmd/upas/fs')
-rw-r--r--sys/src/cmd/upas/fs/pop3.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/src/cmd/upas/fs/pop3.c b/sys/src/cmd/upas/fs/pop3.c
index fbb6f6c5e..257fc8970 100644
--- a/sys/src/cmd/upas/fs/pop3.c
+++ b/sys/src/cmd/upas/fs/pop3.c
@@ -129,6 +129,9 @@ pop3pushtls(Pop *pop)
err = "tls error";
goto out;
}
+ pop->fd = fd;
+ Binit(&pop->bin, pop->fd, OREAD);
+ Binit(&pop->bout, pop->fd, OWRITE);
if(conn.cert==nil || conn.certlen <= 0){
err = "server did not provide TLS certificate";
goto out;
@@ -140,17 +143,10 @@ pop3pushtls(Pop *pop)
err = "bad server certificate";
goto out;
}
- close(pop->fd);
- pop->fd = fd;
pop->encrypted = 1;
- Binit(&pop->bin, pop->fd, OREAD);
- Binit(&pop->bout, pop->fd, OWRITE);
- fd = -1;
out:
free(conn.sessionID);
free(conn.cert);
- if(fd >= 0)
- close(fd);
return err;
}