diff options
Diffstat (limited to 'src/sfsasl.c')
| -rw-r--r-- | src/sfsasl.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/src/sfsasl.c b/src/sfsasl.c index 5209dfa1c3b27..3335608e450c9 100644 --- a/src/sfsasl.c +++ b/src/sfsasl.c @@ -19,7 +19,7 @@ SM_RCSID("@(#)$Id: sfsasl.c,v 8.121 2013-11-22 20:51:56 ca Exp $") /* allow to disable error handling code just in case... */ #ifndef DEAL_WITH_ERROR_SSL # define DEAL_WITH_ERROR_SSL 1 -#endif /* ! DEAL_WITH_ERROR_SSL */ +#endif #if SASL # include "sfsasl.h" @@ -66,7 +66,7 @@ sasl_getinfo(fp, what, valp) case SM_IO_WHAT_FD: if (so->fp == NULL) return -1; - return so->fp->f_file; /* for stdio fileno() compatability */ + return so->fp->f_file; /* for stdio fileno() compatibility */ case SM_IO_IS_READABLE: if (so->fp == NULL) @@ -193,9 +193,9 @@ sasl_read(fp, buf, size) ssize_t len; # if SASL >= 20000 static const char *outbuf = NULL; -# else /* SASL >= 20000 */ +# else static char *outbuf = NULL; -# endif /* SASL >= 20000 */ +# endif static unsigned int outlen = 0; static unsigned int offset = 0; struct sasl_obj *so = (struct sasl_obj *) fp->f_cookie; @@ -214,9 +214,9 @@ sasl_read(fp, buf, size) # if SASL >= 20000 while (outlen == 0) -# else /* SASL >= 20000 */ +# else while (outbuf == NULL && outlen == 0) -# endif /* SASL >= 20000 */ +# endif { len = sm_io_read(so->fp, SM_TIME_DEFAULT, buf, size); if (len <= 0) @@ -255,7 +255,7 @@ sasl_read(fp, buf, size) (void) memcpy(buf, outbuf + offset, (size_t) len); # if SASL < 20000 SASL_DEALLOC(outbuf); -# endif /* SASL < 20000 */ +# endif outbuf = NULL; offset = 0; outlen = 0; @@ -287,9 +287,9 @@ sasl_write(fp, buf, size) int result; # if SASL >= 20000 const char *outbuf; -# else /* SASL >= 20000 */ +# else char *outbuf; -# endif /* SASL >= 20000 */ +# endif unsigned int outlen, *maxencode; size_t ret = 0, total = 0; struct sasl_obj *so = (struct sasl_obj *) fp->f_cookie; @@ -299,7 +299,7 @@ sasl_write(fp, buf, size) ** This can be less than the size set in attemptauth() ** due to a negotiation with the other side, e.g., ** Cyrus IMAP lmtp program sets maxbuf=4096, - ** digestmd5 substracts 25 and hence we'll get 4071 + ** digestmd5 subtracts 25 and hence we'll get 4071 ** instead of 8192 (MAXOUTLEN). ** Hack (for now): simply reduce the size, callers are (must be) ** able to deal with that and invoke sasl_write() again with @@ -339,7 +339,7 @@ sasl_write(fp, buf, size) } # if SASL < 20000 SASL_DEALLOC(outbuf); -# endif /* SASL < 20000 */ +# endif } return size; } @@ -416,6 +416,7 @@ sfdcsasl(fin, fout, conn, tmo) #if STARTTLS # include "sfsasl.h" +# include <tls.h> # include <openssl/err.h> /* Structure used by the "tls" file type */ @@ -461,7 +462,7 @@ tls_getinfo(fp, what, valp) case SM_IO_WHAT_FD: if (so->fp == NULL) return -1; - return so->fp->f_file; /* for stdio fileno() compatability */ + return so->fp->f_file; /* for stdio fileno() compatibility */ case SM_IO_IS_READABLE: return SSL_pending(so->con) > 0; @@ -627,8 +628,7 @@ tls_retry(ssl, rfd, wfd, tlsstart, timeout, err, where) sm_syslog(LOG_ERR, NOQID, "STARTTLS=%s, error: fd %d/%d too large", where, rfd, wfd); - if (LogLevel > 8) - tlslogerr(LOG_WARNING, where); + tlslogerr(LOG_WARNING, 8, where); } errno = EINVAL; } @@ -674,9 +674,9 @@ tls_retry(ssl, rfd, wfd, tlsstart, timeout, err, where) /* errno to force refill() etc to stop (see IS_IO_ERROR()) */ #ifdef ETIMEDOUT # define SM_ERR_TIMEOUT ETIMEDOUT -#else /* ETIMEDOUT */ +#else # define SM_ERR_TIMEOUT EIO -#endif /* ETIMEDOUT */ +#endif /* ** SET_TLS_RD_TMO -- read secured information for the caller @@ -768,15 +768,12 @@ tls_read(fp, buf, size) if (r == 0 && errno == 0) /* out of protocol EOF found */ break; err = "syscall error"; -/* - get_last_socket_error()); -*/ break; case SSL_ERROR_SSL: #if DEAL_WITH_ERROR_SSL if (r == 0 && errno == 0) /* out of protocol EOF found */ break; -#endif /* DEAL_WITH_ERROR_SSL */ +#endif err = "generic SSL error"; if (LogLevel > 9) @@ -787,14 +784,14 @@ tls_read(fp, buf, size) pri = LOG_DEBUG; else pri = LOG_WARNING; - tlslogerr(pri, "read"); + tlslogerr(pri, 9, "read"); } #if DEAL_WITH_ERROR_SSL /* avoid repeated calls? */ if (r == 0) r = -1; -#endif /* DEAL_WITH_ERROR_SSL */ +#endif break; } if (err != NULL) @@ -893,23 +890,19 @@ tls_write(fp, buf, size) if (r == 0 && errno == 0) /* out of protocol EOF found */ break; err = "syscall error"; -/* - get_last_socket_error()); -*/ break; case SSL_ERROR_SSL: err = "generic SSL error"; /* ERR_GET_REASON(ERR_peek_error())); */ - if (LogLevel > 9) - tlslogerr(LOG_WARNING, "write"); + tlslogerr(LOG_WARNING, 9, "write"); #if DEAL_WITH_ERROR_SSL /* avoid repeated calls? */ if (r == 0) r = -1; -#endif /* DEAL_WITH_ERROR_SSL */ +#endif break; } if (err != NULL) |
