diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2013-01-01 18:27:25 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2013-01-01 18:27:25 -0300 |
commit | 9a533c36c2858875a31900fc86a3000a8f1d59bc (patch) | |
tree | 2275ea59a085b8458d1b30ef61af35a56bd2b6a9 /test | |
parent | 63a8894243214f850a3ec2d934822a633c8b7cd1 (diff) |
Don't leak a FD if write() fails on a just-connected local dpi socket.
This also fixes the wrong error message given in this situation.
http://lists.auriga.wearlab.de/pipermail/dillo-dev/2012-December/009656.html
Patch: p37sitdu, jcid
Diffstat (limited to 'test')
-rw-r--r-- | test/cookies.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/test/cookies.c b/test/cookies.c index 5461e77e..1036779f 100644 --- a/test/cookies.c +++ b/test/cookies.c @@ -392,7 +392,7 @@ static int Dpi_connect_socket(const char *server_name) } else if (connect(sock_fd, (void*)&sin, sizeof(sin)) == -1) { MSG("[dpi::connect] errno:%d %s\n", errno, dStrerror(errno)); - /* send authentication Key (the server closes sock_fd on error) */ + /* send authentication Key (the server closes sock_fd on auth error) */ } else if (!(cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "auth", SharedKey))) { MSG_ERR("[Dpi_connect_socket] Can't make auth message.\n"); } else if (Dpi_blocking_write(sock_fd, cmd, strlen(cmd)) == -1) { @@ -401,6 +401,8 @@ static int Dpi_connect_socket(const char *server_name) ret = sock_fd; } dFree(cmd); + if (sock_fd != -1 && ret == -1) /* can't send cmd? */ + Dpi_close_fd(sock_fd); return ret; } |