]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.3-20050716
authorWietse Venema <wietse@porcupine.org>
Sat, 16 Jul 2005 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:31:22 +0000 (06:31 +0000)
29 files changed:
postfix/HISTORY
postfix/RELEASE_NOTES
postfix/makedefs
postfix/src/bounce/bounce_notify_util.c
postfix/src/dns/dns_lookup.c
postfix/src/global/mail_version.h
postfix/src/global/pipe_command.c
postfix/src/global/record.c
postfix/src/global/smtp_stream.c
postfix/src/lmtp/lmtp_chat.c
postfix/src/lmtp/lmtp_sasl_glue.c
postfix/src/smtp/smtp.h
postfix/src/smtp/smtp_chat.c
postfix/src/smtp/smtp_sasl_glue.c
postfix/src/smtpd/smtpd.c
postfix/src/smtpd/smtpd_chat.c
postfix/src/smtpd/smtpd_check.c
postfix/src/smtpstone/qmqp-source.c
postfix/src/tls/tls_scache.c
postfix/src/trivial-rewrite/resolve.c
postfix/src/util/environ.c
postfix/src/util/inet_addr_host.c
postfix/src/util/line_wrap.c
postfix/src/util/line_wrap.h
postfix/src/util/netstring.c
postfix/src/util/vstring.h
postfix/src/util/vstring_vstream.c
postfix/src/util/vstring_vstream.h
postfix/src/util/write_buf.c

index 8769984417b632d9925cf749744de801f3b8ebf1..97dd138dcee85805bfe23fbdeebe1122c73a4508 100644 (file)
@@ -10987,27 +10987,30 @@ Apologies for any names omitted.
        Portability: use explicitly unsigned operands when doing
        bit-wise shift operations on data larger than a character.
 
-20050709-14
-
-       Migration of data object sizes from int->ssize_t and
-       unsigned->size_t for better portability to LP64 and LLP64
-       systems.  Simply changing everything to size_t would be
-       dangerous. A lot of code was written assuming signed
-       arithmetic; for example, it recognizes negative lengths as
-       an indication of integer overflow.  Files: util/vbuf.[hc],
-       util/mymalloc.[hc], util/vstring.[hc], util/vstream.[hc],
-       util/timed_read.c, util/timed_write.c and functions that
-       override timed_read/write.c; in a later round updated pretty
-       much everything that contains a length of, or an offset
-       into, a buffer. This eliminates unnecessary conversions
-       back and forth between 32-bit and 64-bit integers.
-
-20050710-3
+20050709-15
+
+       Migration of data object sizes and offsets from int->ssize_t
+       and unsigned->size_t for better portability to LP64 and
+       LLP64 systems where *size_t is 64 bits wide.   This change
+       has no effect on 32-bit systems.
+
+       This change not only eliminated some obscure portability
+       bugs (see two paragraphs down), it also eliminated many
+       unnecessary conversions back and forth between 32-bit and
+       64-bit integers, because all relevant system library functions
+       take *size_t arguments or return *size_t results.
+
+       Simply changing every data object size or offset to size_t
+       (which is unsigned!) would be dangerous.  A lot of code was
+       written assuming signed arithmetic and rejects negative
+       lengths, which can happen as the result of integer overflow.
 
        Portability: on LP64 systems, integer expressions are int,
        but sizeof() and pointer difference expressions are larger.
-       Fixed a few discrepancies with functions that expect int:
-       util/clean_env.c, util/argv.c, util/attr_print*.c.
+       The above changes fixed a few discrepancies with function
+       calls where *size_t was passed while the old code expected
+       an int: clean_env() versus argv_addn(), and code that sent
+       binary blobs via the TLS session cache manager protocol.
 
 20050711
 
@@ -11020,6 +11023,11 @@ Apologies for any names omitted.
        that were incompatible with pre-DSN Postfix versions.  File:
        cleanup/cleanup_out_recipient.c.
 
+20050716
+
+       Bugfix: the smtpd_sasl_authenticated_header code did not
+       check if SASL was actually enabled. File: smtpd/smtpd.c.
+
 Open problems:
 
        Look for systems with XPG basename() declared in <libgen.h>,
index a12abd678eb4fb133b39d8e4de2aa595ca004309..f1ef928e0d5ecbef91ea723b42bfb68c435852f5 100644 (file)
@@ -17,6 +17,40 @@ Incompatibility with Postfix 2.1 and earlier
 If you upgrade from Postfix 2.1 or earlier, read RELEASE_NOTES-2.2
 before proceeding.
 
+Incompatibility with snapshot 20050715
+======================================
+
+Internal interfaces have changed; this may break third-party patches
+because the text of function argument and result type definitions
+has changed.  The type of buffer lengths and offsets were changed
+from "(unsigned) int" (32 bit on 32-bit and LP64 systems) to
+"(s)size_t" (64 bit on LP64 systems, 32 bit on 32-bit systems).
+
+Otherwise, this change makes no difference on 32-bit systems. On
+LP64 systems, however, software may mis-behave 1) when Postfix is
+linked with pre-compiled code that was compiled with old Postfix
+interface definitions and 2) when compiling Postfix source that was
+modified by a third-party patch: incorrect code may be generated
+when the patch passes the wrong integer argument type in contexts
+that disable automatic argument type conversions.  Examples of such
+contexts are formatting with printf-like arguments, and invoking
+functions that write Postfix request or reply attributes across
+inter-process communication channels.  Unfortunately, gcc does not
+report "(unsigned) int" versus "(s)size_t" format string argument
+mis-matches on 32-bit systems; they can be found only on 64-bit
+systems.
+
+Major changes with snapshot 20050715 
+====================================
+
+Improved portability to LP64 systems, by converting the type of
+buffer lengths and offsets from "(unsigned) int" to "(s)size_t".
+This change has zero effect on 32-bit systems. On LP64 platforms,
+however, this change not only eliminates some obscure portability
+bugs, it also eliminates unnecessary conversions between 32/64 bit
+integer types, because many system library routines take "(s)size_t"
+arguments or return "(s)size_t" values.
+
 Incompatibility with snapshot 20050707
 ======================================
 
index 5565f25d498f7edb15a419d27f70fb483be13465..a01cd78a2f85ad8dc732c2f04ba6ec8014ca09e5 100644 (file)
@@ -168,6 +168,7 @@ case "$SYSTEM.$RELEASE" in
                ?*) error "Don't set LD_LIBRARY_PATH";;
                esac
                case "${CC}" in
+               *" "*) ;;
                *ucb*) error "Don't use /usr/ucb/cc or ucblib";;
                  cc*) case `which ${CC}` in
                *ucb*) error "Don't use /usr/ucb/cc or ucblib";;
@@ -396,6 +397,9 @@ export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
 # Snapshot only.
 CCARGS="$CCARGS -DSNAPSHOT"
 
+# Non-production, i.e. needs thorough testing.
+#CCARGS="$CCARGS -DNONPROD"
+
 sed 's/  / /g' <<EOF
 SYSTYPE        = $SYSTYPE
 AR     = $AR
index 578cc851adf16ead71c2eebc8b55663100e3409f..ae42a3e1869a63c6389a40dbcb0d5fa222e11295 100644 (file)
@@ -535,11 +535,11 @@ int     bounce_boilerplate(VSTREAM *bounce, BOUNCE_INFO *bounce_info)
 
 /* bounce_print - line_wrap callback */
 
-static void bounce_print(const char *str, ssize_t len, ssize_t indent, char *context)
+static void bounce_print(const char *str, int len, int indent, char *context)
 {
     VSTREAM *bounce = (VSTREAM *) context;
 
-    post_mail_fprintf(bounce, "%*s%.*s", (int) indent, "", (int) len, str);
+    post_mail_fprintf(bounce, "%*s%.*s", indent, "", len, str);
 }
 
 /* bounce_print_wrap - print and wrap a line */
index 187da911edbfa3ee5c3e25e9a59389bf1ba31f42..98676b55accfbdd9fff20e85771036e501e6ccb6 100644 (file)
@@ -171,7 +171,7 @@ static int dns_query(const char *name, int type, int flags,
      * Initialize the reply buffer.
      */
     if (reply->buf == 0) {
-       reply->buf = mymalloc(DEF_DNS_REPLY_SIZE);
+       reply->buf = (unsigned char *) mymalloc(DEF_DNS_REPLY_SIZE);
        reply->buf_len = DEF_DNS_REPLY_SIZE;
     }
 
@@ -228,7 +228,8 @@ static int dns_query(const char *name, int type, int flags,
        reply_header = (HEADER *) reply->buf;
        if (reply_header->tc == 0 || reply->buf_len >= MAX_DNS_REPLY_SIZE)
            break;
-       reply->buf = myrealloc(reply->buf, 2 * reply->buf_len);
+       reply->buf = (unsigned char *)
+           myrealloc((char *) reply->buf, 2 * reply->buf_len);
        reply->buf_len *= 2;
     }
 
index fba46100cdbd2ba3629cc33644c4bf3a48bd353c..0fd214c7287e85197e3d225f45dedb7d46daee70 100644 (file)
   * Patches change both the patchlevel and the release date. Snapshots have no
   * patchlevel; they change the release date only.
   */
-#define MAIL_RELEASE_DATE      "20050714"
+#define MAIL_RELEASE_DATE      "20050716"
 #define MAIL_VERSION_NUMBER    "2.3"
 
-#define VAR_MAIL_VERSION       "mail_version"
 #ifdef SNAPSHOT
-#define DEF_MAIL_VERSION       MAIL_VERSION_NUMBER "-" MAIL_RELEASE_DATE
+# define MAIL_VERSION_DATE     "-" MAIL_RELEASE_DATE
+#else
+# define MAIL_VERSION_DATE
+#endif
+
+#ifdef NONPROD
+# define MAIL_VERSION_PROD     "-nonprod"
 #else
-#define DEF_MAIL_VERSION       MAIL_VERSION_NUMBER
+# define MAIL_VERSION_PROD
 #endif
+
+#define VAR_MAIL_VERSION       "mail_version"
+#define DEF_MAIL_VERSION       MAIL_VERSION_NUMBER MAIL_VERSION_DATE MAIL_VERSION_PROD
+
 extern char *var_mail_version;
 
  /*
index d3319ec306eb909ca1ec9bcc6f38d0007fe5536e..245e492dcd38153e2c8aa2ddc8f234adebc50773 100644 (file)
@@ -268,7 +268,9 @@ static void get_pipe_args(struct pipe_args * args, va_list ap)
 
 /* pipe_command_write - write to command with time limit */
 
-static ssize_t pipe_command_write(int fd, void *buf, ssize_t len)
+static ssize_t pipe_command_write(int fd, void *buf, size_t len,
+                                         int unused_timeout,
+                                         void *unused_context)
 {
     int     maxtime = (pipe_command_timeout == 0) ? pipe_command_maxtime : 0;
     char   *myname = "pipe_command_write";
@@ -289,7 +291,9 @@ static ssize_t pipe_command_write(int fd, void *buf, ssize_t len)
 
 /* pipe_command_read - read from command with time limit */
 
-static ssize_t pipe_command_read(int fd, void *buf, ssize_t len)
+static ssize_t pipe_command_read(int fd, void *buf, ssize_t len,
+                                        int unused_timeout,
+                                        void *unused_context)
 {
     int     maxtime = (pipe_command_timeout == 0) ? pipe_command_maxtime : 0;
     char   *myname = "pipe_command_read";
index 2e63278efc11c891d114eeed5aef28038a9f4d0e..15cc1bd600b1a8e2e6fca8a16d5a025f34394695 100644 (file)
@@ -132,7 +132,7 @@ int     rec_put_type(VSTREAM *stream, int type, long offset)
 int     rec_put(VSTREAM *stream, int type, const char *data, ssize_t len)
 {
     ssize_t len_rest;
-    ssize_t len_byte;
+    int     len_byte;
 
     if (type < 0 || type > 255)
        msg_panic("rec_put: bad record type %d", type);
@@ -234,7 +234,7 @@ int     rec_get(VSTREAM *stream, VSTRING *buf, ssize_t maxsize)
     VSTRING_TERMINATE(buf);
     if (msg_verbose > 2)
        msg_info("%s: type %c len %ld data %.10s", myname,
-                type, (unsigned long) len, vstring_str(buf));
+                type, (long) len, vstring_str(buf));
     return (type);
 }
 
index dbaf48c6c9700e4792fee2051867419c1a034487..d836e67361ca0858aee8ca2965ecdabeb3f42f1f 100644 (file)
@@ -319,7 +319,7 @@ int     smtp_get(VSTRING *vp, VSTREAM *stream, ssize_t bound)
 
 void    smtp_fputs(const char *cp, ssize_t todo, VSTREAM *stream)
 {
-    size_t  err;
+    ssize_t  err;
 
     if (todo < 0)
        msg_panic("smtp_fputs: negative todo %ld", (long) todo);
@@ -346,7 +346,7 @@ void    smtp_fputs(const char *cp, ssize_t todo, VSTREAM *stream)
 
 void    smtp_fwrite(const char *cp, ssize_t todo, VSTREAM *stream)
 {
-    size_t  err;
+    ssize_t  err;
 
     if (todo < 0)
        msg_panic("smtp_fwrite: negative todo %ld", (long) todo);
index e99107c2a8114005a8f5c8df14687495d85c1b5a..608b8a8f3ebc24cac062acd6d3c83c92ccd2e93d 100644 (file)
@@ -286,11 +286,11 @@ LMTP_RESP *lmtp_chat_resp(LMTP_STATE *state)
 
 /* print_line - line_wrap callback */
 
-static void print_line(const char *str, ssize_t len, ssize_t indent, char *context)
+static void print_line(const char *str, int len, int indent, char *context)
 {
     VSTREAM *notice = (VSTREAM *) context;
 
-    post_mail_fprintf(notice, " %*s%.*s", (int) indent, "", (int) len, str);
+    post_mail_fprintf(notice, " %*s%.*s", indent, "", len, str);
 }
 
 /* lmtp_chat_notify - notify postmaster */
index 0ca789a27842808d524b0b9eeeafb7e659b82c15..371bfc6fe935d4a04f6eb280a1d2db6832ffc609 100644 (file)
@@ -124,11 +124,6 @@ static NAME_MASK lmtp_sasl_sec_mask[] = {
     0,
 };
 
- /*
-  * Silly little macros.
-  */
-#define STR(x) vstring_str(x)
-
  /*
   * Macros to handle API differences between SASLv1 and SASLv2. Specifics:
   * 
index 2d3f4f617ef04b1d61474ee8911397712d2cb7ce..d924ce3434d7810e39b721ece1e188c8213edc56 100644 (file)
@@ -51,7 +51,7 @@ typedef struct SMTP_STATE {
     DELIVER_REQUEST *request;          /* envelope info, offsets */
     struct SMTP_SESSION *session;      /* network connection */
     int     status;                    /* delivery status */
-    int     space_left;                        /* output length control */
+    ssize_t space_left;                        /* output length control */
 
     /*
      * Connection cache support. The (nexthop_lookup_mx, nexthop_domain,
index 4e9b6f3eb384c891b97830428a213467206e6ec3..7f27fc20f60251bedc25db5312f4d3b46c4a6f98 100644 (file)
@@ -306,11 +306,11 @@ SMTP_RESP *smtp_chat_resp(SMTP_SESSION *session)
 
 /* print_line - line_wrap callback */
 
-static void print_line(const char *str, ssize_t len, ssize_t indent, char *context)
+static void print_line(const char *str, int len, int indent, char *context)
 {
     VSTREAM *notice = (VSTREAM *) context;
 
-    post_mail_fprintf(notice, " %*s%.*s", (int) indent, "", (int) len, str);
+    post_mail_fprintf(notice, " %*s%.*s", indent, "", len, str);
 }
 
 /* smtp_chat_notify - notify postmaster */
index fe437fb0e7fd94d364fcf443bae91f7426de4476..ef6c4cb6eba2b0579ae44a7570bd6884b44d316f 100644 (file)
@@ -139,11 +139,6 @@ static NAME_MASK smtp_sasl_sec_mask[] = {
     0,
 };
 
- /*
-  * Silly little macros.
-  */
-#define STR(x) vstring_str(x)
-
  /*
   * Macros to handle API differences between SASLv1 and SASLv2. Specifics:
   * 
index 7be9340df01c50e8d54abcabbc46b7e23abc93ad..62636081b6ad5d389a2a37db28c0b79ec92fe905 100644 (file)
@@ -2167,7 +2167,7 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
        }
 #endif
 #ifdef USE_SASL_AUTH
-       if (var_smtpd_sasl_auth_hdr && state->sasl_username) {
+       if (var_smtpd_sasl_enable && var_smtpd_sasl_auth_hdr && state->sasl_username) {
            username = VSTRING_STRDUP(state->sasl_username);
            comment_sanitize(username);
            out_fprintf(out_stream, REC_TYPE_NORM,
index 394e52b16d6c3f4ecce363eb119295bcc298090e..2962b1efbe43f07de9966596faa6d4510c7f4386 100644 (file)
@@ -183,11 +183,11 @@ void    smtpd_chat_reply(SMTPD_STATE *state, char *format,...)
 
 /* print_line - line_wrap callback */
 
-static void print_line(const char *str, ssize_t len, ssize_t indent, char *context)
+static void print_line(const char *str, int len, int indent, char *context)
 {
     VSTREAM *notice = (VSTREAM *) context;
 
-    post_mail_fprintf(notice, " %*s%.*s", (int) indent, "", (int) len, str);
+    post_mail_fprintf(notice, " %*s%.*s", indent, "", len, str);
 }
 
 /* smtpd_chat_notify - notify postmaster */
index a56c4cb76d00c3c0e0761cf83ca2d6fe33112f20..b2b2065edd9b1cd2310b61fa8e9a8da35ca09a4c 100644 (file)
@@ -1119,12 +1119,12 @@ static int reject_unknown_hostname(SMTPD_STATE *state, char *name,
                              RR_ADDR_TYPES, T_MX, 0);
     if (dns_status == DNS_NOTFOUND)
        return (smtpd_check_reject(state, MAIL_ERROR_POLICY,
-                                  var_unk_name_code, "4.1.0",
+                                  var_unk_name_code, "4.7.1",
                                   "<%s>: %s rejected: Host not found",
                                   reply_name, reply_class));
     else if (dns_status != DNS_OK)
        DEFER_IF_PERMIT2(state, MAIL_ERROR_POLICY,
-                        450, "4.1.0",
+                        450, "4.7.1",
                         "<%s>: %s rejected: Host not found",
                         reply_name, reply_class);
     return (SMTPD_CHECK_DUNNO);
index ec0c457d6074297ef06e5119c9d670276a5d3c7a..628ebd2a70c51a42595857f29610cd1a2013a09e 100644 (file)
@@ -372,7 +372,7 @@ static void send_data(SESSION *session)
                        STR(message_buffer), LEN(message_buffer),
                        STR(sender_buffer), LEN(sender_buffer),
                        STR(recipient_buffer), LEN(recipient_buffer),
-                       (ssize_t) 0);
+                       (char *) 0);
     netstring_fflush(session->stream);
 
     /*
index d141967ee6446dc1534cd246972c2c16ce5ced5e..bcd2cc03f252decd9492a4d93ce903ac5a86f875 100644 (file)
@@ -24,7 +24,7 @@
 /*     TLS_SCACHE *cache;
 /*     const char *cache_id;
 /*     const char *session;
-/*     int     session_len;
+/*     ssize_t session_len;
 /*
 /*     int     tls_scache_sequence(cache, first_next, out_cache_id,
 /*                             VSTRING *out_session)
index f125838848e4855f6ac2c525a6f7084418ba3402..3d6cd7627324147e9fc93d25e2083cf96e1bb91d 100644 (file)
@@ -147,8 +147,8 @@ static void resolve_addr(RES_CONTEXT *rp, char *addr,
     const char *blame = 0;
     const char *rcpt_domain;
     ssize_t addr_len;
-    int     loop_count;
-    int     loop_max;
+    ssize_t loop_count;
+    ssize_t loop_max;
     char   *local;
     char   *oper;
     char   *junk;
@@ -233,8 +233,8 @@ static void resolve_addr(RES_CONTEXT *rp, char *addr,
         * disrupt the operation of an MTA.
         */
        if (loop_count > loop_max) {
-           msg_warn("resolve_addr: <%s>: giving up after %d iterations",
-                    addr, loop_count);
+           msg_warn("resolve_addr: <%s>: giving up after %ld iterations",
+                    addr, (long) loop_count);
            break;
        }
 
index 294ca199bd8178aab4306f58302dd2302123a049..4b6c59e30881082315c797823685f3e6b44014b0 100644 (file)
@@ -34,7 +34,7 @@ static ssize_t namelength(const char *name)
 
 /* findenv - given name, locate name=value */
 
-static char **findenv(const char *name, int len)
+static char **findenv(const char *name, ssize_t len)
 {
     char  **envp;
 
@@ -50,7 +50,7 @@ static char **findenv(const char *name, int len)
 
 char   *getenv(const char *name)
 {
-    int     len = namelength(name);
+    ssize_t len = namelength(name);
     char  **envp = findenv(name, len);
 
     return (envp ? *envp + len + 1 : 0);
@@ -85,7 +85,7 @@ int     setenv(const char *name, const char *value, int clobber)
 {
     char   *destination;
     char  **envp;
-    int     l_name;                    /* length of name part */
+    ssize_t l_name;                    /* length of name part */
     unsigned int l_nameval;            /* length of name=value */
 
     /* Permit name= and =value. */
index f330e5b5a3f46927158fca7fedcb4f9d8191b7c1..aab2e97a7695509428207971910174162943e03e 100644 (file)
@@ -149,20 +149,19 @@ int     main(int argc, char **argv)
     proto_info = inet_proto_init(argv[0], argv[1]);
     argv += 1;
 
-    inet_addr_list_init(&list);
-
     while (--argc && *++argv) {
+       inet_addr_list_init(&list);
        if (inet_addr_host(&list, *argv) == 0)
            msg_fatal("not found: %s", *argv);
 
        for (sa = list.addrs; sa < list.addrs + list.used; sa++) {
            SOCKADDR_TO_HOSTADDR(SOCK_ADDR_PTR(sa), SOCK_ADDR_LEN(sa),
                                 &hostaddr, (MAI_SERVPORT_STR *) 0, 0);
-           vstream_printf("%s\n", hostaddr.buf);
+           vstream_printf("%s\t%s\n", *argv, hostaddr.buf);
        }
        vstream_fflush(VSTREAM_OUT);
+       inet_addr_list_free(&list);
     }
-    inet_addr_list_free(&list);
     return (0);
 }
 
index 38c5558cfc838412ad078253ad26beabfd26afc2..50d172cabb813327b371293c837a920de0993b8d 100644 (file)
@@ -73,16 +73,16 @@ void print(const char *str, int len, int indent, char *context)
 
 /* line_wrap - wrap long lines upon output */
 
-void    line_wrap(const char *str, ssize_t len, ssize_t indent, LINE_WRAP_FN output_fn,
+void    line_wrap(const char *str, int len, int indent, LINE_WRAP_FN output_fn,
                          char *context)
 {
     const char *start_line;
     const char *word;
     const char *next_word;
     const char *next_space;
-    ssize_t line_len;
-    ssize_t curr_len;
-    ssize_t curr_indent;
+    int     line_len;
+    int     curr_len;
+    int     curr_indent;
 
     if (indent < 0) {
        curr_indent = -indent;
index d1b0c18ea8aa77a57db9c50955d093a0604146b1..b901c1f3dec827b98a0fa3f6bf88dd37e1f24195 100644 (file)
@@ -14,8 +14,8 @@
  /*
   * External interface.
   */
-typedef void (*LINE_WRAP_FN) (const char *, ssize_t, ssize_t, char *);
-extern void line_wrap(const char *, ssize_t, ssize_t, LINE_WRAP_FN, char *);
+typedef void (*LINE_WRAP_FN) (const char *, int, int, char *);
+extern void line_wrap(const char *, int, int, LINE_WRAP_FN, char *);
 
 /* LICENSE
 /* .ad
index 82b54941c358df35e89c5f1f99ec21ee6cf5e622..7dfee0a34ce6d35a7e436f4dea6ea11641afdfbb 100644 (file)
@@ -22,7 +22,7 @@
 /*     void    netstring_put(stream, data, len)
 /*     VSTREAM *stream;
 /*     const char *data;
-/*     int     ssize_t;
+/*     ssize_t len;
 /*
 /*     void    netstring_put_multi(stream, data, len, data, len, ..., 0)
 /*     VSTREAM *stream;
@@ -39,7 +39,7 @@
 /*     VSTRING *netstring_memcpy(buf, data, len)
 /*     VSTRING *buf;
 /*     const char *data;
-/*     int     ssize_t;
+/*     ssize_t len;
 /*
 /*     VSTRING *netstring_memcat(buf, data, len)
 /*     VSTRING *buf;
index 3c792005ecdfc956ba81632ced933e695d5eef99..e031bbcf856488f12d4c92335f835ce82c9c0eac 100644 (file)
@@ -58,24 +58,30 @@ extern VSTRING *vstring_import(char *);
 #define vstring_str(vp)                ((char *) (vp)->vbuf.data)
 #define VSTRING_LEN(vp)                ((ssize_t) ((vp)->vbuf.ptr - (vp)->vbuf.data))
 #define vstring_end(vp)                ((char *) (vp)->vbuf.ptr)
-#define VSTRING_TERMINATE(vp)  { if ((vp)->vbuf.cnt <= 0) \
+#define VSTRING_TERMINATE(vp)  do { \
+                                   if ((vp)->vbuf.cnt <= 0) \
                                        VSTRING_SPACE((vp),1); \
-                                 *(vp)->vbuf.ptr = 0; }
-#define VSTRING_RESET(vp)      { (vp)->vbuf.ptr = (vp)->vbuf.data; \
-                                 (vp)->vbuf.cnt = (vp)->vbuf.len; }
+                                   *(vp)->vbuf.ptr = 0; \
+                               } while (0)
+#define VSTRING_RESET(vp)      do { \
+                                   (vp)->vbuf.ptr = (vp)->vbuf.data; \
+                                   (vp)->vbuf.cnt = (vp)->vbuf.len; \
+                               } while (0)
 #define        VSTRING_ADDCH(vp, ch)   VBUF_PUT(&(vp)->vbuf, ch)
-#define VSTRING_SKIP(vp)       { while ((vp)->vbuf.cnt > 0 && *(vp)->vbuf.ptr) \
-                                 (vp)->vbuf.ptr++, (vp)->vbuf.cnt--; }
+#define VSTRING_SKIP(vp)       do { \
+                                   while ((vp)->vbuf.cnt > 0 && *(vp)->vbuf.ptr) \
+                                       (vp)->vbuf.ptr++, (vp)->vbuf.cnt--; \
+                               } while (0)
 #define vstring_avail(vp)      ((vp)->vbuf.cnt)
 
  /*
   * The following macro is not part of the public interface, because it can
   * really screw up a buffer by positioning past allocated memory.
   */
-#define VSTRING_AT_OFFSET(vp, offset) { \
+#define VSTRING_AT_OFFSET(vp, offset) do { \
        (vp)->vbuf.ptr = (vp)->vbuf.data + (offset); \
        (vp)->vbuf.cnt = (vp)->vbuf.len - (offset); \
-    }
+    } while (0)
 
 extern VSTRING *vstring_vsprintf(VSTRING *, const char *, va_list);
 extern VSTRING *vstring_vsprintf_append(VSTRING *, const char *, va_list);
index 7c78427330f84307fa3bc76439222e9654013412..36c9134725b247d7bc3f50c1dd52416685fad578 100644 (file)
 /*     int     vstring_get_bound(vp, fp, bound)
 /*     VSTRING *vp;
 /*     VSTREAM *fp;
-/*     int     bound;
+/*     ssize_t bound;
 /*
 /*     int     vstring_get_nonl_bound(vp, fp, bound)
 /*     VSTRING *vp;
 /*     VSTREAM *fp;
-/*     int     bound;
+/*     ssize_t bound;
 /*
 /*     int     vstring_get_null_bound(vp, fp, bound)
 /*     VSTRING *vp;
 /*     VSTREAM *fp;
-/*     int     bound;
+/*     ssize_t bound;
 /* DESCRIPTION
 /*     The routines in this module each read one newline or null-terminated
 /*     string from an input stream. In all cases the result is either the
@@ -126,12 +126,12 @@ int     vstring_get_null(VSTRING *vp, VSTREAM *fp)
 
 /* vstring_get_bound - read line from file, keep newline, up to bound */
 
-int     vstring_get_bound(VSTRING *vp, VSTREAM *fp, int bound)
+int     vstring_get_bound(VSTRING *vp, VSTREAM *fp, ssize_t bound)
 {
     int     c;
 
     if (bound <= 0)
-       msg_panic("vstring_get_bound: invalid bound %d", bound);
+       msg_panic("vstring_get_bound: invalid bound %ld", (long) bound);
 
     VSTRING_RESET(vp);
     while (bound-- > 0 && (c = VSTREAM_GETC(fp)) != VSTREAM_EOF) {
@@ -145,12 +145,12 @@ int     vstring_get_bound(VSTRING *vp, VSTREAM *fp, int bound)
 
 /* vstring_get_nonl_bound - read line from file, strip newline, up to bound */
 
-int     vstring_get_nonl_bound(VSTRING *vp, VSTREAM *fp, int bound)
+int     vstring_get_nonl_bound(VSTRING *vp, VSTREAM *fp, ssize_t bound)
 {
     int     c;
 
     if (bound <= 0)
-       msg_panic("vstring_get_nonl_bound: invalid bound %d", bound);
+       msg_panic("vstring_get_nonl_bound: invalid bound %ld", (long) bound);
 
     VSTRING_RESET(vp);
     while (bound-- > 0 && (c = VSTREAM_GETC(fp)) != VSTREAM_EOF && c != '\n')
@@ -161,12 +161,12 @@ int     vstring_get_nonl_bound(VSTRING *vp, VSTREAM *fp, int bound)
 
 /* vstring_get_null_bound - read null-terminated string from file */
 
-int     vstring_get_null_bound(VSTRING *vp, VSTREAM *fp, int bound)
+int     vstring_get_null_bound(VSTRING *vp, VSTREAM *fp, ssize_t bound)
 {
     int     c;
 
     if (bound <= 0)
-       msg_panic("vstring_get_nonl_bound: invalid bound %d", bound);
+       msg_panic("vstring_get_nonl_bound: invalid bound %ld", (long) bound);
 
     VSTRING_RESET(vp);
     while (bound-- > 0 && (c = VSTREAM_GETC(fp)) != VSTREAM_EOF && c != 0)
index 68bd8106db0c57e913cc963b0f4c83ccebb8369d..9bd9d7127cfc9c37dcbb415e4e940fa8abcc3290 100644 (file)
@@ -22,9 +22,9 @@
 extern int vstring_get(VSTRING *, VSTREAM *);
 extern int vstring_get_nonl(VSTRING *, VSTREAM *);
 extern int vstring_get_null(VSTRING *, VSTREAM *);
-extern int vstring_get_bound(VSTRING *, VSTREAM *, int);
-extern int vstring_get_nonl_bound(VSTRING *, VSTREAM *, int);
-extern int vstring_get_null_bound(VSTRING *, VSTREAM *, int);
+extern int vstring_get_bound(VSTRING *, VSTREAM *, ssize_t);
+extern int vstring_get_nonl_bound(VSTRING *, VSTREAM *, ssize_t);
+extern int vstring_get_null_bound(VSTRING *, VSTREAM *, ssize_t);
 
  /*
   * Backwards compatibility for code that still uses the vstring_fgets()
index 2bce6c972716e69ef8fff1d1b5df40512e43318d..9544365642b6ec76020cc1084959e328a7232589 100644 (file)
@@ -56,6 +56,7 @@
 
 ssize_t write_buf(int fd, const char *buf, ssize_t len, int timeout)
 {
+    const char *start = buf;
     ssize_t count;
 
     while (len > 0) {
@@ -71,5 +72,5 @@ ssize_t write_buf(int fd, const char *buf, ssize_t len, int timeout)
        buf += count;
        len -= count;
     }
-    return (len);
+    return (buf - start);
 }