Correct some small details here and there.

This commit is contained in:
Lefteris Chatzimparmpas 2012-02-16 18:49:57 +01:00
parent b67ae8209b
commit 820e9db522
4 changed files with 34 additions and 30 deletions

View File

@ -29,8 +29,7 @@ auth_cram_md5(const char *user, const char *pass, unsigned char *chal)
EVP_DecodeBlock(resp, chal, strlen((char *)(chal)));
HMAC_Init(&hmac, (const unsigned char *)pass, strlen(pass),
EVP_md5());
HMAC_Init(&hmac, (const unsigned char *)pass, strlen(pass), EVP_md5());
HMAC_Update(&hmac, resp, strlen((char *)(resp)));
HMAC_Final(&hmac, md, &mdlen);

View File

@ -148,7 +148,8 @@ open_debug(void)
debugfp = fopen(opts.debug, "w");
if (debugfp == NULL) {
error("opening debug file %s: %s\n", opts.debug, strerror(errno));
error("opening debug file %s: %s\n", opts.debug,
strerror(errno));
return 1;
}
return 0;

View File

@ -219,7 +219,8 @@ response_generic(session *ssn, int tag)
do {
buffer_check(&ibuf, ibuf.len + INPUT_BUF);
if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) == -1)
if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) ==
-1)
return -1;
ibuf.len += n;
@ -247,7 +248,8 @@ response_continuation(session *ssn)
do {
buffer_check(&ibuf, ibuf.len + INPUT_BUF);
if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) == -1)
if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) ==
-1)
return -1;
ibuf.len += n;
@ -353,8 +355,9 @@ response_authenticate(session *ssn, int tag, unsigned char **cont)
if ((r = response_continuation(ssn)) == STATUS_CONTINUE &&
!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0))
*cont = (unsigned char *)xstrndup(ibuf.data + re->pmatch[1].rm_so,
re->pmatch[1].rm_eo - re->pmatch[1].rm_so);
*cont = (unsigned char *)xstrndup(ibuf.data +
re->pmatch[1].rm_so, re->pmatch[1].rm_eo -
re->pmatch[1].rm_so);
return r;
}
@ -571,7 +574,8 @@ response_search(session *ssn, int tag, char **mesgs)
*m = '\0';
}
min = (unsigned int)(re->pmatch[1].rm_eo - re->pmatch[1].rm_so) < ibuf.len ?
min = (unsigned int)(re->pmatch[1].rm_eo -
re->pmatch[1].rm_so) < ibuf.len ?
(unsigned int)(re->pmatch[1].rm_eo - re->pmatch[1].rm_so) :
ibuf.len;
@ -775,7 +779,8 @@ response_fetchbody(session *ssn, int tag, char **body, size_t *len)
do {
buffer_check(&ibuf, ibuf.len + INPUT_BUF);
if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) == -1)
if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) ==
-1)
return -1;
ibuf.len += n;

View File

@ -125,6 +125,7 @@ open_secure_connection(session *ssn)
"connection has been closed cleanly\n",
ssn->server);
goto fail;
case SSL_ERROR_NONE:
case SSL_ERROR_WANT_CONNECT:
case SSL_ERROR_WANT_ACCEPT:
case SSL_ERROR_WANT_X509_LOOKUP:
@ -149,7 +150,7 @@ open_secure_connection(session *ssn)
NULL));
goto fail;
default:
goto fail;
break;
}
}
if (get_option_boolean("certificates") && get_cert(ssn) == -1)
@ -294,9 +295,7 @@ socket_secure_read(session *ssn, char *buf, size_t len)
int r, e;
for (;;) {
r = (ssize_t) SSL_read(ssn->sslsocket, buf, len);
if (r > 0)
if ((r = (ssize_t) SSL_read(ssn->sslsocket, buf, len)) > 0)
break;
switch (SSL_get_error(ssn->sslsocket, r)) {
@ -304,6 +303,7 @@ socket_secure_read(session *ssn, char *buf, size_t len)
error("reading data; the connection has been closed "
"cleanly\n");
return -1;
case SSL_ERROR_NONE:
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_CONNECT:
@ -326,7 +326,7 @@ socket_secure_read(session *ssn, char *buf, size_t len)
ERR_error_string(ERR_get_error(), NULL));
return -1;
default:
return -1;
break;
}
}
@ -342,10 +342,10 @@ ssize_t
socket_write(session *ssn, const char *buf, size_t len)
{
int s;
ssize_t w, wt;
ssize_t r, t;
fd_set fds;
w = wt = 0;
r = t = 0;
s = 1;
FD_ZERO(&fds);
@ -356,28 +356,28 @@ socket_write(session *ssn, const char *buf, size_t len)
FD_ISSET(ssn->socket, &fds))) {
#ifndef NO_SSLTLS
if (ssn->sslsocket) {
w = socket_secure_write(ssn, buf, len);
r = socket_secure_write(ssn, buf, len);
if (w <= 0)
if (r <= 0)
goto fail;
} else
#endif
{
w = write(ssn->socket, buf, len);
r = write(ssn->socket, buf, len);
if (w == -1) {
if (r == -1) {
error("writing data; %s\n",
strerror(errno));
goto fail;
} else if (w == 0) {
} else if (r == 0) {
goto fail;
}
}
if (w > 0) {
len -= w;
buf += w;
wt += w;
if (r > 0) {
len -= r;
buf += r;
t += r;
}
}
}
@ -390,7 +390,7 @@ socket_write(session *ssn, const char *buf, size_t len)
goto fail;
}
return wt;
return t;
fail:
close_connection(ssn);
@ -408,9 +408,7 @@ socket_secure_write(session *ssn, const char *buf, size_t len)
int r, e;
for (;;) {
r = (ssize_t) SSL_write(ssn->sslsocket, buf, len);
if (r > 0)
if ((r = (ssize_t) SSL_write(ssn->sslsocket, buf, len)) > 0)
break;
switch (SSL_get_error(ssn->sslsocket, r)) {
@ -418,6 +416,7 @@ socket_secure_write(session *ssn, const char *buf, size_t len)
error("writing data; the connection has been closed "
"cleanly\n");
return -1;
case SSL_ERROR_NONE:
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_CONNECT:
@ -440,7 +439,7 @@ socket_secure_write(session *ssn, const char *buf, size_t len)
ERR_error_string(ERR_get_error(), NULL));
return -1;
default:
return -1;
break;
}
}