Commit d1e06eeb d1e06eeb9401fea5c5e634888377c48ed682e13c by Sergey Poznyakoff

Bugfixes

* libmailutils/filter/base64.c (_base64_encoder): Fix for the case
when cmd==mu_filter_lastbuf and isize==0.

* libmailutils/stream/tcp.c (mu_tcp_stream_create_with_source_ip)
(mu_tcp_stream_create_with_source_host): Don't treat EAGAIN and
EINPROGRESS as errors.
* libproto/mailer/smtp.c (smtp_open): Free sockaddr if
mu_tcp_stream_create_from_sa failed.
* libproto/pop/mbox.c (pop_open): Likewise.
* mu/imap.c (com_connect): Likewise.
* mu/pop.c (com_connect): Likewise.
1 parent dd07fe07
......@@ -286,30 +286,40 @@ _base64_encoder (void *xd,
if (!(consumed + 3 <= isize || pad))
break;
*optr++ = b64tab[ptr[0] >> 2];
nbytes++;
lp->cur_len++;
consumed++;
switch (isize - consumed)
if (consumed == isize)
{
default:
consumed++;
y = b64tab[ptr[2] & 0x3f];
c2 = ptr[2] >> 6;
case 1:
consumed++;
x = b64tab[((ptr[1] << 2) + c2) & 0x3f];
c1 = (ptr[1] >> 4);
case 0:
lp->save[0] = b64tab[((ptr[0] << 4) + c1) & 0x3f];
lp->save[1] = x;
lp->save[2] = y;
lp->idx = 0;
lp->idx = 1;
lp->state = base64_rollback;
}
ptr += 3;
else
{
*optr++ = b64tab[ptr[0] >> 2];
nbytes++;
lp->cur_len++;
consumed++;
switch (isize - consumed)
{
default:
consumed++;
y = b64tab[ptr[2] & 0x3f];
c2 = ptr[2] >> 6;
case 1:
consumed++;
x = b64tab[((ptr[1] << 2) + c2) & 0x3f];
c1 = (ptr[1] >> 4);
case 0:
lp->save[0] = b64tab[((ptr[0] << 4) + c1) & 0x3f];
lp->save[1] = x;
lp->save[2] = y;
lp->idx = 0;
lp->state = base64_rollback;
}
ptr += 3;
}
pad = 0;
}
......
......@@ -332,7 +332,7 @@ mu_tcp_stream_create_with_source_ip (mu_stream_t *pstream,
}
rc = mu_tcp_stream_create_from_sa (pstream, remote_addr, source_addr, flags);
if (rc)
if (rc && !(rc == EAGAIN || rc == EINPROGRESS))
{
mu_sockaddr_free (remote_addr);
mu_sockaddr_free (source_addr);
......@@ -371,7 +371,7 @@ mu_tcp_stream_create_with_source_host (mu_stream_t *stream,
}
rc = mu_tcp_stream_create_from_sa (stream, remote_addr, source_addr, flags);
if (rc)
if (rc && !(rc == EAGAIN || rc == EINPROGRESS))
{
mu_sockaddr_free (remote_addr);
mu_sockaddr_free (source_addr);
......
......@@ -175,7 +175,10 @@ smtp_open (mu_mailer_t mailer, int flags)
rc = mu_tcp_stream_create_from_sa (&mailer->stream, sa, NULL,
mailer->flags);
if (rc)
return rc;
{
mu_sockaddr_free (sa);
return rc;
}
mu_stream_set_buffer (mailer->stream, mu_buffer_line, 0);
}
mu_smtp_set_carrier (smtp_mailer->smtp, mailer->stream);
......
......@@ -132,7 +132,10 @@ pop_open (mu_mailbox_t mbox, int flags)
status = mu_tcp_stream_create_from_sa (&stream, sa, NULL, mbox->flags);
if (status)
return status;
{
mu_sockaddr_free (sa);
return status;
}
#ifdef WITH_TLS
if (mpd->pops)
{
......
......@@ -217,7 +217,11 @@ com_connect (int argc, char **argv)
hints.socktype = SOCK_STREAM;
status = mu_sockaddr_from_node (&sa, argv[0], argv[1], &hints);
if (status == 0)
status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0);
{
status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0);
if (status)
mu_sockaddr_free (sa);
}
if (status == 0)
{
#ifdef WITH_TLS
......
......@@ -542,6 +542,8 @@ com_connect (int argc, char **argv)
{
n = port_from_sa (sa);
status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0);
if (status)
mu_sockaddr_free (sa);
}
if (status == 0)
{
......