]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.10-20120713
authorWietse Venema <wietse@porcupine.org>
Fri, 13 Jul 2012 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:38:14 +0000 (06:38 +0000)
postfix/HISTORY
postfix/makedefs
postfix/src/dns/dns_sa_to_rr.ref
postfix/src/global/mail_version.h
postfix/src/local/biff_notify.c
postfix/src/util/binhash.c
postfix/src/util/htable.c
postfix/src/util/myaddrinfo.ref
postfix/src/util/vstream.c
postfix/src/util/vstream_tweak.c

index 9426fafe081e487ec94f1d683ccce82a78a69ae2..3058d8fb6af7883e853273f7e5b2e6c387f907fa 100644 (file)
@@ -17877,3 +17877,20 @@ Apologies for any names omitted.
 20120629
 
        Workaround: "sendmail -bl" emulation. File: sendmail/sendmail.c.
+
+20120630
+
+       Cleanup: sub-optimal hash performance on systems where the
+       "char" type is signed.  Files: util/htable.c, util/binhash.c.
+
+20120702
+
+       Bugfix (introduced: 19990127): the BIFF client leaked an
+       unprivileged UDP socket. Fix by Jaroslav Skarvada.  File:
+       local/biff_notify.c.
+
+20120713
+
+       Bugfix (introduced: 20120527-8): infrastructure to specify
+       a smaller-than-default VSTREAM buffer, without the complex
+       run-time checks. File: util/vstream.c, vstream_tweak.c.
index 92a9717c37469ea5e8fe901d2068cea42189c97f..d9149b4e5af0bd94fcf6f379ef32773f8103279e 100644 (file)
@@ -367,7 +367,7 @@ EOF
                esac
                for name in nsl resolv
                do
-                   for lib in /usr/lib64 /lib64 /usr/lib /lib
+                   for lib in /usr/lib64 /lib64 /usr/lib /usr/lib/* /lib /lib/*
                    do
                        test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
                            SYSLIBS="$SYSLIBS -l$name"
index 86c022d56a6aecc8832bf4ef2761f113d1e9948a..0b67b74e23388b89459aa4ebbf8c23749267483e 100644 (file)
@@ -1,2 +1,2 @@
-spike.porcupine.org -> 168.100.189.2
 spike.porcupine.org -> 2604:8d00:189::2
+spike.porcupine.org -> 168.100.189.2
index 4479ab0e41f43ebe853e8183455c317f8e16c539..965b8a07f84d92acf50f7afa292327f9fff074c5 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change both the patchlevel and the release date. Snapshots have no
   * patchlevel; they change the release date only.
   */
-#define MAIL_RELEASE_DATE      "20120630"
+#define MAIL_RELEASE_DATE      "20120713"
 #define MAIL_VERSION_NUMBER    "2.10"
 
 #ifdef SNAPSHOT
index b189ad4b2d4a7302971ed279971b7ec3538644d2..ca7dc1645b1a18180a6c6ebaf4216a8ab59b0e34 100644 (file)
@@ -43,6 +43,7 @@
 /* Utility library. */
 
 #include <msg.h>
+#include <iostuff.h>
 
 /* Application-specific. */
 
@@ -81,9 +82,12 @@ void    biff_notify(const char *text, ssize_t len)
     /*
      * Open a socket, or re-use an existing one.
      */
-    if (sock < 0 && (sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-       msg_warn("socket: %m");
-       return;
+    if (sock < 0) {
+       if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+           msg_warn("socket: %m");
+           return;
+       }
+       close_on_exec(sock, CLOSE_ON_EXEC);
     }
 
     /*
index b877f77eecace78e0c9ab69bbcc2794447b689cf..84ca87c75d2220db91d328ae6d9e87432fa93a6a 100644 (file)
@@ -134,7 +134,7 @@ static unsigned binhash_hash(const char *key, int len, unsigned size)
      */
 
     while (len-- > 0) {
-       h = (h << 4U) + *key++;
+       h = (h << 4U) + *(unsigned const char *) key++;
        if ((g = (h & 0xf0000000)) != 0) {
            h ^= (g >> 24U);
            h ^= g;
index 3fc981a35558f60a7b03be495ea0b2ec9cdb83db..009e0fcdf0d1dacb656d4487ec12cb10c42f974c 100644 (file)
@@ -138,7 +138,7 @@ static unsigned htable_hash(const char *s, unsigned size)
      */
 
     while (*s) {
-       h = (h << 4U) + *s++;
+       h = (h << 4U) + *(unsigned const char *) s++;
        if ((g = (h & 0xf0000000)) != 0) {
            h ^= (g >> 24U);
            h ^= g;
index 360228a10b637e7d732e33f55bff70e39575b105..f0da580cbddc601145e20493a2fffff225bbed96 100644 (file)
@@ -1,8 +1,8 @@
 ./myaddrinfo: === hostname belly.porcupine.org ===
-./myaddrinfo: belly.porcupine.org -> family=2 sock=1 proto=6 168.100.189.6
-./myaddrinfo: 168.100.189.6 -> belly.porcupine.org
 ./myaddrinfo: belly.porcupine.org -> family=28 sock=1 proto=6 2604:8d00:189::6
 ./myaddrinfo: 2604:8d00:189::6 -> belly.porcupine.org
+./myaddrinfo: belly.porcupine.org -> family=2 sock=1 proto=6 168.100.189.6
+./myaddrinfo: 168.100.189.6 -> belly.porcupine.org
 ./myaddrinfo: === host address 168.100.189.2 ===
 ./myaddrinfo: 168.100.189.2 -> family=2 sock=1 proto=6 168.100.189.2
 ./myaddrinfo: 168.100.189.2 -> spike.porcupine.org
index 38eb02246aa974424aea1ce96472a75b97d435bc..7a7b7dbcb36fc75028c5de1b717b1093f44e0500 100644 (file)
 /*     This involves allocation of additional memory that normally isn't
 /*     used.
 /* .IP "VSTREAM_CTL_BUFSIZE (ssize_t)"
-/*     Specify a non-default buffer size, or zero to implement
-/*     a no-op. Requests to resize a fixed-size buffer (stderr)
-/*     are not allowed.
+/*     Specify a non-default write buffer size, or zero to implement
+/*     a no-op. Requests to shrink an existing buffer size are
+/*     silently ignored. To get a buffer size smaller than
+/*     VSTREAM_BUFSIZE, make the VSTREAM_CTL_BUFSIZE before the
+/*     stream has been used. Requests to change a fixed-size buffer
+/*     (e.g., stderr) are not allowed.
 /*
 /*     NOTE: the VSTREAM_CTL_BUFSIZE request specifies intent, not
 /*     reality.  Actual buffer sizes are not updated immediately.
-/*     Instead, a write buffer size will be updated when writing
-/*     to a stream for the first time, or when writing to a full
-/*     buffer, and a read buffer size will be updated when reading
-/*     from a stream for the first time, or when reading from an
-/*     empty buffer.
+/*     Instead, an existing write buffer will be resized when it
+/*     is full, and an existing read buffer will be resized when
+/*     the buffer is filled.
 /*
 /*     NOTE: the vstream_*printf() routines may silently expand a
 /*     buffer, so that the result of some %letter specifiers can
@@ -503,13 +504,13 @@ VSTREAM vstream_fstd[] = {
            0, 0, 0, 0,                 /* buffer */
            vstream_buf_get_ready, vstream_buf_put_ready, vstream_buf_space,
     }, STDIN_FILENO, (VSTREAM_FN) timed_read, (VSTREAM_FN) timed_write,
-    VSTREAM_BUFSIZE,},
+    0,},
     {{
            0,                          /* flags */
            0, 0, 0, 0,                 /* buffer */
            vstream_buf_get_ready, vstream_buf_put_ready, vstream_buf_space,
     }, STDOUT_FILENO, (VSTREAM_FN) timed_read, (VSTREAM_FN) timed_write,
-    VSTREAM_BUFSIZE,},
+    0,},
     {{
            VBUF_FLAG_FIXED | VSTREAM_FLAG_WRITE,
            vstream_fstd_buf, VSTREAM_BUFSIZE, VSTREAM_BUFSIZE, vstream_fstd_buf,
@@ -626,17 +627,10 @@ static void vstream_buf_alloc(VBUF *bp, ssize_t len)
     ssize_t used = bp->ptr - bp->data;
     const char *myname = "vstream_buf_alloc";
 
-    /*
-     * Don't shrink a non-empty read buffer, or a non-flushed write buffer.
-     */
-    if (len <= 0)
-       msg_panic("%s: bad buffer length: %ld", myname, (long) len);
-    if (len < bp->len
-       && (((bp->flags & VSTREAM_FLAG_READ) && bp->cnt != 0)
-           || ((bp->flags & VSTREAM_FLAG_WRITE) && bp->cnt != bp->len)))
-       msg_panic("%s: attempt to shrink non-empty buffer", myname);
+    if (len < bp->len)
+       msg_panic("%s: attempt to shrink buffer", myname);
     if (bp->flags & VSTREAM_FLAG_FIXED)
-       msg_panic("%s: attempt to resize fixed-length buffer", myname);
+       msg_panic("%s: unable to extend fixed-size buffer", myname);
 
     /*
      * Late buffer allocation allows the user to override the default policy.
@@ -853,8 +847,12 @@ static int vstream_buf_get_ready(VBUF *bp)
      * If this is the first GET operation, allocate a buffer. Late buffer
      * allocation gives the application a chance to override the default
      * buffering policy.
+     * 
+     * XXX Tricky code to set the preferred buffer size as late as possible.
      */
-    if (bp->len != stream->req_bufsize)
+    if (stream->req_bufsize == 0)
+       stream->req_bufsize = VSTREAM_BUFSIZE;
+    if (bp->len < stream->req_bufsize)
        vstream_buf_alloc(bp, stream->req_bufsize);
 
     /*
@@ -961,15 +959,17 @@ static int vstream_buf_put_ready(VBUF *bp)
      * stream or if the buffer is smaller than the requested size, allocate a
      * new buffer; obviously there is no data to be flushed yet. Otherwise,
      * flush the buffer.
+     * 
+     * XXX Tricky code to set the preferred buffer size as late as possible.
      */
+    if (stream->req_bufsize == 0)
+       stream->req_bufsize = VSTREAM_BUFSIZE;
     if (bp->len < stream->req_bufsize) {
        vstream_buf_alloc(bp, stream->req_bufsize);
     } else if (bp->cnt <= 0) {
        if (VSTREAM_FFLUSH_SOME(stream))
            return (VSTREAM_EOF);
     }
-    if (bp->len > stream->req_bufsize)
-       vstream_buf_alloc(bp, stream->req_bufsize);
     return (0);
 }
 
@@ -1014,10 +1014,14 @@ static int vstream_buf_space(VBUF *bp, ssize_t want)
      * VSTREAM_BUFSIZE bytes and resize the buffer to a multiple of
      * VSTREAM_BUFSIZE. We flush multiples of VSTREAM_BUFSIZE in an attempt
      * to keep file updates block-aligned for better performance.
+     * 
+     * XXX Tricky code to set the preferred buffer size as late as possible.
      */
 #define VSTREAM_TRUNCATE(count, base)  (((count) / (base)) * (base))
 #define VSTREAM_ROUNDUP(count, base)   VSTREAM_TRUNCATE(count + base - 1, base)
 
+    if (stream->req_bufsize == 0)
+       stream->req_bufsize = VSTREAM_BUFSIZE;
     if (want > bp->cnt) {
        if ((used = bp->len - bp->cnt) > stream->req_bufsize)
            if (vstream_fflush_some(stream, VSTREAM_TRUNCATE(used, stream->req_bufsize)))
@@ -1231,7 +1235,7 @@ VSTREAM *vstream_fdopen(int fd, int flags)
     stream->jbuf = 0;
     stream->iotime.tv_sec = stream->iotime.tv_usec = 0;
     stream->time_limit.tv_sec = stream->time_limit.tv_usec = 0;
-    stream->req_bufsize = VSTREAM_BUFSIZE;
+    stream->req_bufsize = 0;
     return (stream);
 }
 
@@ -1482,7 +1486,8 @@ void    vstream_control(VSTREAM *stream, int name,...)
            if (req_bufsize < 0 || req_bufsize > INT_MAX)
                msg_panic("unreasonable VSTREAM_CTL_BUFSIZE request: %ld",
                          (long) req_bufsize);
-           if (req_bufsize > 0 && stream != VSTREAM_ERR)
+           if (stream != VSTREAM_ERR
+               && req_bufsize > stream->req_bufsize)
                stream->req_bufsize = req_bufsize;
            break;
 
@@ -1625,9 +1630,9 @@ int     main(int argc, char **argv)
      * Test buffer expansion and shrinking. Formatted print may silently
      * expand the write buffer and cause multiple bytes to be written.
      */
-    copy_line(1);                              /* one-byte read/write */
+    copy_line(1);                      /* one-byte read/write */
     copy_line(2);                              /* two-byte read/write */
-    copy_line(1);                              /* one-byte read/write */
+    copy_line(1);                              /* two-byte read/write */
     printf_number();                           /* multi-byte write */
     exit(0);
 }
index 166ffc0c8e3b34a6cd1ab520e25095be3d425708..5c528376a6df859a01e15e354eb05df391168e20 100644 (file)
@@ -116,12 +116,12 @@ int     vstream_tweak_tcp(VSTREAM *fp)
 
     /*
      * Fix for recent Postfix versions: increase the VSTREAM buffer size if
-     * the VSTREAM buffer is smaller than the MSS. Note: the MSS may change
-     * when the route changes and IP path MTU discovery is turned on, so we
-     * choose a somewhat larger buffer.
+     * the default VSTREAM buffer size is smaller than the MSS. Note: the MSS
+     * may change when the route changes and IP path MTU discovery is turned
+     * on, so we choose a somewhat larger buffer.
      */
 #ifdef VSTREAM_CTL_BUFSIZE
-    if (mss > 0) {
+    if (mss > VSTREAM_BUFSIZE) {
        if (mss < INT_MAX / 2)
            mss *= 2;
        vstream_control(fp,