commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-366-gd1e06ee


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-366-gd1e06ee
Date: Thu, 31 Mar 2011 18:41:11 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=d1e06eeb9401fea5c5e634888377c48ed682e13c

The branch, master has been updated
       via  d1e06eeb9401fea5c5e634888377c48ed682e13c (commit)
       via  dd07fe07ac35257c75d0f9fb3b8dd02387182a1b (commit)
      from  c1a08f800299ea54f09e37b10513ca66ac1758d9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d1e06eeb9401fea5c5e634888377c48ed682e13c
Author: Sergey Poznyakoff <address@hidden>
Date:   Thu Mar 31 21:37:46 2011 +0300

    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.

commit dd07fe07ac35257c75d0f9fb3b8dd02387182a1b
Author: Sergey Poznyakoff <address@hidden>
Date:   Thu Mar 31 16:50:15 2011 +0300

    cidr: Implement simplified IPv6 formats
    
    * include/mailutils/cidr.h (MU_CIDR_FMT_SIMPLIFY): New format flag.
    * libmailutils/cidr/tostr.c (format_ipv6_bytes): Take additional
    argument, indicating whether to simplify the output.
    (format_ipv6_bytes_normal)
    (format_ipv6_bytes_simplified): New static functions.
    (mu_cidr_to_string): Select appropriate ipv6 printer depending on
    the MU_CIDR_FMT_SIMPLIFY bit.
    * libmailutils/tests/cidr.c (main): New options -s and -S

-----------------------------------------------------------------------

Summary of changes:
 include/mailutils/cidr.h     |    1 +
 libmailutils/cidr/tostr.c    |   96 ++++++++++++++++++++++++++++++++++++------
 libmailutils/filter/base64.c |   48 +++++++++++++--------
 libmailutils/stream/tcp.c    |    4 +-
 libmailutils/tests/cidr.c    |   19 +++++++-
 libproto/mailer/smtp.c       |    5 ++-
 libproto/pop/mbox.c          |    5 ++-
 mu/imap.c                    |    6 ++-
 mu/pop.c                     |    2 +
 9 files changed, 146 insertions(+), 40 deletions(-)

diff --git a/include/mailutils/cidr.h b/include/mailutils/cidr.h
index c54bf62..4f174de 100644
--- a/include/mailutils/cidr.h
+++ b/include/mailutils/cidr.h
@@ -42,6 +42,7 @@ int mu_cidr_from_sockaddr (struct mu_cidr *cp, const struct 
sockaddr *sa);
 int mu_cidr_from_string (struct mu_cidr *cp, const char *str);
 
 #define MU_CIDR_FMT_ADDRONLY 0x01
+#define MU_CIDR_FMT_SIMPLIFY 0x02
   
 int mu_cidr_to_string (struct mu_cidr *cidr, int flags, char *buf, size_t size,
                       size_t *pret);
diff --git a/libmailutils/cidr/tostr.c b/libmailutils/cidr/tostr.c
index 3d1ee5f..0b882ca 100644
--- a/libmailutils/cidr/tostr.c
+++ b/libmailutils/cidr/tostr.c
@@ -34,33 +34,102 @@ to_xdig (unsigned char b)
 
 static size_t
 format_ipv6_bytes (const unsigned char *bytes, int len, 
-                  char *buf, size_t size)
+                  char *buf, size_t size, int simplify)
 {
   size_t total = 0;
   int i;
+  int run_count = 0;
+  char *p;
   
   for (i = 0; i < len; i += 2)
     {
-      if (i)
+      if (bytes[0] == 0 && bytes[1] == 0)
+       {
+         if (simplify)
+           run_count++;
+         else
+           {
+             if (i && total++ < size)
+               *buf++ = ':';
+             if (total++ < size)
+               *buf++ = '0';
+           }
+         bytes += 2;
+       }
+      else
+       {
+         if (run_count)
+           {
+             if (run_count == 1)
+               {
+                 if (i && total++ < size)
+                   *buf++ = ':';
+                 if (total++ < size)
+                   *buf++ = '0';
+               }
+             else
+               {
+                 if (total++ < size)
+                   *buf++ = ':';
+                 simplify = 0;
+               }
+             run_count = 0;
+           }
+         
+         if (i && total++ < size)
+           *buf++ = ':';
+
+         p = buf;
+         if ((*bytes & 0xf0) && total++ < size)
+           *buf++ = to_xdig (*bytes >> 4);
+         if ((buf > p || (*bytes & 0xf)) && total++ < size)
+           *buf++ = to_xdig (*bytes & 0xf);
+         bytes++;
+         if ((buf > p || (*bytes & 0xf0)) && total++ < size)
+           *buf++ = to_xdig (*bytes >> 4);
+         if ((buf > p || (*bytes & 0xf)) && total++ < size)
+           *buf++ = to_xdig (*bytes & 0xf);
+         bytes++;
+       }
+    }
+
+  if (run_count)
+    {
+      if (run_count == 1)
+       {
+         if (i && total++ < size)
+           *buf++ = ':';
+         if (total++ < size)
+           *buf++ = '0';
+       }
+      else
        {
          if (total++ < size)
            *buf++ = ':';
+         if (total++ < size)
+           *buf++ = ':';
        }
-      if (total++ < size)
-       *buf++ = to_xdig (*bytes >> 4);
-      if (total++ < size)
-       *buf++ = to_xdig (*bytes & 0xf);
-      bytes++;
-      if (total++ < size)
-       *buf++ = to_xdig (*bytes >> 4);
-      if (total++ < size)
-       *buf++ = to_xdig (*bytes & 0xf);
-      bytes++;
     }
+  
   return total;
 }
 
 static size_t
+format_ipv6_bytes_normal (const unsigned char *bytes, int len, 
+                         char *buf, size_t size)
+{
+  return format_ipv6_bytes (bytes, len, buf, size, 0);
+}
+
+static size_t
+format_ipv6_bytes_simplified (const unsigned char *bytes, int len, 
+                             char *buf, size_t size)
+{
+  return format_ipv6_bytes (bytes, len, buf, size, 1);
+}
+
+
+static size_t
 format_ipv4_bytes (const unsigned char *bytes, int len, 
                   char *buf, size_t size)
 {
@@ -114,7 +183,8 @@ mu_cidr_to_string (struct mu_cidr *cidr, int flags,
       
 #ifdef MAILUTILS_IPV6
     case AF_INET6:
-      fmt = format_ipv6_bytes;
+      fmt = (flags & MU_CIDR_FMT_SIMPLIFY) ?
+                format_ipv6_bytes_simplified : format_ipv6_bytes_normal;
       break;
 #endif
 
diff --git a/libmailutils/filter/base64.c b/libmailutils/filter/base64.c
index 9873874..d99cdc5 100644
--- a/libmailutils/filter/base64.c
+++ b/libmailutils/filter/base64.c
@@ -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;
     }
 
diff --git a/libmailutils/stream/tcp.c b/libmailutils/stream/tcp.c
index f383f1b..25493f9 100644
--- a/libmailutils/stream/tcp.c
+++ b/libmailutils/stream/tcp.c
@@ -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);
diff --git a/libmailutils/tests/cidr.c b/libmailutils/tests/cidr.c
index 797fb24..6b07fa6 100644
--- a/libmailutils/tests/cidr.c
+++ b/libmailutils/tests/cidr.c
@@ -33,10 +33,12 @@ print_bytes (unsigned char *b, size_t l)
 int
 main (int argc, char **argv)
 {
+  int flags = 0;
+  
   mu_set_program_name (argv[0]);
   if (argc < 2)
     {
-      mu_error ("usage: %s CIDR [CIDR...]", argv[0]);
+      mu_error ("usage: %s [-sS] CIDR [CIDR...]", argv[0]);
       return 1;
     }
 
@@ -46,7 +48,18 @@ main (int argc, char **argv)
       struct mu_cidr cidr;
       int rc;
       char *str;
-      
+
+      if (strcmp (arg, "-s") == 0)
+       {
+         flags |= MU_CIDR_FMT_SIMPLIFY;
+         continue;
+       }
+      else if (strcmp (arg, "-S") == 0)
+       {
+         flags &= ~MU_CIDR_FMT_SIMPLIFY;
+         continue;
+       }
+              
       rc = mu_cidr_from_string (&cidr, arg);
       if (rc)
        {
@@ -61,7 +74,7 @@ main (int argc, char **argv)
       print_bytes (cidr.address, cidr.len);
       printf ("netmask =");
       print_bytes (cidr.netmask, cidr.len);
-      rc = mu_cidr_format (&cidr, 0, &str);
+      rc = mu_cidr_format (&cidr, flags, &str);
       if (rc)
        {
          mu_error ("cannot covert to string: %s", mu_strerror (rc));
diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c
index 892a0ce..6487b67 100644
--- a/libproto/mailer/smtp.c
+++ b/libproto/mailer/smtp.c
@@ -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);
diff --git a/libproto/pop/mbox.c b/libproto/pop/mbox.c
index 79854ae..b3a0203 100644
--- a/libproto/pop/mbox.c
+++ b/libproto/pop/mbox.c
@@ -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)
     {
diff --git a/mu/imap.c b/mu/imap.c
index deea939..4fccd4d 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -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
diff --git a/mu/pop.c b/mu/pop.c
index de092cd..c76f009 100644
--- a/mu/pop.c
+++ b/mu/pop.c
@@ -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)
        {


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]