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
...@@ -287,6 +287,15 @@ _base64_encoder (void *xd, ...@@ -287,6 +287,15 @@ _base64_encoder (void *xd,
287 if (!(consumed + 3 <= isize || pad)) 287 if (!(consumed + 3 <= isize || pad))
288 break; 288 break;
289 289
290 if (consumed == isize)
291 {
292 lp->save[1] = x;
293 lp->save[2] = y;
294 lp->idx = 1;
295 lp->state = base64_rollback;
296 }
297 else
298 {
290 *optr++ = b64tab[ptr[0] >> 2]; 299 *optr++ = b64tab[ptr[0] >> 2];
291 nbytes++; 300 nbytes++;
292 lp->cur_len++; 301 lp->cur_len++;
...@@ -310,6 +319,7 @@ _base64_encoder (void *xd, ...@@ -310,6 +319,7 @@ _base64_encoder (void *xd,
310 } 319 }
311 320
312 ptr += 3; 321 ptr += 3;
322 }
313 pad = 0; 323 pad = 0;
314 } 324 }
315 325
......
...@@ -332,7 +332,7 @@ mu_tcp_stream_create_with_source_ip (mu_stream_t *pstream, ...@@ -332,7 +332,7 @@ mu_tcp_stream_create_with_source_ip (mu_stream_t *pstream,
332 } 332 }
333 333
334 rc = mu_tcp_stream_create_from_sa (pstream, remote_addr, source_addr, flags); 334 rc = mu_tcp_stream_create_from_sa (pstream, remote_addr, source_addr, flags);
335 if (rc) 335 if (rc && !(rc == EAGAIN || rc == EINPROGRESS))
336 { 336 {
337 mu_sockaddr_free (remote_addr); 337 mu_sockaddr_free (remote_addr);
338 mu_sockaddr_free (source_addr); 338 mu_sockaddr_free (source_addr);
...@@ -371,7 +371,7 @@ mu_tcp_stream_create_with_source_host (mu_stream_t *stream, ...@@ -371,7 +371,7 @@ mu_tcp_stream_create_with_source_host (mu_stream_t *stream,
371 } 371 }
372 372
373 rc = mu_tcp_stream_create_from_sa (stream, remote_addr, source_addr, flags); 373 rc = mu_tcp_stream_create_from_sa (stream, remote_addr, source_addr, flags);
374 if (rc) 374 if (rc && !(rc == EAGAIN || rc == EINPROGRESS))
375 { 375 {
376 mu_sockaddr_free (remote_addr); 376 mu_sockaddr_free (remote_addr);
377 mu_sockaddr_free (source_addr); 377 mu_sockaddr_free (source_addr);
......
...@@ -175,7 +175,10 @@ smtp_open (mu_mailer_t mailer, int flags) ...@@ -175,7 +175,10 @@ smtp_open (mu_mailer_t mailer, int flags)
175 rc = mu_tcp_stream_create_from_sa (&mailer->stream, sa, NULL, 175 rc = mu_tcp_stream_create_from_sa (&mailer->stream, sa, NULL,
176 mailer->flags); 176 mailer->flags);
177 if (rc) 177 if (rc)
178 {
179 mu_sockaddr_free (sa);
178 return rc; 180 return rc;
181 }
179 mu_stream_set_buffer (mailer->stream, mu_buffer_line, 0); 182 mu_stream_set_buffer (mailer->stream, mu_buffer_line, 0);
180 } 183 }
181 mu_smtp_set_carrier (smtp_mailer->smtp, mailer->stream); 184 mu_smtp_set_carrier (smtp_mailer->smtp, mailer->stream);
......
...@@ -132,7 +132,10 @@ pop_open (mu_mailbox_t mbox, int flags) ...@@ -132,7 +132,10 @@ pop_open (mu_mailbox_t mbox, int flags)
132 132
133 status = mu_tcp_stream_create_from_sa (&stream, sa, NULL, mbox->flags); 133 status = mu_tcp_stream_create_from_sa (&stream, sa, NULL, mbox->flags);
134 if (status) 134 if (status)
135 {
136 mu_sockaddr_free (sa);
135 return status; 137 return status;
138 }
136 #ifdef WITH_TLS 139 #ifdef WITH_TLS
137 if (mpd->pops) 140 if (mpd->pops)
138 { 141 {
......
...@@ -217,7 +217,11 @@ com_connect (int argc, char **argv) ...@@ -217,7 +217,11 @@ com_connect (int argc, char **argv)
217 hints.socktype = SOCK_STREAM; 217 hints.socktype = SOCK_STREAM;
218 status = mu_sockaddr_from_node (&sa, argv[0], argv[1], &hints); 218 status = mu_sockaddr_from_node (&sa, argv[0], argv[1], &hints);
219 if (status == 0) 219 if (status == 0)
220 {
220 status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0); 221 status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0);
222 if (status)
223 mu_sockaddr_free (sa);
224 }
221 if (status == 0) 225 if (status == 0)
222 { 226 {
223 #ifdef WITH_TLS 227 #ifdef WITH_TLS
......
...@@ -542,6 +542,8 @@ com_connect (int argc, char **argv) ...@@ -542,6 +542,8 @@ com_connect (int argc, char **argv)
542 { 542 {
543 n = port_from_sa (sa); 543 n = port_from_sa (sa);
544 status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0); 544 status = mu_tcp_stream_create_from_sa (&tcp, sa, NULL, 0);
545 if (status)
546 mu_sockaddr_free (sa);
545 } 547 }
546 if (status == 0) 548 if (status == 0)
547 { 549 {
......