diff options
author | Tim Rühsen <tim.ruehsen@gmx.de> | 2019-02-06 11:30:06 +0100 |
---|---|---|
committer | Tim Rühsen <tim.ruehsen@gmx.de> | 2019-02-18 21:40:45 +0100 |
commit | 34988aa20369cb71e59b94772132b5efab6bc076 (patch) | |
tree | 84d801fb5bbc82581789053eebbd4dc66ce1b463 /src | |
parent | 72fb20c6c0a2a6c2e70b073994df4b48e04d3b0b (diff) | |
download | gnutls-34988aa20369cb71e59b94772132b5efab6bc076.tar.gz |
gnutls-cli: Fix --starttls-proto=xmpp
Fixes two issues with gnutls-cli --starttls-proto=xmpp:
1. Print 'Timeout' on timeout instead of random errno message
2. Do not wait for linefeed when using XMPP (XML)
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/socket.c b/src/socket.c index dcffe6bc9c..20b17cef3c 100644 --- a/src/socket.c +++ b/src/socket.c @@ -177,13 +177,13 @@ ssize_t wait_for_text(socket_st * socket, const char *txt, unsigned txt_size) tv.tv_sec = 10; tv.tv_usec = 0; ret = select(socket->fd + 1, &read_fds, NULL, NULL, &tv); - if (ret <= 0) - ret = -1; - else + if (ret > 0) ret = recv(socket->fd, pbuf, left, 0); - if (ret == -1 || ret == 0) { - int e = errno; - fprintf(stderr, "error receiving %s: %s\n", txt, strerror(e)); + if (ret == -1) { + fprintf(stderr, "error receiving '%s': %s\n", txt, strerror(errno)); + exit(2); + } else if (ret == 0) { + fprintf(stderr, "error receiving '%s': Timeout\n", txt); exit(2); } pbuf[ret] = 0; @@ -204,8 +204,8 @@ ssize_t wait_for_text(socket_st * socket, const char *txt, unsigned txt_size) p = memmem(buf, got, txt, txt_size); if (p != NULL && p != buf) { p--; - if (*p == '\n' || *p == '\r') - break; + if (*p == '\n' || *p == '\r' || (*txt == '<' && *p == '>')) // XMPP is not line oriented, uses XML format + break; } } } while(got < txt_size || strncmp(buf, txt, txt_size) != 0); |