From: Wietse Venema Date: Thu, 14 Jul 2005 05:00:00 +0000 (-0500) Subject: postfix-2.3-20050714 X-Git-Tag: v2.3-RC1~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=948637192636b7fc2d91b06af7252c87bb490d42;p=thirdparty%2Fpostfix.git postfix-2.3-20050714 --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 3f7eb9851..876998441 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -10980,8 +10980,45 @@ Apologies for any names omitted. 20050708 - Bugfix: missing returns in 20050706 caching disabling code. - File: global/scache_clnt.c. + Bugfix: missing returns in 20050706 caching disabling code + (in error handling code that never executes). File: + global/scache_clnt.c. + + 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 + + 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. + +20050711 + + Bugfix: don't include <> when auto-generating an ORCPT + address from a client RCPT TO command. File: smtpd.c. + +20050712 + + Cleanup: cleanup_out_recipient() still generated DSN records + that were incompatible with pre-DSN Postfix versions. File: + cleanup/cleanup_out_recipient.c. Open problems: diff --git a/postfix/html/trivial-rewrite.8.html b/postfix/html/trivial-rewrite.8.html index 1ba4a47de..604ab1581 100644 --- a/postfix/html/trivial-rewrite.8.html +++ b/postfix/html/trivial-rewrite.8.html @@ -135,8 +135,8 @@ TRIVIAL-REWRITE(8) TRIVIAL-REWRITE(8) remote_header_rewrite_domain (empty) Don't rewrite message headers from remote clients at all when this parameter is empty; otherwise, re- - write remote message headers and append the speci- - fied domain name to incomplete addresses. + write message headers and append the specified + domain name to incomplete addresses. ROUTING CONTROLS The following is applicable to Postfix version 2.0 and diff --git a/postfix/man/man8/trivial-rewrite.8 b/postfix/man/man8/trivial-rewrite.8 index 97522bca6..40fcfd671 100644 --- a/postfix/man/man8/trivial-rewrite.8 +++ b/postfix/man/man8/trivial-rewrite.8 @@ -129,8 +129,8 @@ Enable the rewriting of "site!user" into "user@site". Available in Postfix 2.2 and later: .IP "\fBremote_header_rewrite_domain (empty)\fR" Don't rewrite message headers from remote clients at all when -this parameter is empty; otherwise, rewrite remote message headers -and append the specified domain name to incomplete addresses. +this parameter is empty; otherwise, rewrite message headers and +append the specified domain name to incomplete addresses. .SH "ROUTING CONTROLS" .na .nf diff --git a/postfix/src/bounce/bounce_notify_util.c b/postfix/src/bounce/bounce_notify_util.c index ae42a3e18..578cc851a 100644 --- a/postfix/src/bounce/bounce_notify_util.c +++ b/postfix/src/bounce/bounce_notify_util.c @@ -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, int len, int indent, char *context) +static void bounce_print(const char *str, ssize_t len, ssize_t indent, char *context) { VSTREAM *bounce = (VSTREAM *) context; - post_mail_fprintf(bounce, "%*s%.*s", indent, "", len, str); + post_mail_fprintf(bounce, "%*s%.*s", (int) indent, "", (int) len, str); } /* bounce_print_wrap - print and wrap a line */ diff --git a/postfix/src/cleanup/Makefile.in b/postfix/src/cleanup/Makefile.in index 51f667270..9e7b1923f 100644 --- a/postfix/src/cleanup/Makefile.in +++ b/postfix/src/cleanup/Makefile.in @@ -474,6 +474,7 @@ cleanup_out.o: ../../include/vstring.h cleanup_out.o: cleanup.h cleanup_out.o: cleanup_out.c cleanup_out_recipient.o: ../../include/argv.h +cleanup_out_recipient.o: ../../include/attr.h cleanup_out_recipient.o: ../../include/been_here.h cleanup_out_recipient.o: ../../include/bounce.h cleanup_out_recipient.o: ../../include/cleanup_user.h @@ -485,8 +486,10 @@ cleanup_out_recipient.o: ../../include/dsn_mask.h cleanup_out_recipient.o: ../../include/ext_prop.h cleanup_out_recipient.o: ../../include/header_opts.h cleanup_out_recipient.o: ../../include/htable.h +cleanup_out_recipient.o: ../../include/iostuff.h cleanup_out_recipient.o: ../../include/mail_conf.h cleanup_out_recipient.o: ../../include/mail_params.h +cleanup_out_recipient.o: ../../include/mail_proto.h cleanup_out_recipient.o: ../../include/mail_queue.h cleanup_out_recipient.o: ../../include/mail_stream.h cleanup_out_recipient.o: ../../include/maps.h diff --git a/postfix/src/cleanup/cleanup.h b/postfix/src/cleanup/cleanup.h index 1d9524848..dbd2110a6 100644 --- a/postfix/src/cleanup/cleanup.h +++ b/postfix/src/cleanup/cleanup.h @@ -54,10 +54,10 @@ typedef struct CLEANUP_STATE { int hop_count; /* count of received: headers */ char *resent; /* any resent- header seen */ BH_TABLE *dups; /* recipient dup filter */ - void (*action) (struct CLEANUP_STATE *, int, const char *, int); + void (*action) (struct CLEANUP_STATE *, int, const char *, ssize_t); off_t data_offset; /* start of message content */ off_t xtra_offset; /* start of extra segment */ - int rcpt_count; /* recipient count */ + ssize_t rcpt_count; /* recipient count */ char *reason; /* failure reason */ NVTABLE *attr; /* queue file attribute list */ MIME_STATE *mime_state; /* MIME state engine */ @@ -154,7 +154,7 @@ extern CONFIG_TIME_TABLE cleanup_time_table[]; /* * cleanup_out.c */ -extern void cleanup_out(CLEANUP_STATE *, int, const char *, int); +extern void cleanup_out(CLEANUP_STATE *, int, const char *, ssize_t); extern void cleanup_out_string(CLEANUP_STATE *, int, const char *); extern void PRINTFLIKE(3, 4) cleanup_out_format(CLEANUP_STATE *, int, const char *,...); @@ -167,17 +167,17 @@ extern void PRINTFLIKE(3, 4) cleanup_out_format(CLEANUP_STATE *, int, const char /* * cleanup_envelope.c */ -extern void cleanup_envelope(CLEANUP_STATE *, int, const char *, int); +extern void cleanup_envelope(CLEANUP_STATE *, int, const char *, ssize_t); /* * cleanup_message.c */ -extern void cleanup_message(CLEANUP_STATE *, int, const char *, int); +extern void cleanup_message(CLEANUP_STATE *, int, const char *, ssize_t); /* * cleanup_extracted.c */ -extern void cleanup_extracted(CLEANUP_STATE *, int, const char *, int); +extern void cleanup_extracted(CLEANUP_STATE *, int, const char *, ssize_t); /* * cleanup_rewrite.c diff --git a/postfix/src/cleanup/cleanup_envelope.c b/postfix/src/cleanup/cleanup_envelope.c index a30383061..e2d999705 100644 --- a/postfix/src/cleanup/cleanup_envelope.c +++ b/postfix/src/cleanup/cleanup_envelope.c @@ -10,7 +10,7 @@ /* CLEANUP_STATE *state; /* int type; /* const char *buf; -/* int len; +/* ssize_t len; /* DESCRIPTION /* This module processes envelope records and writes the result /* to the queue file. It validates the message structure, rewrites @@ -77,12 +77,12 @@ #define STR vstring_str #define STREQ(x,y) (strcmp((x), (y)) == 0) -static void cleanup_envelope_process(CLEANUP_STATE *, int, const char *, int); +static void cleanup_envelope_process(CLEANUP_STATE *, int, const char *, ssize_t); /* cleanup_envelope - initialize message envelope */ void cleanup_envelope(CLEANUP_STATE *state, int type, - const char *str, int len) + const char *str, ssize_t len) { /* @@ -107,7 +107,7 @@ void cleanup_envelope(CLEANUP_STATE *state, int type, /* cleanup_envelope_process - process one envelope record */ static void cleanup_envelope_process(CLEANUP_STATE *state, int type, - const char *buf, int len) + const char *buf, ssize_t len) { char *attr_name; char *attr_value; @@ -118,7 +118,7 @@ static void cleanup_envelope_process(CLEANUP_STATE *state, int type, const char *mapped_buf = buf; if (msg_verbose) - msg_info("initial envelope %c %.*s", type, len, buf); + msg_info("initial envelope %c %.*s", type, (int) len, buf); if (type == REC_TYPE_FLGS) { /* Not part of queue file format. */ diff --git a/postfix/src/cleanup/cleanup_extracted.c b/postfix/src/cleanup/cleanup_extracted.c index 7d28d168b..1e2f43b06 100644 --- a/postfix/src/cleanup/cleanup_extracted.c +++ b/postfix/src/cleanup/cleanup_extracted.c @@ -10,7 +10,7 @@ /* CLEANUP_STATE *state; /* int type; /* const char *buf; -/* int len; +/* ssize_t len; /* DESCRIPTION /* This module processes message records with information extracted /* from message content, or with recipients that are stored after the @@ -72,13 +72,13 @@ #define STR(x) vstring_str(x) -static void cleanup_extracted_process(CLEANUP_STATE *, int, const char *, int); +static void cleanup_extracted_process(CLEANUP_STATE *, int, const char *, ssize_t); static void cleanup_extracted_finish(CLEANUP_STATE *); /* cleanup_extracted - initialize extracted segment */ void cleanup_extracted(CLEANUP_STATE *state, int type, - const char *buf, int len) + const char *buf, ssize_t len) { /* @@ -96,7 +96,7 @@ void cleanup_extracted(CLEANUP_STATE *state, int type, /* cleanup_extracted_process - process one extracted envelope record */ void cleanup_extracted_process(CLEANUP_STATE *state, int type, - const char *buf, int len) + const char *buf, ssize_t len) { const char *encoding; const char generated_by_cleanup[] = { @@ -109,7 +109,7 @@ void cleanup_extracted_process(CLEANUP_STATE *state, int type, int junk; if (msg_verbose) - msg_info("extracted envelope %c %.*s", type, len, buf); + msg_info("extracted envelope %c %.*s", type, (int) len, buf); if (strchr(REC_TYPE_EXTRACT, type) == 0) { msg_warn("%s: message rejected: " diff --git a/postfix/src/cleanup/cleanup_masquerade.c b/postfix/src/cleanup/cleanup_masquerade.c index f54fb7e5a..0a4fededb 100644 --- a/postfix/src/cleanup/cleanup_masquerade.c +++ b/postfix/src/cleanup/cleanup_masquerade.c @@ -81,10 +81,10 @@ int cleanup_masquerade_external(VSTRING *addr, ARGV *masq_domains) { char *domain; - int domain_len; + ssize_t domain_len; char **masqp; char *masq; - int masq_len; + ssize_t masq_len; char *parent; int truncate; int did_rewrite = 0; diff --git a/postfix/src/cleanup/cleanup_message.c b/postfix/src/cleanup/cleanup_message.c index 127870f0f..81ab2e145 100644 --- a/postfix/src/cleanup/cleanup_message.c +++ b/postfix/src/cleanup/cleanup_message.c @@ -10,7 +10,7 @@ /* CLEANUP_STATE *state; /* int type; /* const char *buf; -/* int len; +/* ssize_t len; /* DESCRIPTION /* This module processes message content records and copies the /* result to the queue file. It validates the input, rewrites @@ -663,7 +663,7 @@ static void cleanup_header_done_callback(void *context) /* cleanup_body_callback - output one body record */ static void cleanup_body_callback(void *context, int type, - const char *buf, int len, + const char *buf, ssize_t len, off_t offset) { CLEANUP_STATE *state = (CLEANUP_STATE *) context; @@ -699,7 +699,7 @@ static void cleanup_body_callback(void *context, int type, /* cleanup_message_headerbody - process message content, header and body */ static void cleanup_message_headerbody(CLEANUP_STATE *state, int type, - const char *buf, int len) + const char *buf, ssize_t len) { char *myname = "cleanup_message_headerbody"; MIME_STATE_DETAIL *detail; @@ -763,7 +763,7 @@ static void cleanup_mime_error_callback(void *context, int err_code, /* cleanup_message - initialize message content segment */ -void cleanup_message(CLEANUP_STATE *state, int type, const char *buf, int len) +void cleanup_message(CLEANUP_STATE *state, int type, const char *buf, ssize_t len) { char *myname = "cleanup_message"; int mime_options; diff --git a/postfix/src/cleanup/cleanup_out.c b/postfix/src/cleanup/cleanup_out.c index 959038386..f72d94129 100644 --- a/postfix/src/cleanup/cleanup_out.c +++ b/postfix/src/cleanup/cleanup_out.c @@ -13,7 +13,7 @@ /* CLEANUP_STATE *state; /* int type; /* const char *data; -/* int len; +/* ssize_t len; /* /* void cleanup_out_string(state, type, str) /* CLEANUP_STATE *state; @@ -85,7 +85,7 @@ /* cleanup_out - output one single record */ -void cleanup_out(CLEANUP_STATE *state, int type, const char *string, int len) +void cleanup_out(CLEANUP_STATE *state, int type, const char *string, ssize_t len) { int err = 0; diff --git a/postfix/src/cleanup/cleanup_out_recipient.c b/postfix/src/cleanup/cleanup_out_recipient.c index 4bdadc3dc..ad3d04b61 100644 --- a/postfix/src/cleanup/cleanup_out_recipient.c +++ b/postfix/src/cleanup/cleanup_out_recipient.c @@ -81,6 +81,7 @@ #include #include #include /* cleanup_trace_path */ +#include /* Application-specific. */ @@ -134,10 +135,11 @@ void cleanup_out_recipient(CLEANUP_STATE *state, if (been_here(state->dups, "%s\n%d\n%s\n%s", dsn_orcpt, dsn_notify, orcpt, recip) == 0) { if (dsn_notify) - cleanup_out_format(state, REC_TYPE_DSN_NOTIFY, "%d", - dsn_notify); + cleanup_out_format(state, REC_TYPE_ATTR, "%s=%d", + MAIL_ATTR_DSN_NOTIFY, dsn_notify); if (*dsn_orcpt) - cleanup_out_string(state, REC_TYPE_DSN_ORCPT, dsn_orcpt); + cleanup_out_format(state, REC_TYPE_ATTR, "%s=%s", + MAIL_ATTR_DSN_ORCPT, dsn_orcpt); cleanup_out_string(state, REC_TYPE_ORCP, orcpt); cleanup_out_string(state, REC_TYPE_RCPT, recip); state->rcpt_count++; @@ -199,10 +201,11 @@ void cleanup_out_recipient(CLEANUP_STATE *state, if (been_here(state->dups, "%s\n%d\n%s\n%s", dsn_orcpt, dsn_notify, orcpt, *cpp) == 0) { if (dsn_notify) - cleanup_out_format(state, REC_TYPE_DSN_NOTIFY, "%d", - dsn_notify); + cleanup_out_format(state, REC_TYPE_ATTR, "%s=%d", + MAIL_ATTR_DSN_NOTIFY, dsn_notify); if (*dsn_orcpt) - cleanup_out_string(state, REC_TYPE_DSN_ORCPT, dsn_orcpt); + cleanup_out_format(state, REC_TYPE_ATTR, "%s=%s", + MAIL_ATTR_DSN_ORCPT, dsn_orcpt); cleanup_out_string(state, REC_TYPE_ORCP, orcpt); cleanup_out_string(state, REC_TYPE_RCPT, *cpp); state->rcpt_count++; diff --git a/postfix/src/dns/dns.h b/postfix/src/dns/dns.h index 90a45b82c..a54d9a808 100644 --- a/postfix/src/dns/dns.h +++ b/postfix/src/dns/dns.h @@ -83,7 +83,7 @@ typedef struct DNS_RR { unsigned int ttl; /* always */ unsigned short pref; /* T_MX only */ struct DNS_RR *next; /* linkage */ - unsigned data_len; /* actual data size */ + size_t data_len; /* actual data size */ char data[1]; /* actually a bunch of data */ } DNS_RR; @@ -103,7 +103,7 @@ extern unsigned dns_type(const char *); */ extern DNS_RR *dns_rr_create(const char *, ushort, ushort, unsigned, unsigned, - const char *, unsigned); + const char *, size_t); extern void dns_rr_free(DNS_RR *); extern DNS_RR *dns_rr_copy(DNS_RR *); extern DNS_RR *dns_rr_append(DNS_RR *, DNS_RR *); diff --git a/postfix/src/dns/dns_lookup.c b/postfix/src/dns/dns_lookup.c index 6bb49f0aa..187da911e 100644 --- a/postfix/src/dns/dns_lookup.c +++ b/postfix/src/dns/dns_lookup.c @@ -344,7 +344,7 @@ static DNS_RR *dns_get_rr(DNS_REPLY *reply, unsigned char *pos, char *rr_name, DNS_FIXED *fixed) { char temp[DNS_NAME_LEN]; - int data_len; + ssize_t data_len; unsigned pref = 0; unsigned char *src; unsigned char *dst; diff --git a/postfix/src/dns/dns_rr.c b/postfix/src/dns/dns_rr.c index fe6a23067..01732d0dd 100644 --- a/postfix/src/dns/dns_rr.c +++ b/postfix/src/dns/dns_rr.c @@ -14,7 +14,7 @@ /* unsigned int ttl; /* unsigned preference; /* const char *data; -/* unsigned len; +/* size_t data_len; /* /* void dns_rr_free(list) /* DNS_RR *list; @@ -93,7 +93,7 @@ DNS_RR *dns_rr_create(const char *name, ushort type, ushort class, unsigned int ttl, unsigned pref, - const char *data, unsigned data_len) + const char *data, size_t data_len) { DNS_RR *rr; @@ -126,7 +126,7 @@ void dns_rr_free(DNS_RR *rr) DNS_RR *dns_rr_copy(DNS_RR *src) { - int len = sizeof(*src) + src->data_len - 1; + ssize_t len = sizeof(*src) + src->data_len - 1; DNS_RR *dst; /* diff --git a/postfix/src/dns/dns_rr_eq_sa.c b/postfix/src/dns/dns_rr_eq_sa.c index 27495fca6..baecab790 100644 --- a/postfix/src/dns/dns_rr_eq_sa.c +++ b/postfix/src/dns/dns_rr_eq_sa.c @@ -132,6 +132,7 @@ int main(int argc, char **argv) vstream_fflush(VSTREAM_OUT); argv += 1; } + return (0); } #endif diff --git a/postfix/src/global/anvil_clnt.c b/postfix/src/global/anvil_clnt.c index 7b4ea84b6..c54b9500b 100644 --- a/postfix/src/global/anvil_clnt.c +++ b/postfix/src/global/anvil_clnt.c @@ -337,7 +337,7 @@ int main(int unused_argc, char **argv) VSTRING *inbuf = vstring_alloc(1); char *bufp; char *cmd; - int cmd_len; + ssize_t cmd_len; char *service; char *addr; int count; diff --git a/postfix/src/global/bounce_log.c b/postfix/src/global/bounce_log.c index f28b1a70c..0fac7f986 100644 --- a/postfix/src/global/bounce_log.c +++ b/postfix/src/global/bounce_log.c @@ -18,7 +18,7 @@ /* const char *queue; /* const char *id; /* int flags; -/* int mode; +/* mode_t mode; /* /* BOUNCE_LOG *bounce_log_read(bp) /* BOUNCE_LOG *bp; @@ -73,7 +73,7 @@ /* file has the same name as the original message file. /* .IP flags /* File open flags, as with open(2). -/* .IP more +/* .IP mode /* File permissions, as with open(2). /* .PP /* Recipient results: @@ -152,7 +152,7 @@ /* bounce_log_open - open bounce read stream */ BOUNCE_LOG *bounce_log_open(const char *queue_name, const char *queue_id, - int flags, int mode) + int flags, mode_t mode) { BOUNCE_LOG *bp; VSTREAM *fp; diff --git a/postfix/src/global/bounce_log.h b/postfix/src/global/bounce_log.h index 67eea4159..235772ed3 100644 --- a/postfix/src/global/bounce_log.h +++ b/postfix/src/global/bounce_log.h @@ -41,7 +41,7 @@ typedef struct { DSN dsn; /* delivery status */ } BOUNCE_LOG; -extern BOUNCE_LOG *bounce_log_open(const char *, const char *, int, int); +extern BOUNCE_LOG *bounce_log_open(const char *, const char *, int, mode_t); extern BOUNCE_LOG *bounce_log_read(BOUNCE_LOG *); extern BOUNCE_LOG *bounce_log_delrcpt(BOUNCE_LOG *); extern BOUNCE_LOG *bounce_log_forge(RECIPIENT *, DSN *); diff --git a/postfix/src/global/defer.c b/postfix/src/global/defer.c index f11ba0242..32a304c16 100644 --- a/postfix/src/global/defer.c +++ b/postfix/src/global/defer.c @@ -257,7 +257,7 @@ int defer_flush(int flags, const char *queue, const char *id, * do not flush the log */ int defer_warn(int flags, const char *queue, const char *id, - const char *sender, const char *envid, int ret) + const char *sender, const char *envid, int dsn_ret) { if (mail_command_client(MAIL_CLASS_PRIVATE, var_defer_service, ATTR_TYPE_NUM, MAIL_ATTR_NREQ, BOUNCE_CMD_WARN, @@ -266,7 +266,7 @@ int defer_warn(int flags, const char *queue, const char *id, ATTR_TYPE_STR, MAIL_ATTR_QUEUEID, id, ATTR_TYPE_STR, MAIL_ATTR_SENDER, sender, ATTR_TYPE_STR, MAIL_ATTR_DSN_ENVID, envid, - ATTR_TYPE_NUM, MAIL_ATTR_DSN_RET, ret, + ATTR_TYPE_NUM, MAIL_ATTR_DSN_RET, dsn_ret, ATTR_TYPE_END) == 0) { return (0); } else { diff --git a/postfix/src/global/dict_proxy.c b/postfix/src/global/dict_proxy.c index 81aae3462..f4eea08bd 100644 --- a/postfix/src/global/dict_proxy.c +++ b/postfix/src/global/dict_proxy.c @@ -8,7 +8,7 @@ /* /* DICT *dict_proxy_open(map, open_flags, dict_flags) /* const char *map; -/* int dummy; +/* int open_flags; /* int dict_flags; /* DESCRIPTION /* dict_proxy_open() relays read-only operations through diff --git a/postfix/src/global/domain_list.c b/postfix/src/global/domain_list.c index a2e7d95ff..b5617a7aa 100644 --- a/postfix/src/global/domain_list.c +++ b/postfix/src/global/domain_list.c @@ -116,6 +116,7 @@ int main(int argc, char **argv) "YES" : "NO"); vstream_fflush(VSTREAM_OUT); domain_list_free(list); + return (0); } #endif diff --git a/postfix/src/global/dsn_util.c b/postfix/src/global/dsn_util.c index 8d4b2ef00..a4d7ceed5 100644 --- a/postfix/src/global/dsn_util.c +++ b/postfix/src/global/dsn_util.c @@ -112,7 +112,7 @@ size_t dsn_valid(const char *text) { const unsigned char *cp = (unsigned char *) text; - int len; + size_t len; /* First portion is one digit followed by dot. */ if ((cp[0] != '2' && cp[0] != '4' && cp[0] != '5') || cp[1] != '.') diff --git a/postfix/src/global/ehlo_mask.c b/postfix/src/global/ehlo_mask.c index d711731c4..811005487 100644 --- a/postfix/src/global/ehlo_mask.c +++ b/postfix/src/global/ehlo_mask.c @@ -110,6 +110,7 @@ const char *str_ehlo_mask(int mask_bits) /* * Stand-alone test program. */ +#include #include #include #include diff --git a/postfix/src/global/header_token.c b/postfix/src/global/header_token.c index 20bbc486e..337512574 100644 --- a/postfix/src/global/header_token.c +++ b/postfix/src/global/header_token.c @@ -14,10 +14,10 @@ /* .in /* } HEADER_TOKEN; /* -/* int header_token(token, token_len, token_buffer, ptr, +/* ssize_t header_token(token, token_len, token_buffer, ptr, /* specials, terminator) /* HEADER_TOKEN *token; -/* int token_len; +/* ssize_t token_len; /* VSTRING *token_buffer; /* const char **ptr; /* const char *specials; @@ -104,16 +104,16 @@ /* header_token - parse out the next item in a message header */ -int header_token(HEADER_TOKEN *token, int token_len, +ssize_t header_token(HEADER_TOKEN *token, ssize_t token_len, VSTRING *token_buffer, const char **ptr, const char *user_specials, int user_terminator) { - int comment_level; + ssize_t comment_level; const unsigned char *cp; - int len; + ssize_t len; int ch; - int tok_count; - int n; + ssize_t tok_count; + ssize_t n; /* * Initialize. diff --git a/postfix/src/global/header_token.h b/postfix/src/global/header_token.h index 222d3d79f..7154ef7e5 100644 --- a/postfix/src/global/header_token.h +++ b/postfix/src/global/header_token.h @@ -24,14 +24,14 @@ typedef struct HEADER_TOKEN { int type; /* see below */ union { const char *value; /* just a pointer, not a copy */ - int offset; /* index into token buffer */ + ssize_t offset; /* index into token buffer */ } u; /* indent beats any alternative */ } HEADER_TOKEN; #define HEADER_TOK_TOKEN 256 #define HEADER_TOK_QSTRING 257 -extern int header_token(HEADER_TOKEN *, int, VSTRING *, const char **, const char *, int); +extern ssize_t header_token(HEADER_TOKEN *, ssize_t, VSTRING *, const char **, const char *, int); /* LICENSE /* .ad diff --git a/postfix/src/global/mail_addr_crunch.c b/postfix/src/global/mail_addr_crunch.c index cd1bda9b1..8f92d2968 100644 --- a/postfix/src/global/mail_addr_crunch.c +++ b/postfix/src/global/mail_addr_crunch.c @@ -66,7 +66,7 @@ ARGV *mail_addr_crunch(const char *string, const char *extension) TOK822 **addr_list; TOK822 **tpp; char *ratsign; - int extlen; + ssize_t extlen; if (extension) extlen = strlen(extension); @@ -113,6 +113,7 @@ ARGV *mail_addr_crunch(const char *string, const char *extension) /* * Stand-alone test program, sort of interactive. */ +#include #include #include #include @@ -144,6 +145,7 @@ int main(int unused_argc, char **unused_argv) vstream_printf(" %s\n", *cpp); vstream_fflush(VSTREAM_OUT); } + return (0); } #endif diff --git a/postfix/src/global/mail_addr_find.c b/postfix/src/global/mail_addr_find.c index c08f9dbcf..cda022b04 100644 --- a/postfix/src/global/mail_addr_find.c +++ b/postfix/src/global/mail_addr_find.c @@ -213,6 +213,7 @@ int main(int argc, char **argv) vstring_free(buffer); maps_free(path); + return (0); } #endif diff --git a/postfix/src/global/mail_addr_map.c b/postfix/src/global/mail_addr_map.c index df6237ec6..ad0c6c394 100644 --- a/postfix/src/global/mail_addr_map.c +++ b/postfix/src/global/mail_addr_map.c @@ -191,6 +191,7 @@ int main(int argc, char **argv) } vstring_free(buffer); maps_free(path); + return (0); } #endif diff --git a/postfix/src/global/mail_conf_raw.c b/postfix/src/global/mail_conf_raw.c index 4c7927d5a..2e4c9832e 100644 --- a/postfix/src/global/mail_conf_raw.c +++ b/postfix/src/global/mail_conf_raw.c @@ -76,14 +76,14 @@ static void check_mail_conf_raw(const char *name, const char *strval, int min, int max) { - int len = strlen(strval); + ssize_t len = strlen(strval); if (min && len < min) - msg_fatal("bad string length (%d < %d): %s = %s", - len, min, name, strval); + msg_fatal("bad string length (%ld < %d): %s = %s", + (long) len, min, name, strval); if (max && len > max) - msg_fatal("bad string length (%d > %d): %s = %s", - len, max, name, strval); + msg_fatal("bad string length (%ld > %d): %s = %s", + (long) len, max, name, strval); } /* get_mail_conf_raw - evaluate string-valued configuration variable */ diff --git a/postfix/src/global/mail_conf_str.c b/postfix/src/global/mail_conf_str.c index 1c2c170ab..bb734520d 100644 --- a/postfix/src/global/mail_conf_str.c +++ b/postfix/src/global/mail_conf_str.c @@ -84,14 +84,14 @@ static void check_mail_conf_str(const char *name, const char *strval, int min, int max) { - int len = strlen(strval); + ssize_t len = strlen(strval); if (min && len < min) - msg_fatal("bad string length %d < %d: %s = %s", - len, min, name, strval); + msg_fatal("bad string length %ld < %d: %s = %s", + (long) len, min, name, strval); if (max && len > max) - msg_fatal("bad string length %d > %d: %s = %s", - len, max, name, strval); + msg_fatal("bad string length %ld > %d: %s = %s", + (long) len, max, name, strval); } /* get_mail_conf_str - evaluate string-valued configuration variable */ diff --git a/postfix/src/global/mail_conf_time.c b/postfix/src/global/mail_conf_time.c index 682a6863d..e7c4f0c5a 100644 --- a/postfix/src/global/mail_conf_time.c +++ b/postfix/src/global/mail_conf_time.c @@ -237,6 +237,7 @@ int main(int unused_argc, char **unused_argv) vstream_printf("10 days = %d\n", days); vstream_printf("10 weeks = %d\n", weeks); vstream_fflush(VSTREAM_OUT); + return (0); } #endif diff --git a/postfix/src/global/mail_proto.h b/postfix/src/global/mail_proto.h index a170596c0..53ca483a8 100644 --- a/postfix/src/global/mail_proto.h +++ b/postfix/src/global/mail_proto.h @@ -84,7 +84,7 @@ extern VSTREAM *mail_connect(const char *, const char *, int); extern VSTREAM *mail_connect_wait(const char *, const char *); extern int mail_command_client(const char *, const char *,...); extern int mail_command_server(VSTREAM *,...); -extern int mail_trigger(const char *, const char *, const char *, int); +extern int mail_trigger(const char *, const char *, const char *, ssize_t); extern char *mail_pathname(const char *, const char *); /* diff --git a/postfix/src/global/mail_queue.c b/postfix/src/global/mail_queue.c index 9068955c3..1b9f31611 100644 --- a/postfix/src/global/mail_queue.c +++ b/postfix/src/global/mail_queue.c @@ -8,13 +8,13 @@ /* /* VSTREAM *mail_queue_enter(queue_name, mode) /* const char *queue_name; -/* int mode; +/* mode_t mode; /* /* VSTREAM *mail_queue_open(queue_name, queue_id, flags, mode) /* const char *queue_name; /* const char *queue_id; /* int flags; -/* int mode; +/* mode_t mode; /* /* char *mail_queue_dir(buf, queue_name, queue_id) /* VSTRING *buf; @@ -304,7 +304,7 @@ int mail_queue_id_ok(const char *queue_id) /* mail_queue_enter - make mail queue entry with locally-unique name */ -VSTREAM *mail_queue_enter(const char *queue_name, int mode) +VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode) { char *myname = "mail_queue_enter"; static VSTRING *id_buf; @@ -407,7 +407,7 @@ VSTREAM *mail_queue_enter(const char *queue_name, int mode) /* mail_queue_open - open mail queue file */ VSTREAM *mail_queue_open(const char *queue_name, const char *queue_id, - int flags, int mode) + int flags, mode_t mode) { const char *path = mail_queue_path((VSTRING *) 0, queue_name, queue_id); VSTREAM *fp; diff --git a/postfix/src/global/mail_queue.h b/postfix/src/global/mail_queue.h index b3d692821..19c04b7b8 100644 --- a/postfix/src/global/mail_queue.h +++ b/postfix/src/global/mail_queue.h @@ -37,8 +37,8 @@ #define MAIL_QUEUE_STAT_READY (S_IRUSR | S_IWUSR | S_IXUSR) #define MAIL_QUEUE_STAT_CORRUPT (S_IRUSR) -extern struct VSTREAM *mail_queue_enter(const char *, int); -extern struct VSTREAM *mail_queue_open(const char *, const char *, int, int); +extern struct VSTREAM *mail_queue_enter(const char *, mode_t); +extern struct VSTREAM *mail_queue_open(const char *, const char *, int, mode_t); extern int mail_queue_rename(const char *, const char *, const char *); extern int mail_queue_remove(const char *, const char *); extern const char *mail_queue_dir(VSTRING *, const char *, const char *); diff --git a/postfix/src/global/mail_stream.c b/postfix/src/global/mail_stream.c index 86d1da83f..5ac392b1a 100644 --- a/postfix/src/global/mail_stream.c +++ b/postfix/src/global/mail_stream.c @@ -88,7 +88,8 @@ /* .IP "MAIL_STREAM_CTL_SERVICE (char *)" /* The argument specifies an alternate trigger service. /* .IP "MAIL_STREAM_CTL_MODE (int)" -/* The argument specifies an altername file mode. +/* The argument specifies alternate permissions that override +/* the permissions specified with mail_stream_file(). /* LICENSE /* .ad /* .fi diff --git a/postfix/src/global/mail_trigger.c b/postfix/src/global/mail_trigger.c index 457f19d6b..5f9ac580a 100644 --- a/postfix/src/global/mail_trigger.c +++ b/postfix/src/global/mail_trigger.c @@ -10,7 +10,7 @@ /* const char *class; /* const char *service; /* const char *request; -/* int length; +/* ssize_t length; /* DESCRIPTION /* mail_trigger() wakes up the specified mail subsystem, by /* sending it the specified request. @@ -67,7 +67,7 @@ /* mail_trigger - trigger a service */ int mail_trigger(const char *class, const char *service, - const char *req_buf, int req_len) + const char *req_buf, ssize_t req_len) { struct stat st; char *path; diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 87fbef89d..fba46100c 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -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 "20050708" +#define MAIL_RELEASE_DATE "20050714" #define MAIL_VERSION_NUMBER "2.3" #define VAR_MAIL_VERSION "mail_version" diff --git a/postfix/src/global/maps.c b/postfix/src/global/maps.c index 8df010706..ad97ee6d6 100644 --- a/postfix/src/global/maps.c +++ b/postfix/src/global/maps.c @@ -239,6 +239,7 @@ int main(int argc, char **argv) } maps_free(maps); vstring_free(buf); + return (0); } #endif diff --git a/postfix/src/global/mbox_open.c b/postfix/src/global/mbox_open.c index 7c6751058..de3d1551e 100644 --- a/postfix/src/global/mbox_open.c +++ b/postfix/src/global/mbox_open.c @@ -17,7 +17,7 @@ /* def_dsn, why) /* const char *path; /* int flags; -/* int mode; +/* mode_t mode; /* struct stat *st; /* uid_t user; /* gid_t group; @@ -101,7 +101,7 @@ /* mbox_open - open mailbox-style file for exclusive access */ -MBOX *mbox_open(const char *path, int flags, int mode, struct stat * st, +MBOX *mbox_open(const char *path, int flags, mode_t mode, struct stat * st, uid_t chown_uid, gid_t chown_gid, int lock_style, const char *def_dsn, DSN_BUF *why) diff --git a/postfix/src/global/mbox_open.h b/postfix/src/global/mbox_open.h index 843c37709..54d13c659 100644 --- a/postfix/src/global/mbox_open.h +++ b/postfix/src/global/mbox_open.h @@ -31,7 +31,7 @@ typedef struct { VSTREAM *fp; /* open stream or null */ int locked; /* what locks were set */ } MBOX; -extern MBOX *mbox_open(const char *, int, int, struct stat *, uid_t, gid_t, +extern MBOX *mbox_open(const char *, int, mode_t, struct stat *, uid_t, gid_t, int, const char *, DSN_BUF *); extern void mbox_release(MBOX *); extern const char *mbox_dsn(int, const char *); diff --git a/postfix/src/global/mime_state.c b/postfix/src/global/mime_state.c index 409e1231d..31c166508 100644 --- a/postfix/src/global/mime_state.c +++ b/postfix/src/global/mime_state.c @@ -7,15 +7,15 @@ /* #include /* /* MIME_STATE *mime_state_alloc(flags, head_out, head_end, -/* body_out, body_end, -/* err_print, context) +/* body_out, body_end, +/* err_print, context) /* int flags; /* void (*head_out)(void *ptr, int header_class, /* HEADER_OPTS *header_info, /* VSTRING *buf, off_t offset); /* void (*head_end)(void *ptr); /* void (*body_out)(void *ptr, int rec_type, -/* const char *buf, int len, +/* const char *buf, ssize_t len, /* off_t offset); /* void (*body_end)(void *ptr); /* void (*err_print)(void *ptr, int err_flag, const char *text) @@ -25,7 +25,7 @@ /* MIME_STATE *state; /* int rec_type; /* const char *buf; -/* int len; +/* ssize_t len; /* /* MIME_STATE *mime_state_free(state) /* MIME_STATE *state; @@ -269,7 +269,7 @@ typedef struct MIME_STACK { int def_ctype; /* default content type */ int def_stype; /* default content subtype */ char *boundary; /* boundary string */ - int bound_len; /* boundary length */ + ssize_t bound_len; /* boundary length */ struct MIME_STACK *next; /* linkage */ } MIME_STACK; @@ -516,7 +516,7 @@ static void mime_state_content_type(MIME_STATE *state, HEADER_OPTS *header_info) { const char *cp; - int tok_count; + ssize_t tok_count; int def_ctype; int def_stype; @@ -665,7 +665,7 @@ static const char *mime_state_enc_name(int encoding) /* mime_state_downgrade - convert 8-bit data to quoted-printable */ static void mime_state_downgrade(MIME_STATE *state, int rec_type, - const char *text, int len) + const char *text, ssize_t len) { static char hexchars[] = "0123456789ABCDEF"; const unsigned char *cp; @@ -723,7 +723,7 @@ static void mime_state_downgrade(MIME_STATE *state, int rec_type, /* mime_state_update - update MIME state machine */ int mime_state_update(MIME_STATE *state, int rec_type, - const char *text, int len) + const char *text, ssize_t len) { int input_is_text = (rec_type == REC_TYPE_NORM || rec_type == REC_TYPE_CONT); @@ -1108,7 +1108,7 @@ static void head_end(void *context) vstream_fprintf(stream, "HEADER END\n"); } -static void body_out(void *context, int rec_type, const char *buf, int len, +static void body_out(void *context, int rec_type, const char *buf, ssize_t len, off_t offset) { VSTREAM *stream = (VSTREAM *) context; diff --git a/postfix/src/global/mime_state.h b/postfix/src/global/mime_state.h index 820be4288..952967b11 100644 --- a/postfix/src/global/mime_state.h +++ b/postfix/src/global/mime_state.h @@ -26,12 +26,12 @@ */ typedef struct MIME_STATE MIME_STATE; typedef void (*MIME_STATE_HEAD_OUT) (void *, int, HEADER_OPTS *, VSTRING *, off_t); -typedef void (*MIME_STATE_BODY_OUT) (void *, int, const char *, int, off_t); +typedef void (*MIME_STATE_BODY_OUT) (void *, int, const char *, ssize_t, off_t); typedef void (*MIME_STATE_ANY_END) (void *); typedef void (*MIME_STATE_ERR_PRINT) (void *, int, const char *); extern MIME_STATE *mime_state_alloc(int, MIME_STATE_HEAD_OUT, MIME_STATE_ANY_END, MIME_STATE_BODY_OUT, MIME_STATE_ANY_END, MIME_STATE_ERR_PRINT, void *); -extern int mime_state_update(MIME_STATE *, int, const char *, int); +extern int mime_state_update(MIME_STATE *, int, const char *, ssize_t); extern MIME_STATE *mime_state_free(MIME_STATE *); /* diff --git a/postfix/src/global/mynetworks.c b/postfix/src/global/mynetworks.c index d698be7fc..9a910a032 100644 --- a/postfix/src/global/mynetworks.c +++ b/postfix/src/global/mynetworks.c @@ -90,10 +90,10 @@ const char *mynetworks(void) char *myname = "mynetworks"; INET_ADDR_LIST *my_addr_list; INET_ADDR_LIST *my_mask_list; - int shift; - int junk; + unsigned shift; + unsigned junk; int i; - int mask_style; + unsigned mask_style; struct sockaddr_storage *sa; struct sockaddr_storage *ma; int net_mask_count = 0; @@ -109,7 +109,7 @@ const char *mynetworks(void) * require exactly one value, or we need to provide an API that is * dedicated for single-valued flags. */ - for (i = 0, junk = mask_style; junk != 0; junk >>= 1) + for (i = 0, junk = mask_style; junk != 0; junk >>= 1U) i += (junk & 1); if (i != 1) msg_fatal("bad %s value: %s; specify exactly one value", @@ -293,6 +293,7 @@ int main(int argc, char **argv) var_mynetworks_style = argv[2]; var_inet_interfaces = argv[3]; mynetworks(); + return (0); } #endif diff --git a/postfix/src/global/mypwd.c b/postfix/src/global/mypwd.c index 23fb29589..2b7821382 100644 --- a/postfix/src/global/mypwd.c +++ b/postfix/src/global/mypwd.c @@ -228,6 +228,7 @@ int main(int argc, char **argv) } myfree((char *) mypwd); + return (0); } #endif diff --git a/postfix/src/global/namadr_list.c b/postfix/src/global/namadr_list.c index 3388023b3..f74b8337a 100644 --- a/postfix/src/global/namadr_list.c +++ b/postfix/src/global/namadr_list.c @@ -125,6 +125,7 @@ int main(int argc, char **argv) "YES" : "NO"); vstream_fflush(VSTREAM_OUT); namadr_list_free(list); + return (0); } #endif diff --git a/postfix/src/global/off_cvt.c b/postfix/src/global/off_cvt.c index 756b63c8c..d56051681 100644 --- a/postfix/src/global/off_cvt.c +++ b/postfix/src/global/off_cvt.c @@ -152,6 +152,7 @@ int main(int unused_argc, char **unused_argv) vstream_fflush(VSTREAM_OUT); } vstring_free(buf); + return (0); } #endif diff --git a/postfix/src/global/pipe_command.c b/postfix/src/global/pipe_command.c index ebdcd6ef0..d3319ec30 100644 --- a/postfix/src/global/pipe_command.c +++ b/postfix/src/global/pipe_command.c @@ -69,11 +69,11 @@ /* \fImail_copy\fR() routine. /* .IP "PIPE_CMD_EOL (char *)" /* End-of-line delimiter. The default is to use the newline character. -/* .IP "PIPE_CMD_UID (int)" +/* .IP "PIPE_CMD_UID (uid_t)" /* The user ID to execute the command as. The default is /* the user ID corresponding to the \fIdefault_privs\fR /* configuration parameter. The user ID must be non-zero. -/* .IP "PIPE_CMD_GID (int)" +/* .IP "PIPE_CMD_GID (gid_t)" /* The group ID to execute the command as. The default is /* the group ID corresponding to the \fIdefault_privs\fR /* configuration parameter. The group ID must be non-zero. @@ -234,10 +234,10 @@ static void get_pipe_args(struct pipe_args * args, va_list ap) args->command = va_arg(ap, char *); break; case PIPE_CMD_UID: - args->uid = va_arg(ap, int); /* in case uid_t is short */ + args->uid = va_arg(ap, uid_t); /* in case uid_t is short */ break; case PIPE_CMD_GID: - args->gid = va_arg(ap, int); /* in case gid_t is short */ + args->gid = va_arg(ap, gid_t); /* in case gid_t is short */ break; case PIPE_CMD_TIME_LIMIT: pipe_command_maxtime = va_arg(ap, int); @@ -268,7 +268,7 @@ static void get_pipe_args(struct pipe_args * args, va_list ap) /* pipe_command_write - write to command with time limit */ -static int pipe_command_write(int fd, void *buf, unsigned len) +static ssize_t pipe_command_write(int fd, void *buf, ssize_t len) { int maxtime = (pipe_command_timeout == 0) ? pipe_command_maxtime : 0; char *myname = "pipe_command_write"; @@ -289,7 +289,7 @@ static int pipe_command_write(int fd, void *buf, unsigned len) /* pipe_command_read - read from command with time limit */ -static int pipe_command_read(int fd, void *buf, unsigned len) +static ssize_t pipe_command_read(int fd, void *buf, ssize_t len) { int maxtime = (pipe_command_timeout == 0) ? pipe_command_maxtime : 0; char *myname = "pipe_command_read"; @@ -574,7 +574,7 @@ int pipe_command(VSTREAM *src, DSN_BUF *why,...) else if (dsn_valid(log_buf) > 0) { dsn_split(&dp, "5.3.0", log_buf); dsb_unix(why, DSN_STATUS(dp.dsn), DSN_CLASS(dp.dsn) == '4' ? - EX_TEMPFAIL : EX_UNAVAILABLE, dp.text, "%s", dp.text); + EX_TEMPFAIL : EX_UNAVAILABLE, dp.text, "%s", dp.text); return (DSN_CLASS(dp.dsn) == '4' ? PIPE_STAT_DEFER : PIPE_STAT_BOUNCE); } diff --git a/postfix/src/global/post_mail.c b/postfix/src/global/post_mail.c index b79967dd1..93850d934 100644 --- a/postfix/src/global/post_mail.c +++ b/postfix/src/global/post_mail.c @@ -383,7 +383,7 @@ int post_mail_buffer(VSTREAM *cleanup, const char *buf, int len) int post_mail_fputs(VSTREAM *cleanup, const char *str) { - int len = str ? strlen(str) : 0; + ssize_t len = str ? strlen(str) : 0; return (rec_put(cleanup, REC_TYPE_NORM, str, len) != REC_TYPE_NORM ? CLEANUP_STAT_WRITE : 0); diff --git a/postfix/src/global/quote_822_local.c b/postfix/src/global/quote_822_local.c index bf18059d3..a16149d2b 100644 --- a/postfix/src/global/quote_822_local.c +++ b/postfix/src/global/quote_822_local.c @@ -235,6 +235,7 @@ int main(int unused_argc, char **unused_argv) vstring_free(unquoted); vstring_free(quoted); vstring_free(raw); + return (0); } #endif diff --git a/postfix/src/global/rec2stream.c b/postfix/src/global/rec2stream.c index 8188f1f6e..4b72c42e2 100644 --- a/postfix/src/global/rec2stream.c +++ b/postfix/src/global/rec2stream.c @@ -43,4 +43,5 @@ int main(void) while ((type = rec_get(VSTREAM_IN, buf, 0)) > 0) REC_STREAMLF_PUT_BUF(VSTREAM_OUT, type, buf); vstream_fflush(VSTREAM_OUT); + return (0); } diff --git a/postfix/src/global/recdump.c b/postfix/src/global/recdump.c index 74ff7ea02..aa13eb644 100644 --- a/postfix/src/global/recdump.c +++ b/postfix/src/global/recdump.c @@ -24,6 +24,7 @@ /* System library. */ #include +#include /* Utility library. */ @@ -46,9 +47,9 @@ int main(int unused_argc, char **argv) while (offset = vstream_ftell(VSTREAM_IN), ((type = rec_get(VSTREAM_IN, buf, 0)) != REC_TYPE_EOF && type != REC_TYPE_ERROR)) { - vstream_fprintf(VSTREAM_OUT, "%15s|%4ld|%3d|%s\n", + vstream_fprintf(VSTREAM_OUT, "%15s|%4ld|%3ld|%s\n", rec_type_name(type), offset, - VSTRING_LEN(buf), vstring_str(buf)); + (long) VSTRING_LEN(buf), vstring_str(buf)); } vstream_fflush(VSTREAM_OUT); vstring_free(buf); diff --git a/postfix/src/global/record.c b/postfix/src/global/record.c index 5e91a9ee5..2e63278ef 100644 --- a/postfix/src/global/record.c +++ b/postfix/src/global/record.c @@ -9,13 +9,13 @@ /* int rec_get(stream, buf, maxsize) /* VSTREAM *stream; /* VSTRING *buf; -/* int maxsize; +/* ssize_t maxsize; /* /* int rec_put(stream, type, data, len) /* VSTREAM *stream; /* int type; /* const char *data; -/* int len; +/* ssize_t len; /* AUXILIARY FUNCTIONS /* int rec_put_type(stream, type, offset) /* VSTREAM *stream; @@ -129,16 +129,17 @@ int rec_put_type(VSTREAM *stream, int type, long offset) /* rec_put - store typed record */ -int rec_put(VSTREAM *stream, int type, const char *data, int len) +int rec_put(VSTREAM *stream, int type, const char *data, ssize_t len) { - int len_rest; - int len_byte; + ssize_t len_rest; + ssize_t len_byte; if (type < 0 || type > 255) msg_panic("rec_put: bad record type %d", type); if (msg_verbose > 2) - msg_info("rec_put: type %c len %d data %.10s", type, len, data); + msg_info("rec_put: type %c len %ld data %.10s", + type, (long) len, data); /* * Write the record type, one byte. @@ -153,7 +154,7 @@ int rec_put(VSTREAM *stream, int type, const char *data, int len) len_rest = len; do { len_byte = len_rest & 0177; - if (len_rest >>= 7) + if (len_rest >>= 7U) len_byte |= 0200; if (VSTREAM_PUTC(len_byte, stream) == VSTREAM_EOF) { return (REC_TYPE_ERROR); @@ -170,19 +171,19 @@ int rec_put(VSTREAM *stream, int type, const char *data, int len) /* rec_get - retrieve typed record */ -int rec_get(VSTREAM *stream, VSTRING *buf, int maxsize) +int rec_get(VSTREAM *stream, VSTRING *buf, ssize_t maxsize) { char *myname = "rec_get"; int type; - int len; + ssize_t len; int len_byte; - int shift; + unsigned shift; /* * Sanity check. */ if (maxsize < 0) - msg_panic("%s: bad record size limit: %d", myname, maxsize); + msg_panic("%s: bad record size limit: %ld", myname, (long) maxsize); /* * Extract the record type. @@ -211,8 +212,8 @@ int rec_get(VSTREAM *stream, VSTRING *buf, int maxsize) break; } if (len < 0 || (maxsize > 0 && len > maxsize)) { - msg_warn("%s: illegal length %d, record type %d", - VSTREAM_PATH(stream), len, type); + msg_warn("%s: illegal length %ld, record type %d", + VSTREAM_PATH(stream), (long) len, type); while (len-- > 0 && VSTREAM_GETC(stream) != VSTREAM_EOF) /* void */ ; return (REC_TYPE_ERROR); @@ -225,15 +226,15 @@ int rec_get(VSTREAM *stream, VSTRING *buf, int maxsize) VSTRING_RESET(buf); VSTRING_SPACE(buf, len); if (vstream_fread(stream, vstring_str(buf), len) != len) { - msg_warn("%s: unexpected EOF in data, record type %d length %d", - VSTREAM_PATH(stream), type, len); + msg_warn("%s: unexpected EOF in data, record type %d length %ld", + VSTREAM_PATH(stream), type, (long) len); return (REC_TYPE_ERROR); } VSTRING_AT_OFFSET(buf, len); VSTRING_TERMINATE(buf); if (msg_verbose > 2) - msg_info("%s: type %c len %d data %.10s", myname, - type, len, vstring_str(buf)); + msg_info("%s: type %c len %ld data %.10s", myname, + type, (unsigned long) len, vstring_str(buf)); return (type); } diff --git a/postfix/src/global/record.h b/postfix/src/global/record.h index da91dc3e1..32e724cfb 100644 --- a/postfix/src/global/record.h +++ b/postfix/src/global/record.h @@ -32,8 +32,8 @@ /* * Functional interface. */ -extern int rec_get(VSTREAM *, VSTRING *, int); -extern int rec_put(VSTREAM *, int, const char *, int); +extern int rec_get(VSTREAM *, VSTRING *, ssize_t); +extern int rec_put(VSTREAM *, int, const char *, ssize_t); extern int rec_put_type(VSTREAM *, int, long); extern int PRINTFLIKE(3, 4) rec_fprintf(VSTREAM *, int, const char *,...); extern int rec_fputs(VSTREAM *, int, const char *); diff --git a/postfix/src/global/resolve_local.c b/postfix/src/global/resolve_local.c index 830ad54c2..fdbf7c528 100644 --- a/postfix/src/global/resolve_local.c +++ b/postfix/src/global/resolve_local.c @@ -76,7 +76,7 @@ int resolve_local(const char *addr) char *dest; const char *bare_dest; struct addrinfo *res0 = 0; - int len; + ssize_t len; #define RETURN(x) \ do { \ @@ -170,6 +170,7 @@ int main(int argc, char **argv) mail_conf_read(); vstream_printf("%s\n", resolve_local(argv[1]) ? "yes" : "no"); vstream_fflush(VSTREAM_OUT); + return (0); } #endif diff --git a/postfix/src/global/scache.c b/postfix/src/global/scache.c index 61347047b..2a242ae0e 100644 --- a/postfix/src/global/scache.c +++ b/postfix/src/global/scache.c @@ -148,6 +148,7 @@ #include #include #include +#include /* Utility library. */ diff --git a/postfix/src/global/smtp_stream.c b/postfix/src/global/smtp_stream.c index ba4b78e7c..dbaf48c6c 100644 --- a/postfix/src/global/smtp_stream.c +++ b/postfix/src/global/smtp_stream.c @@ -23,16 +23,16 @@ /* int smtp_get(vp, stream, maxlen) /* VSTRING *vp; /* VSTREAM *stream; -/* int maxlen; +/* ssize_t maxlen; /* /* void smtp_fputs(str, len, stream) /* const char *str; -/* int len; +/* ssize_t len; /* VSTREAM *stream; /* /* void smtp_fwrite(str, len, stream) /* const char *str; -/* int len; +/* ssize_t len; /* VSTREAM *stream; /* /* void smtp_fputc(ch, stream) @@ -247,7 +247,7 @@ int smtp_fgetc(VSTREAM *stream) /* smtp_get - read one line from SMTP peer */ -int smtp_get(VSTRING *vp, VSTREAM *stream, int bound) +int smtp_get(VSTRING *vp, VSTREAM *stream, ssize_t bound) { int last_char; int next_char; @@ -317,12 +317,12 @@ int smtp_get(VSTRING *vp, VSTREAM *stream, int bound) /* smtp_fputs - write one line to SMTP peer */ -void smtp_fputs(const char *cp, int todo, VSTREAM *stream) +void smtp_fputs(const char *cp, ssize_t todo, VSTREAM *stream) { - unsigned err; + size_t err; if (todo < 0) - msg_panic("smtp_fputs: negative todo %d", todo); + msg_panic("smtp_fputs: negative todo %ld", (long) todo); /* * Do the I/O, protected against timeout. @@ -344,12 +344,12 @@ void smtp_fputs(const char *cp, int todo, VSTREAM *stream) /* smtp_fwrite - write one string to SMTP peer */ -void smtp_fwrite(const char *cp, int todo, VSTREAM *stream) +void smtp_fwrite(const char *cp, ssize_t todo, VSTREAM *stream) { - unsigned err; + size_t err; if (todo < 0) - msg_panic("smtp_fwrite: negative todo %d", todo); + msg_panic("smtp_fwrite: negative todo %ld", (long) todo); /* * Do the I/O, protected against timeout. diff --git a/postfix/src/global/smtp_stream.h b/postfix/src/global/smtp_stream.h index cbd0f7aba..2fc2f5f66 100644 --- a/postfix/src/global/smtp_stream.h +++ b/postfix/src/global/smtp_stream.h @@ -33,9 +33,9 @@ extern void smtp_timeout_setup(VSTREAM *, int); extern void PRINTFLIKE(2, 3) smtp_printf(VSTREAM *, const char *,...); extern void smtp_flush(VSTREAM *); extern int smtp_fgetc(VSTREAM *); -extern int smtp_get(VSTRING *, VSTREAM *, int); -extern void smtp_fputs(const char *, int len, VSTREAM *); -extern void smtp_fwrite(const char *, int len, VSTREAM *); +extern int smtp_get(VSTRING *, VSTREAM *, ssize_t); +extern void smtp_fputs(const char *, ssize_t len, VSTREAM *); +extern void smtp_fwrite(const char *, ssize_t len, VSTREAM *); extern void smtp_fputc(int, VSTREAM *); extern void smtp_vprintf(VSTREAM *, const char *, va_list); diff --git a/postfix/src/global/stream2rec.c b/postfix/src/global/stream2rec.c index a7da5c5ea..1dbd96229 100644 --- a/postfix/src/global/stream2rec.c +++ b/postfix/src/global/stream2rec.c @@ -43,4 +43,5 @@ int main(void) while ((type = rec_streamlf_get(VSTREAM_IN, buf, 150)) > 0) REC_PUT_BUF(VSTREAM_OUT, type, buf); vstream_fflush(VSTREAM_OUT); + return (0); } diff --git a/postfix/src/global/string_list.c b/postfix/src/global/string_list.c index bed30deab..42cbec009 100644 --- a/postfix/src/global/string_list.c +++ b/postfix/src/global/string_list.c @@ -105,6 +105,7 @@ int main(int argc, char **argv) "YES" : "NO"); vstream_fflush(VSTREAM_OUT); string_list_free(list); + return (0); } #endif diff --git a/postfix/src/global/tok822_parse.c b/postfix/src/global/tok822_parse.c index c337ccb8f..63f998c95 100644 --- a/postfix/src/global/tok822_parse.c +++ b/postfix/src/global/tok822_parse.c @@ -243,7 +243,7 @@ VSTRING *tok822_internalize(VSTRING *vp, TOK822 *tree, int flags) /* strip_address - strip non-address text from address expression */ -static void strip_address(VSTRING *vp, int start, TOK822 *addr) +static void strip_address(VSTRING *vp, ssize_t start, TOK822 *addr) { VSTRING *tmp; @@ -270,9 +270,9 @@ VSTRING *tok822_externalize(VSTRING *vp, TOK822 *tree, int flags) { VSTRING *tmp; TOK822 *tp; - int start; + ssize_t start; TOK822 *addr; - int addr_len; + ssize_t addr_len; /* * Guard against a Sendmail buffer overflow (CERT advisory CA-2003-07). diff --git a/postfix/src/global/verify_clnt.c b/postfix/src/global/verify_clnt.c index 5c45ea621..14dd3cd5e 100644 --- a/postfix/src/global/verify_clnt.c +++ b/postfix/src/global/verify_clnt.c @@ -284,6 +284,7 @@ int main(int argc, char **argv) msg_warn("unrecognized command: %s", command); } vstring_free(buffer); + return (0); } #endif diff --git a/postfix/src/global/verp_sender.c b/postfix/src/global/verp_sender.c index b7c0f806e..bed3b3d8c 100644 --- a/postfix/src/global/verp_sender.c +++ b/postfix/src/global/verp_sender.c @@ -66,8 +66,8 @@ VSTRING *verp_sender(VSTRING *buf, const char *delimiters, const char *sender, const char *recipient) { - int send_local_len; - int rcpt_local_len; + ssize_t send_local_len; + ssize_t rcpt_local_len; const char *cp; /* diff --git a/postfix/src/global/xtext.c b/postfix/src/global/xtext.c index c711cafda..a736070f5 100644 --- a/postfix/src/global/xtext.c +++ b/postfix/src/global/xtext.c @@ -132,9 +132,9 @@ VSTRING *xtext_unquote(VSTRING *unquoted, const char *quoted) #define BUFLEN 1024 -static int read_buf(VSTREAM *fp, VSTRING *buf) +static ssize_t read_buf(VSTREAM *fp, VSTRING *buf) { - int len; + ssize_t len; VSTRING_RESET(buf); len = vstream_fread(fp, STR(buf), vstring_avail(buf)); @@ -147,14 +147,15 @@ int main(int unused_argc, char **unused_argv) { VSTRING *unquoted = vstring_alloc(BUFLEN); VSTRING *quoted = vstring_alloc(100); - int len; + ssize_t len; while ((len = read_buf(VSTREAM_IN, unquoted)) > 0) { xtext_quote(quoted, STR(unquoted), "+="); if (xtext_unquote(unquoted, STR(quoted)) == 0) msg_fatal("bad input: %.100s", STR(quoted)); if (LEN(unquoted) != len) - msg_fatal("len %d != unquoted len %d", len, LEN(unquoted)); + msg_fatal("len %ld != unquoted len %ld", + (long) len, (long) LEN(unquoted)); if (vstream_fwrite(VSTREAM_OUT, STR(unquoted), LEN(unquoted)) != LEN(unquoted)) msg_fatal("write error: %m"); } diff --git a/postfix/src/lmtp/lmtp_chat.c b/postfix/src/lmtp/lmtp_chat.c index 608b8a8f3..e99107c2a 100644 --- a/postfix/src/lmtp/lmtp_chat.c +++ b/postfix/src/lmtp/lmtp_chat.c @@ -286,11 +286,11 @@ LMTP_RESP *lmtp_chat_resp(LMTP_STATE *state) /* print_line - line_wrap callback */ -static void print_line(const char *str, int len, int indent, char *context) +static void print_line(const char *str, ssize_t len, ssize_t indent, char *context) { VSTREAM *notice = (VSTREAM *) context; - post_mail_fprintf(notice, " %*s%.*s", indent, "", len, str); + post_mail_fprintf(notice, " %*s%.*s", (int) indent, "", (int) len, str); } /* lmtp_chat_notify - notify postmaster */ diff --git a/postfix/src/local/biff_notify.c b/postfix/src/local/biff_notify.c index 2b02508d3..b189ad4b2 100644 --- a/postfix/src/local/biff_notify.c +++ b/postfix/src/local/biff_notify.c @@ -8,7 +8,7 @@ /* /* void biff_notify(text, len) /* const char *text; -/* int len; +/* ssize_t len; /* DESCRIPTION /* biff_notify() sends a \fBBIFF\fR notification request to the /* \fBcomsat\fR daemon. @@ -50,7 +50,7 @@ /* biff_notify - notify recipient via the biff "protocol" */ -void biff_notify(const char *text, int len) +void biff_notify(const char *text, ssize_t len) { static struct sockaddr_in sin; static int sock = -1; diff --git a/postfix/src/local/biff_notify.h b/postfix/src/local/biff_notify.h index b2b8548f9..8b76f9dc6 100644 --- a/postfix/src/local/biff_notify.h +++ b/postfix/src/local/biff_notify.h @@ -14,7 +14,7 @@ /* * External interface. */ -extern void biff_notify(const char *, int); +extern void biff_notify(const char *, ssize_t); /* LICENSE /* .ad diff --git a/postfix/src/local/resolve.c b/postfix/src/local/resolve.c index 3f0a0f3b9..2a2f68337 100644 --- a/postfix/src/local/resolve.c +++ b/postfix/src/local/resolve.c @@ -88,7 +88,7 @@ int deliver_resolve_tree(LOCAL_STATE state, USER_ATTR usr_attr, TOK822 *addr char *myname = "deliver_resolve_tree"; RESOLVE_REPLY reply; int status; - int ext_len; + ssize_t ext_len; char *ratsign; /* diff --git a/postfix/src/master/mail_flow.c b/postfix/src/master/mail_flow.c index 383ba5816..b0cd7c102 100644 --- a/postfix/src/master/mail_flow.c +++ b/postfix/src/master/mail_flow.c @@ -6,13 +6,13 @@ /* SYNOPSIS /* #include /* -/* int mail_flow_get(count) -/* int count; +/* ssize_t mail_flow_get(count) +/* ssize_t count; /* -/* void mail_flow_put(count) -/* int count; +/* ssize_t mail_flow_put(count) +/* ssize_t count; /* -/* int mail_flow_count() +/* ssize_t mail_flow_count() /* DESCRIPTION /* This module implements a simple flow control mechanism that /* is based on tokens that are consumed by mail receiving processes @@ -66,19 +66,19 @@ /* mail_flow_get - read N tokens */ -int mail_flow_get(int len) +ssize_t mail_flow_get(ssize_t len) { char *myname = "mail_flow_get"; char buf[BUFFER_SIZE]; struct stat st; - int count; - int n = 0; + ssize_t count; + ssize_t n = 0; /* * Sanity check. */ if (len <= 0) - msg_panic("%s: bad length %d", myname, len); + msg_panic("%s: bad length %ld", myname, (long) len); /* * Silence some wild claims. @@ -95,24 +95,24 @@ int mail_flow_get(int len) BUFFER_SIZE : count)) <= 0) return (-1); if (msg_verbose) - msg_info("%s: %d %d", myname, len, len - count); + msg_info("%s: %ld %ld", myname, (long) len, (long) (len - count)); return (len - count); } /* mail_flow_put - put N tokens */ -int mail_flow_put(int len) +ssize_t mail_flow_put(ssize_t len) { char *myname = "mail_flow_put"; char buf[BUFFER_SIZE]; - int count; - int n = 0; + ssize_t count; + ssize_t n = 0; /* * Sanity check. */ if (len <= 0) - msg_panic("%s: bad length %d", myname, len); + msg_panic("%s: bad length %ld", myname, (long) len); /* * Write or discard N bytes. @@ -124,16 +124,16 @@ int mail_flow_put(int len) BUFFER_SIZE : count)) < 0) return (-1); if (msg_verbose) - msg_info("%s: %d %d", myname, len, len - count); + msg_info("%s: %ld %ld", myname, (long) len, (long) (len - count)); return (len - count); } /* mail_flow_count - return number of available tokens */ -int mail_flow_count(void) +ssize_t mail_flow_count(void) { char *myname = "mail_flow_count"; - int count; + ssize_t count; if ((count = peekfd(MASTER_FLOW_READ)) < 0) msg_warn("%s: %m", myname); diff --git a/postfix/src/master/mail_flow.h b/postfix/src/master/mail_flow.h index 9e058598f..3f7f7bd30 100644 --- a/postfix/src/master/mail_flow.h +++ b/postfix/src/master/mail_flow.h @@ -14,9 +14,9 @@ /* * Functional interface. */ -extern int mail_flow_get(int); -extern int mail_flow_put(int); -extern int mail_flow_count(void); +extern ssize_t mail_flow_get(ssize_t); +extern ssize_t mail_flow_put(ssize_t); +extern ssize_t mail_flow_count(void); /* LICENSE /* .ad diff --git a/postfix/src/oqmgr/qmgr_message.c b/postfix/src/oqmgr/qmgr_message.c index b13798fbc..6df215679 100644 --- a/postfix/src/oqmgr/qmgr_message.c +++ b/postfix/src/oqmgr/qmgr_message.c @@ -880,7 +880,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) char *at; char **cpp; char *nexthop; - int len; + ssize_t len; int status; DSN dsn; diff --git a/postfix/src/postqueue/postqueue.c b/postfix/src/postqueue/postqueue.c index dce53cfe3..76925d55e 100644 --- a/postfix/src/postqueue/postqueue.c +++ b/postfix/src/postqueue/postqueue.c @@ -381,7 +381,6 @@ int main(int argc, char **argv) int mode = PQ_MODE_DEFAULT; char *site_to_flush = 0; ARGV *import_env; - char *last; int bad_site; /* diff --git a/postfix/src/qmgr/qmgr_message.c b/postfix/src/qmgr/qmgr_message.c index e3ff32f0b..e1868d680 100644 --- a/postfix/src/qmgr/qmgr_message.c +++ b/postfix/src/qmgr/qmgr_message.c @@ -922,7 +922,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) char *at; char **cpp; char *nexthop; - int len; + ssize_t len; int status; DSN dsn; diff --git a/postfix/src/sendmail/sendmail.c b/postfix/src/sendmail/sendmail.c index ba4470351..955137de6 100644 --- a/postfix/src/sendmail/sendmail.c +++ b/postfix/src/sendmail/sendmail.c @@ -480,7 +480,7 @@ static CONFIG_STR_TABLE str_table[] = { /* output_text - output partial or complete text line */ -static void output_text(void *context, int rec_type, const char *buf, int len, +static void output_text(void *context, int rec_type, const char *buf, ssize_t len, off_t unused_offset) { SM_STATE *state = (SM_STATE *) context; @@ -505,7 +505,7 @@ static void output_header(void *context, int header_class, char *start; char *line; char *next_line; - int len; + ssize_t len; /* * Parse the header line, and save copies of recipient addresses in the diff --git a/postfix/src/smtp/smtp_chat.c b/postfix/src/smtp/smtp_chat.c index 7f27fc20f..4e9b6f3eb 100644 --- a/postfix/src/smtp/smtp_chat.c +++ b/postfix/src/smtp/smtp_chat.c @@ -306,11 +306,11 @@ SMTP_RESP *smtp_chat_resp(SMTP_SESSION *session) /* print_line - line_wrap callback */ -static void print_line(const char *str, int len, int indent, char *context) +static void print_line(const char *str, ssize_t len, ssize_t indent, char *context) { VSTREAM *notice = (VSTREAM *) context; - post_mail_fprintf(notice, " %*s%.*s", indent, "", len, str); + post_mail_fprintf(notice, " %*s%.*s", (int) indent, "", (int) len, str); } /* smtp_chat_notify - notify postmaster */ diff --git a/postfix/src/smtp/smtp_proto.c b/postfix/src/smtp/smtp_proto.c index 856c4c10c..b9da58558 100644 --- a/postfix/src/smtp/smtp_proto.c +++ b/postfix/src/smtp/smtp_proto.c @@ -647,12 +647,12 @@ static int smtp_start_tls(SMTP_STATE *state, int misc_flags) /* smtp_text_out - output one header/body record */ static void smtp_text_out(void *context, int rec_type, - const char *text, int len, + const char *text, ssize_t len, off_t unused_offset) { SMTP_STATE *state = (SMTP_STATE *) context; SMTP_SESSION *session = state->session; - int data_left; + ssize_t data_left; const char *data_start; /* diff --git a/postfix/src/smtp/smtp_unalias.c b/postfix/src/smtp/smtp_unalias.c index 395fd695f..4e9a81ace 100644 --- a/postfix/src/smtp/smtp_unalias.c +++ b/postfix/src/smtp/smtp_unalias.c @@ -136,6 +136,7 @@ int main(int unused_argc, char **unused_argv) } vstring_free(addr); vstring_free(result); + return (0); } #endif diff --git a/postfix/src/smtpd/smtpd.c b/postfix/src/smtpd/smtpd.c index 772509932..7be9340df 100644 --- a/postfix/src/smtpd/smtpd.c +++ b/postfix/src/smtpd/smtpd.c @@ -1759,6 +1759,7 @@ static int rcpt_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) char *arg; int rate; const char *dsn_orcpt_addr = 0; + ssize_t dsn_orcpt_addr_len = 0; const char *dsn_orcpt_type = 0; int dsn_notify = 0; const char *coded_addr; @@ -1846,6 +1847,7 @@ static int rcpt_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) return (-1); } dsn_orcpt_addr = STR(state->dsn_buf); + dsn_orcpt_addr_len = LEN(state->dsn_buf); } else { state->error_mask |= MAIL_ERROR_PROTOCOL; smtpd_chat_reply(state, "555 5.5.4 Unsupported option: %s", arg); @@ -1955,12 +1957,19 @@ static int rcpt_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv) if (dsn_orcpt_addr == 0) { dsn_orcpt_type = "rfc822"; dsn_orcpt_addr = argv[2].strval; + dsn_orcpt_addr_len = strlen(argv[2].strval); + if (dsn_orcpt_addr[0] == '<' + && dsn_orcpt_addr[dsn_orcpt_addr_len - 1] == '>') { + dsn_orcpt_addr += 1; + dsn_orcpt_addr_len -= 2; + } } if (dsn_notify) rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%d", MAIL_ATTR_DSN_NOTIFY, dsn_notify); - rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s;%s", - MAIL_ATTR_DSN_ORCPT, dsn_orcpt_type, dsn_orcpt_addr); + rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s;%.*s", + MAIL_ATTR_DSN_ORCPT, dsn_orcpt_type, + (int) dsn_orcpt_addr_len, dsn_orcpt_addr); rec_fputs(state->cleanup, REC_TYPE_RCPT, STR(state->addr_buf)); vstream_fflush(state->cleanup); } @@ -2025,7 +2034,7 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv) int first = 1; VSTRING *why = 0; int saved_err; - int (*out_record) (VSTREAM *, int, const char *, int); + int (*out_record) (VSTREAM *, int, const char *, ssize_t); int (*out_fprintf) (VSTREAM *, int, const char *,...); VSTREAM *out_stream; int out_error; @@ -2973,10 +2982,10 @@ static void smtpd_start_tls(SMTPD_STATE *state) * verification unless TLS is required. */ state->tls_context = - tls_server_start(smtpd_tls_ctx, state->client, - var_smtpd_starttls_tmout, - state->name, state->addr, &(state->tls_info), - (var_smtpd_tls_req_ccert && state->tls_enforce_tls)); + tls_server_start(smtpd_tls_ctx, state->client, + var_smtpd_starttls_tmout, + state->name, state->addr, &(state->tls_info), + (var_smtpd_tls_req_ccert && state->tls_enforce_tls)); /* * When the TLS handshake fails, the conversation is in an unknown state. @@ -3505,7 +3514,7 @@ static void post_jail_init(char *unused_name, char **unused_argv) * recipient checks, address mapping, header_body_checks?. */ smtpd_input_transp_mask = - input_transp_mask(VAR_INPUT_TRANSP, var_input_transp); + input_transp_mask(VAR_INPUT_TRANSP, var_input_transp); /* * Sanity checks. The queue_minfree value should be at least as large as diff --git a/postfix/src/smtpd/smtpd_chat.c b/postfix/src/smtpd/smtpd_chat.c index 2962b1efb..394e52b16 100644 --- a/postfix/src/smtpd/smtpd_chat.c +++ b/postfix/src/smtpd/smtpd_chat.c @@ -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, int len, int indent, char *context) +static void print_line(const char *str, ssize_t len, ssize_t indent, char *context) { VSTREAM *notice = (VSTREAM *) context; - post_mail_fprintf(notice, " %*s%.*s", indent, "", len, str); + post_mail_fprintf(notice, " %*s%.*s", (int) indent, "", (int) len, str); } /* smtpd_chat_notify - notify postmaster */ diff --git a/postfix/src/smtpd/smtpd_check.c b/postfix/src/smtpd/smtpd_check.c index 9389da190..a56c4cb76 100644 --- a/postfix/src/smtpd/smtpd_check.c +++ b/postfix/src/smtpd/smtpd_check.c @@ -965,7 +965,7 @@ static int permit_mynetworks(SMTPD_STATE *state) static char *dup_if_truncate(char *name) { - int len; + ssize_t len; char *result; /* @@ -990,7 +990,7 @@ static int reject_invalid_hostaddr(SMTPD_STATE *state, char *addr, char *reply_name, char *reply_class) { char *myname = "reject_invalid_hostaddr"; - int len; + ssize_t len; char *test_addr; int stat; @@ -2337,7 +2337,7 @@ static int check_server_access(SMTPD_STATE *state, const char *table, if (*domain == '[') { char *saved_addr; const char *bare_addr; - int len; + ssize_t len; if (type != T_MX) return (SMTPD_CHECK_DUNNO); diff --git a/postfix/src/smtpd/smtpd_proxy.c b/postfix/src/smtpd/smtpd_proxy.c index b5ff2df22..35ebcf61f 100644 --- a/postfix/src/smtpd/smtpd_proxy.c +++ b/postfix/src/smtpd/smtpd_proxy.c @@ -35,7 +35,7 @@ /* VSTREAM *stream; /* int rec_type; /* const char *data; -/* int len; +/* ssize_t len; /* /* int smtpd_proxy_rec_fprintf(stream, rec_type, format, ...) /* VSTREAM *stream; @@ -538,7 +538,7 @@ int smtpd_proxy_cmd(SMTPD_STATE *state, int expect, const char *fmt,...) /* smtpd_proxy_rec_put - send message content, rec_put() clone */ int smtpd_proxy_rec_put(VSTREAM *stream, int rec_type, - const char *data, int len) + const char *data, ssize_t len) { int err; diff --git a/postfix/src/smtpd/smtpd_proxy.h b/postfix/src/smtpd/smtpd_proxy.h index e91543117..11f59ff97 100644 --- a/postfix/src/smtpd/smtpd_proxy.h +++ b/postfix/src/smtpd/smtpd_proxy.h @@ -25,7 +25,7 @@ extern int smtpd_proxy_open(SMTPD_STATE *, const char *, int, const char *, const char *); extern int PRINTFLIKE(3, 4) smtpd_proxy_cmd(SMTPD_STATE *, int, const char *,...); -extern int smtpd_proxy_rec_put(VSTREAM *, int, const char *, int); +extern int smtpd_proxy_rec_put(VSTREAM *, int, const char *, ssize_t); extern int PRINTFLIKE(3, 4) smtpd_proxy_rec_fprintf(VSTREAM *, int, const char *,...); extern void smtpd_proxy_close(SMTPD_STATE *); diff --git a/postfix/src/smtpstone/qmqp-source.c b/postfix/src/smtpstone/qmqp-source.c index 367de51bd..ec0c457d6 100644 --- a/postfix/src/smtpstone/qmqp-source.c +++ b/postfix/src/smtpstone/qmqp-source.c @@ -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), - 0); + (ssize_t) 0); netstring_fflush(session->stream); /* @@ -442,6 +442,7 @@ int main(int argc, char **argv) int path_len; int sessions = 1; int ch; + ssize_t len; int n; int i; char *buf; @@ -587,14 +588,14 @@ int main(int argc, char **argv) STR(buffer)[message_length - 1] = '\n'; netstring_memcpy(message_buffer, STR(buffer), message_length); - n = strlen(sender); - sender_buffer = vstring_alloc(n); - netstring_memcpy(sender_buffer, sender, n); + len = strlen(sender); + sender_buffer = vstring_alloc(len); + netstring_memcpy(sender_buffer, sender, len); if (recipients == 1) { - n = strlen(recipient); - recipient_buffer = vstring_alloc(n); - netstring_memcpy(recipient_buffer, recipient, n); + len = strlen(recipient); + recipient_buffer = vstring_alloc(len); + netstring_memcpy(recipient_buffer, recipient, len); } else { recipient_buffer = vstring_alloc(100); for (n = 0; n < recipients; n++) { diff --git a/postfix/src/smtpstone/smtp-source.c b/postfix/src/smtpstone/smtp-source.c index 99f389e34..ed796a74a 100644 --- a/postfix/src/smtpstone/smtp-source.c +++ b/postfix/src/smtpstone/smtp-source.c @@ -277,7 +277,7 @@ static RESPONSE *response(VSTREAM *stream, VSTRING *buf) */ if (rdata.buf == 0) { rdata.buf = vstring_alloc(100); - vstring_ctl(rdata.buf, VSTRING_CTL_MAXLEN, var_line_limit, 0); + vstring_ctl(rdata.buf, VSTRING_CTL_MAXLEN, (ssize_t) var_line_limit, 0); } /* @@ -938,7 +938,7 @@ int main(int argc, char **argv) */ if (buffer == 0) { buffer = vstring_alloc(100); - vstring_ctl(buffer, VSTRING_CTL_MAXLEN, var_line_limit, 0); + vstring_ctl(buffer, VSTRING_CTL_MAXLEN, (ssize_t) var_line_limit, 0); } /* diff --git a/postfix/src/tls/tls_dh.c b/postfix/src/tls/tls_dh.c index 575233303..a4e99268c 100644 --- a/postfix/src/tls/tls_dh.c +++ b/postfix/src/tls/tls_dh.c @@ -226,6 +226,7 @@ int main(int unused_argc, char **unused_argv) tls_tmp_dh_cb(0, 1, 1024); tls_tmp_dh_cb(0, 1, 2048); tls_tmp_dh_cb(0, 0, 512); + return (0); } #endif diff --git a/postfix/src/tls/tls_mgr.c b/postfix/src/tls/tls_mgr.c index 61f45f820..22b9acdba 100644 --- a/postfix/src/tls/tls_mgr.c +++ b/postfix/src/tls/tls_mgr.c @@ -17,7 +17,7 @@ /* int cache_type; /* const char *cache_id; /* const char *buf; -/* int len; +/* ssize_t len; /* /* int tls_mgr_lookup(cache_type, cache_id, buf) /* int cache_type; @@ -229,7 +229,7 @@ int tls_mgr_lookup(int cache_type, const char *cache_id, VSTRING *buf) /* tls_mgr_update - save session to cache */ int tls_mgr_update(int cache_type, const char *cache_id, - const char *buf, int len) + const char *buf, ssize_t len) { int status; @@ -377,6 +377,7 @@ int main(int unused_ac, char **av) argv_free(argv); vstring_free(inbuf); + return (0); } #endif /* TEST */ diff --git a/postfix/src/tls/tls_mgr.h b/postfix/src/tls/tls_mgr.h index 92aa5f50d..068002c3a 100644 --- a/postfix/src/tls/tls_mgr.h +++ b/postfix/src/tls/tls_mgr.h @@ -50,7 +50,7 @@ extern int tls_mgr_seed(VSTRING *, int); extern int tls_mgr_policy(int *); extern int tls_mgr_lookup(int, const char *, VSTRING *); -extern int tls_mgr_update(int, const char *, const char *, int); +extern int tls_mgr_update(int, const char *, const char *, ssize_t); extern int tls_mgr_delete(int, const char *); /* LICENSE diff --git a/postfix/src/tls/tls_prng_file.c b/postfix/src/tls/tls_prng_file.c index 83754e4b7..3c3c0ecdf 100644 --- a/postfix/src/tls/tls_prng_file.c +++ b/postfix/src/tls/tls_prng_file.c @@ -107,8 +107,8 @@ ssize_t tls_prng_file_read(TLS_PRNG_SRC *fh, size_t len) { const char *myname = "tls_prng_file_read"; char buffer[8192]; - int to_read; - int count; + ssize_t to_read; + ssize_t count; if (msg_verbose) msg_info("%s: seed internal pool from file %s", myname, fh->name); diff --git a/postfix/src/tls/tls_scache.c b/postfix/src/tls/tls_scache.c index e9e172497..d141967ee 100644 --- a/postfix/src/tls/tls_scache.c +++ b/postfix/src/tls/tls_scache.c @@ -160,11 +160,11 @@ typedef struct { static VSTRING *tls_scache_encode(TLS_SCACHE *cp, const char *cache_id, const char *session, - int session_len) + ssize_t session_len) { TLS_SCACHE_ENTRY *entry; VSTRING *hex_data; - int binary_data_len; + ssize_t binary_data_len; /* * Assemble the TLS session cache entry. @@ -187,9 +187,9 @@ static VSTRING *tls_scache_encode(TLS_SCACHE *cp, const char *cache_id, * Logging. */ if (cp->log_level >= 3) - msg_info("write %s TLS cache entry %s: time=%ld [data %d bytes]", + msg_info("write %s TLS cache entry %s: time=%ld [data %ld bytes]", cp->cache_label, cache_id, (long) entry->timestamp, - session_len); + (long) session_len); /* * Clean up. @@ -202,7 +202,7 @@ static VSTRING *tls_scache_encode(TLS_SCACHE *cp, const char *cache_id, /* tls_scache_decode - decode TLS session cache entry */ static int tls_scache_decode(TLS_SCACHE *cp, const char *cache_id, - const char *hex_data, int hex_data_len, + const char *hex_data, ssize_t hex_data_len, VSTRING *out_session) { TLS_SCACHE_ENTRY *entry; @@ -236,9 +236,9 @@ static int tls_scache_decode(TLS_SCACHE *cp, const char *cache_id, * Logging. */ if (cp->log_level >= 3) - msg_info("read %s TLS cache entry %s: time=%ld [data %d bytes]", + msg_info("read %s TLS cache entry %s: time=%ld [data %ld bytes]", cp->cache_label, cache_id, (long) entry->timestamp, - LEN(bin_data) - offsetof(TLS_SCACHE_ENTRY, session)); + (long) (LEN(bin_data) - offsetof(TLS_SCACHE_ENTRY, session))); /* * Other mandatory restrictions. @@ -299,7 +299,7 @@ int tls_scache_lookup(TLS_SCACHE *cp, const char *cache_id, /* tls_scache_update - save session to cache */ int tls_scache_update(TLS_SCACHE *cp, const char *cache_id, - const char *buf, int len) + const char *buf, ssize_t len) { VSTRING *hex_data; @@ -307,8 +307,8 @@ int tls_scache_update(TLS_SCACHE *cp, const char *cache_id, * Logging. */ if (cp->log_level >= 3) - msg_info("put %s session id=%s [data %d bytes]", - cp->cache_label, cache_id, len); + msg_info("put %s session id=%s [data %ld bytes]", + cp->cache_label, cache_id, (long) len); /* * Encode the cache entry. diff --git a/postfix/src/tls/tls_scache.h b/postfix/src/tls/tls_scache.h index dd545d656..0eb88ab0b 100644 --- a/postfix/src/tls/tls_scache.h +++ b/postfix/src/tls/tls_scache.h @@ -34,7 +34,7 @@ typedef struct { extern TLS_SCACHE *tls_scache_open(const char *, const char *, int, int); extern void tls_scache_close(TLS_SCACHE *); extern int tls_scache_lookup(TLS_SCACHE *, const char *, VSTRING *); -extern int tls_scache_update(TLS_SCACHE *, const char *, const char *, int); +extern int tls_scache_update(TLS_SCACHE *, const char *, const char *, ssize_t); extern int tls_scache_delete(TLS_SCACHE *, const char *); extern int tls_scache_sequence(TLS_SCACHE *, int, char **, VSTRING *); diff --git a/postfix/src/tls/tls_server.c b/postfix/src/tls/tls_server.c index 488d116b8..2df0edcb1 100644 --- a/postfix/src/tls/tls_server.c +++ b/postfix/src/tls/tls_server.c @@ -592,7 +592,7 @@ TLScontext_t *tls_server_start(SSL_CTX *server_ctx, VSTREAM *stream, if (X509_digest(peer, EVP_md5(), TLScontext->md, &n)) { for (j = 0; j < (int) n; j++) { TLScontext->fingerprint[j * 3] = - hexcodes[(TLScontext->md[j] & 0xf0) >> 4]; + hexcodes[(TLScontext->md[j] & 0xf0) >> 4U]; TLScontext->fingerprint[(j * 3) + 1] = hexcodes[(TLScontext->md[j] & 0x0f)]; if (j + 1 != (int) n) diff --git a/postfix/src/tls/tls_stream.c b/postfix/src/tls/tls_stream.c index 5a013f356..212edb56b 100644 --- a/postfix/src/tls/tls_stream.c +++ b/postfix/src/tls/tls_stream.c @@ -67,11 +67,11 @@ /* tls_timed_read - read content from stream, then TLS decapsulate */ -static int tls_timed_read(int fd, void *buf, unsigned len, int timeout, - void *context) +static ssize_t tls_timed_read(int fd, void *buf, size_t len, int timeout, + void *context) { char *myname = "tls_timed_read"; - int ret; + ssize_t ret; TLScontext_t *TLScontext; TLScontext = (TLScontext_t *) context; @@ -80,15 +80,15 @@ static int tls_timed_read(int fd, void *buf, unsigned len, int timeout, ret = tls_bio_read(fd, buf, len, timeout, TLScontext); if (ret > 0 && TLScontext->log_level >= 4) - msg_info("Read %d chars: %.*s", - ret, ret > 40 ? 40 : ret, (char *) buf); + msg_info("Read %ld chars: %.*s", + (long) ret, (int) (ret > 40 ? 40 : ret), (char *) buf); return (ret); } /* tls_timed_write - TLS encapsulate content, then write to stream */ -static int tls_timed_write(int fd, void *buf, unsigned len, int timeout, - void *context) +static ssize_t tls_timed_write(int fd, void *buf, size_t len, int timeout, + void *context) { const char *myname = "tls_timed_write"; TLScontext_t *TLScontext; @@ -98,14 +98,14 @@ static int tls_timed_write(int fd, void *buf, unsigned len, int timeout, msg_panic("%s: no context", myname); if (TLScontext->log_level >= 4) - msg_info("Write %d chars: %.*s", - len, (int) (len > 40 ? 40 : len), (char *) buf); + msg_info("Write %ld chars: %.*s", + (long) len, (int) (len > 40 ? 40 : len), (char *) buf); return (tls_bio_write(fd, buf, len, timeout, TLScontext)); } /* tls_stream_start - start VSTREAM over TLS */ -void tls_stream_start(VSTREAM *stream, TLScontext_t * context) +void tls_stream_start(VSTREAM *stream, TLScontext_t *context) { vstream_control(stream, VSTREAM_CTL_READ_FN, tls_timed_read, diff --git a/postfix/src/trivial-rewrite/resolve.c b/postfix/src/trivial-rewrite/resolve.c index ed5af4b2c..f12583884 100644 --- a/postfix/src/trivial-rewrite/resolve.c +++ b/postfix/src/trivial-rewrite/resolve.c @@ -146,7 +146,7 @@ static void resolve_addr(RES_CONTEXT *rp, char *addr, char *destination; const char *blame = 0; const char *rcpt_domain; - int addr_len; + ssize_t addr_len; int loop_count; int loop_max; char *local; diff --git a/postfix/src/trivial-rewrite/trivial-rewrite.c b/postfix/src/trivial-rewrite/trivial-rewrite.c index 6bb9f0238..94b2754b2 100644 --- a/postfix/src/trivial-rewrite/trivial-rewrite.c +++ b/postfix/src/trivial-rewrite/trivial-rewrite.c @@ -109,8 +109,8 @@ /* Available in Postfix 2.2 and later: /* .IP "\fBremote_header_rewrite_domain (empty)\fR" /* Don't rewrite message headers from remote clients at all when -/* this parameter is empty; otherwise, rewrite remote message headers -/* and append the specified domain name to incomplete addresses. +/* this parameter is empty; otherwise, rewrite message headers and +/* append the specified domain name to incomplete addresses. /* ROUTING CONTROLS /* .ad /* .fi diff --git a/postfix/src/util/argv.c b/postfix/src/util/argv.c index 33f1843d1..5ed42a4d8 100644 --- a/postfix/src/util/argv.c +++ b/postfix/src/util/argv.c @@ -7,7 +7,7 @@ /* #include /* /* ARGV *argv_alloc(len) -/* int len; +/* ssize_t len; /* /* ARGV *argv_free(argvp) /* ARGV *argvp; @@ -19,14 +19,14 @@ /* void argv_addn(argvp, arg, arg_len, ..., ARGV_END) /* ARGV *argvp; /* char *arg; -/* int arg_len; +/* ssize_t arg_len; /* /* void argv_terminate(argvp); /* ARGV *argvp; /* /* void argv_truncate(argvp, len); /* ARGV *argvp; -/* int len; +/* ssize_t len; /* DESCRIPTION /* The functions in this module manipulate arrays of string /* pointers. An ARGV structure contains the following members: @@ -100,10 +100,10 @@ ARGV *argv_free(ARGV *argvp) /* argv_alloc - initialize string array */ -ARGV *argv_alloc(int len) +ARGV *argv_alloc(ssize_t len) { ARGV *argvp; - int sane_len; + ssize_t sane_len; /* * Make sure that always argvp->argc < argvp->len. @@ -122,7 +122,7 @@ ARGV *argv_alloc(int len) static void argv_extend(ARGV *argvp) { - int new_len; + ssize_t new_len; new_len = argvp->len * 2; argvp->argv = (char **) @@ -157,7 +157,7 @@ void argv_add(ARGV *argvp,...) void argv_addn(ARGV *argvp,...) { char *arg; - int len; + ssize_t len; va_list ap; /* @@ -165,8 +165,8 @@ void argv_addn(ARGV *argvp,...) */ va_start(ap, argvp); while ((arg = va_arg(ap, char *)) != 0) { - if ((len = va_arg(ap, int)) < 0) - msg_panic("argv_addn: bad string length %d", len); + if ((len = va_arg(ap, ssize_t)) < 0) + msg_panic("argv_addn: bad string length %ld", (long) len); if (ARGV_SPACE_LEFT(argvp) <= 0) argv_extend(argvp); argvp->argv[argvp->argc++] = mystrndup(arg, len); @@ -188,7 +188,7 @@ void argv_terminate(ARGV *argvp) /* argv_truncate - truncate string array */ -void argv_truncate(ARGV *argvp, int len) +void argv_truncate(ARGV *argvp, ssize_t len) { char **cpp; @@ -196,7 +196,7 @@ void argv_truncate(ARGV *argvp, int len) * Sanity check. */ if (len < 0) - msg_panic("argv_truncate: bad length %d", len); + msg_panic("argv_truncate: bad length %ld", (long) len); if (len < argvp->argc) { for (cpp = argvp->argv + len; cpp < argvp->argv + argvp->argc; cpp++) diff --git a/postfix/src/util/argv.h b/postfix/src/util/argv.h index 9c0e75851..f369c084d 100644 --- a/postfix/src/util/argv.h +++ b/postfix/src/util/argv.h @@ -15,16 +15,16 @@ * External interface. */ typedef struct ARGV { - int len; /* number of array elements */ - int argc; /* array elements in use */ + ssize_t len; /* number of array elements */ + ssize_t argc; /* array elements in use */ char **argv; /* string array */ } ARGV; -extern ARGV *argv_alloc(int); +extern ARGV *argv_alloc(ssize_t); extern void argv_add(ARGV *,...); extern void argv_addn(ARGV *,...); extern void argv_terminate(ARGV *); -extern void argv_truncate(ARGV *, int); +extern void argv_truncate(ARGV *, ssize_t); extern ARGV *argv_free(ARGV *); extern ARGV *argv_split(const char *, const char *); diff --git a/postfix/src/util/attr_clnt.c b/postfix/src/util/attr_clnt.c index 505b13a52..130615b9b 100644 --- a/postfix/src/util/attr_clnt.c +++ b/postfix/src/util/attr_clnt.c @@ -223,7 +223,7 @@ int attr_clnt_request(ATTR_CLNT *client, int send_flags,...) SKIP_ARG(ap, char *); break; case ATTR_TYPE_DATA: - SKIP_ARG2(ap, char *, int); + SKIP_ARG2(ap, ssize_t, char *); break; case ATTR_TYPE_NUM: SKIP_ARG(ap, int); diff --git a/postfix/src/util/attr_print0.c b/postfix/src/util/attr_print0.c index 26a6a394f..04222e459 100644 --- a/postfix/src/util/attr_print0.c +++ b/postfix/src/util/attr_print0.c @@ -51,7 +51,7 @@ /* .IP "ATTR_TYPE_STR (char *, char *)" /* This argument is followed by an attribute name and a null-terminated /* string. -/* .IP "ATTR_TYPE_DATA (char *, int, char *)" +/* .IP "ATTR_TYPE_DATA (char *, ssize_t, char *)" /* This argument is followed by an attribute name, an attribute value /* length, and an attribute value pointer. /* .IP "ATTR_TYPE_FUNC (ATTR_PRINT_SLAVE_FN, void *)" @@ -113,7 +113,7 @@ int attr_vprint0(VSTREAM *fp, int flags, va_list ap) char *str_val; HTABLE_INFO **ht_info_list; HTABLE_INFO **ht; - int len_val; + ssize_t len_val; static VSTRING *base64_buf; ATTR_PRINT_SLAVE_FN print_fn; void *print_arg; @@ -159,14 +159,15 @@ int attr_vprint0(VSTREAM *fp, int flags, va_list ap) case ATTR_TYPE_DATA: attr_name = va_arg(ap, char *); vstream_fwrite(fp, attr_name, strlen(attr_name) + 1); - len_val = va_arg(ap, int); + len_val = va_arg(ap, ssize_t); str_val = va_arg(ap, char *); if (base64_buf == 0) base64_buf = vstring_alloc(10); base64_encode(base64_buf, str_val, len_val); vstream_fwrite(fp, STR(base64_buf), LEN(base64_buf) + 1); if (msg_verbose) - msg_info("send attr %s = [data %d bytes]", attr_name, len_val); + msg_info("send attr %s = [data %ld bytes]", + attr_name, (long) len_val); break; case ATTR_TYPE_FUNC: print_fn = va_arg(ap, ATTR_PRINT_SLAVE_FN); diff --git a/postfix/src/util/attr_print64.c b/postfix/src/util/attr_print64.c index 4d4704310..46aaa7631 100644 --- a/postfix/src/util/attr_print64.c +++ b/postfix/src/util/attr_print64.c @@ -51,6 +51,9 @@ /* .IP "ATTR_TYPE_STR (char *, char *)" /* This argument is followed by an attribute name and a null-terminated /* string. +/* .IP "ATTR_TYPE_DATA (char *, ssize_t, char *)" +/* This argument is followed by an attribute name, an attribute value +/* length, and an attribute value pointer. /* .IP "ATTR_TYPE_FUNC (ATTR_PRINT_SLAVE_FN, void *)" /* This argument is followed by a function pointer and generic data /* pointer. The caller-specified function returns whatever the @@ -100,7 +103,7 @@ /* attr_print64_str - encode and send attribute information */ -static void attr_print64_str(VSTREAM *fp, const char *str, int len) +static void attr_print64_str(VSTREAM *fp, const char *str, ssize_t len) { static VSTRING *base64_buf; @@ -145,7 +148,7 @@ int attr_vprint64(VSTREAM *fp, int flags, va_list ap) char *str_val; HTABLE_INFO **ht_info_list; HTABLE_INFO **ht; - int len_val; + ssize_t len_val; ATTR_PRINT_SLAVE_FN print_fn; void *print_arg; @@ -194,13 +197,14 @@ int attr_vprint64(VSTREAM *fp, int flags, va_list ap) case ATTR_TYPE_DATA: attr_name = va_arg(ap, char *); attr_print64_str(fp, attr_name, strlen(attr_name)); - len_val = va_arg(ap, int); + len_val = va_arg(ap, ssize_t); str_val = va_arg(ap, char *); VSTREAM_PUTC(':', fp); attr_print64_str(fp, str_val, len_val); VSTREAM_PUTC('\n', fp); if (msg_verbose) - msg_info("send attr %s = [data %d bytes]", attr_name, len_val); + msg_info("send attr %s = [data %ld bytes]", + attr_name, (long) len_val); break; case ATTR_TYPE_FUNC: print_fn = va_arg(ap, ATTR_PRINT_SLAVE_FN); @@ -260,14 +264,14 @@ int main(int unused_argc, char **argv) ATTR_TYPE_NUM, ATTR_NAME_NUM, 4711, ATTR_TYPE_LONG, ATTR_NAME_LONG, 1234, ATTR_TYPE_STR, ATTR_NAME_STR, "whoopee", - ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", + ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", ATTR_TYPE_HASH, table, ATTR_TYPE_END); attr_print64(VSTREAM_OUT, ATTR_FLAG_NONE, ATTR_TYPE_NUM, ATTR_NAME_NUM, 4711, ATTR_TYPE_LONG, ATTR_NAME_LONG, 1234, ATTR_TYPE_STR, ATTR_NAME_STR, "whoopee", - ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", + ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", ATTR_TYPE_END); if (vstream_fflush(VSTREAM_OUT) != 0) msg_fatal("write error: %m"); diff --git a/postfix/src/util/attr_print_plain.c b/postfix/src/util/attr_print_plain.c index 5fb6b6684..aea66b5c4 100644 --- a/postfix/src/util/attr_print_plain.c +++ b/postfix/src/util/attr_print_plain.c @@ -51,7 +51,7 @@ /* .IP "ATTR_TYPE_STR (char *, char *)" /* This argument is followed by an attribute name and a null-terminated /* string. -/* .IP "ATTR_TYPE_DATA (char *, int, char *)" +/* .IP "ATTR_TYPE_DATA (char *, ssize_t, char *)" /* This argument is followed by an attribute name, an attribute value /* length, and a pointer to attribute value. /* .IP "ATTR_TYPE_FUNC (ATTR_PRINT_SLAVE_FN, void *)" @@ -115,7 +115,7 @@ int attr_vprint_plain(VSTREAM *fp, int flags, va_list ap) HTABLE_INFO **ht_info_list; HTABLE_INFO **ht; static VSTRING *base64_buf; - int len_val; + ssize_t len_val; ATTR_PRINT_SLAVE_FN print_fn; void *print_arg; @@ -154,14 +154,15 @@ int attr_vprint_plain(VSTREAM *fp, int flags, va_list ap) break; case ATTR_TYPE_DATA: attr_name = va_arg(ap, char *); - len_val = va_arg(ap, int); + len_val = va_arg(ap, ssize_t); str_val = va_arg(ap, char *); if (base64_buf == 0) base64_buf = vstring_alloc(10); base64_encode(base64_buf, str_val, len_val); vstream_fprintf(fp, "%s=%s\n", attr_name, STR(base64_buf)); if (msg_verbose) - msg_info("send attr %s = [data %d bytes]", attr_name, len_val); + msg_info("send attr %s = [data %ld bytes]", + attr_name, (long) len_val); break; case ATTR_TYPE_FUNC: print_fn = va_arg(ap, ATTR_PRINT_SLAVE_FN); @@ -218,14 +219,14 @@ int main(int unused_argc, char **argv) ATTR_TYPE_NUM, ATTR_NAME_NUM, 4711, ATTR_TYPE_LONG, ATTR_NAME_LONG, 1234, ATTR_TYPE_STR, ATTR_NAME_STR, "whoopee", - ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", + ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", ATTR_TYPE_HASH, table, ATTR_TYPE_END); attr_print_plain(VSTREAM_OUT, ATTR_FLAG_NONE, ATTR_TYPE_NUM, ATTR_NAME_NUM, 4711, ATTR_TYPE_LONG, ATTR_NAME_LONG, 1234, ATTR_TYPE_STR, ATTR_NAME_STR, "whoopee", - ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", + ATTR_TYPE_DATA, ATTR_NAME_DATA, strlen("whoopee"), "whoopee", ATTR_TYPE_END); if (vstream_fflush(VSTREAM_OUT) != 0) msg_fatal("write error: %m"); diff --git a/postfix/src/util/attr_scan0.c b/postfix/src/util/attr_scan0.c index 27f60a685..db1f1fa00 100644 --- a/postfix/src/util/attr_scan0.c +++ b/postfix/src/util/attr_scan0.c @@ -297,7 +297,7 @@ int attr_vscan0(VSTREAM *fp, int flags, va_list ap) } else if (wanted_type == ATTR_TYPE_HASH) { wanted_name = "(any attribute name or list terminator)"; hash_table = va_arg(ap, HTABLE *); - if (va_arg(ap, int) !=ATTR_TYPE_END) + if (va_arg(ap, int) != ATTR_TYPE_END) msg_panic("%s: ATTR_TYPE_HASH not followed by ATTR_TYPE_END", myname); } else if (wanted_type != ATTR_TYPE_FUNC) { diff --git a/postfix/src/util/attr_scan64.c b/postfix/src/util/attr_scan64.c index 8cf480812..2d5b6936f 100644 --- a/postfix/src/util/attr_scan64.c +++ b/postfix/src/util/attr_scan64.c @@ -300,7 +300,7 @@ int attr_vscan64(VSTREAM *fp, int flags, va_list ap) } else if (wanted_type == ATTR_TYPE_HASH) { wanted_name = "(any attribute name or list terminator)"; hash_table = va_arg(ap, HTABLE *); - if (va_arg(ap, int) !=ATTR_TYPE_END) + if (va_arg(ap, int) != ATTR_TYPE_END) msg_panic("%s: ATTR_TYPE_HASH not followed by ATTR_TYPE_END", myname); } else if (wanted_type != ATTR_TYPE_FUNC) { diff --git a/postfix/src/util/attr_scan_plain.c b/postfix/src/util/attr_scan_plain.c index 79c119cf5..70f216e6a 100644 --- a/postfix/src/util/attr_scan_plain.c +++ b/postfix/src/util/attr_scan_plain.c @@ -313,7 +313,7 @@ int attr_vscan_plain(VSTREAM *fp, int flags, va_list ap) } else if (wanted_type == ATTR_TYPE_HASH) { wanted_name = "(any attribute name or list terminator)"; hash_table = va_arg(ap, HTABLE *); - if (va_arg(ap, int) !=ATTR_TYPE_END) + if (va_arg(ap, int) != ATTR_TYPE_END) msg_panic("%s: ATTR_TYPE_HASH not followed by ATTR_TYPE_END", myname); } else if (wanted_type != ATTR_TYPE_FUNC) { diff --git a/postfix/src/util/base64_code.c b/postfix/src/util/base64_code.c index 22573c4f0..fa9355528 100644 --- a/postfix/src/util/base64_code.c +++ b/postfix/src/util/base64_code.c @@ -9,12 +9,12 @@ /* VSTRING *base64_encode(result, in, len) /* VSTRING *result; /* const char *in; -/* int len; +/* ssize_t len; /* /* VSTRING *base64_decode(result, in, len) /* VSTRING *result; /* const char *in; -/* int len; +/* ssize_t len; /* DESCRIPTION /* base64_encode() takes a block of len bytes and encodes it as one /* null-terminated string. The result value is the result argument. @@ -63,10 +63,10 @@ static unsigned char to_b64[] = /* base64_encode - raw data to encoded */ -VSTRING *base64_encode(VSTRING *result, const char *in, int len) +VSTRING *base64_encode(VSTRING *result, const char *in, ssize_t len) { const unsigned char *cp; - int count; + ssize_t count; /* * Encode 3 -> 4. @@ -97,11 +97,11 @@ VSTRING *base64_encode(VSTRING *result, const char *in, int len) /* base64_decode - encoded data to raw */ -VSTRING *base64_decode(VSTRING *result, const char *in, int len) +VSTRING *base64_decode(VSTRING *result, const char *in, ssize_t len) { static unsigned char *un_b64 = 0; const unsigned char *cp; - int count; + ssize_t count; unsigned int ch0; unsigned int ch1; unsigned int ch2; diff --git a/postfix/src/util/base64_code.h b/postfix/src/util/base64_code.h index d018947e1..e2f938ac4 100644 --- a/postfix/src/util/base64_code.h +++ b/postfix/src/util/base64_code.h @@ -19,8 +19,8 @@ /* * External interface. */ -extern VSTRING *base64_encode(VSTRING *, const char *, int); -extern VSTRING *base64_decode(VSTRING *, const char *, int); +extern VSTRING *base64_encode(VSTRING *, const char *, ssize_t); +extern VSTRING *base64_decode(VSTRING *, const char *, ssize_t); /* LICENSE /* .ad diff --git a/postfix/src/util/binhash.c b/postfix/src/util/binhash.c index 8e9a8e608..b877f77ee 100644 --- a/postfix/src/util/binhash.c +++ b/postfix/src/util/binhash.c @@ -134,9 +134,9 @@ static unsigned binhash_hash(const char *key, int len, unsigned size) */ while (len-- > 0) { - h = (h << 4) + *key++; + h = (h << 4U) + *key++; if ((g = (h & 0xf0000000)) != 0) { - h ^= (g >> 24); + h ^= (g >> 24U); h ^= g; } } diff --git a/postfix/src/util/clean_env.c b/postfix/src/util/clean_env.c index 14023dfe2..ec337cdf0 100644 --- a/postfix/src/util/clean_env.c +++ b/postfix/src/util/clean_env.c @@ -56,7 +56,7 @@ void clean_env(char **preserve_list) /* * Preserve or specify selected environment variables. */ -#define STRING_AND_LENGTH(x, y) (x), (y) +#define STRING_AND_LENGTH(x, y) (x), (ssize_t) (y) save_list = argv_alloc(10); for (cpp = preserve_list; *cpp; cpp++) diff --git a/postfix/src/util/concatenate.c b/postfix/src/util/concatenate.c index cf0d45d1b..1f9716074 100644 --- a/postfix/src/util/concatenate.c +++ b/postfix/src/util/concatenate.c @@ -42,7 +42,7 @@ char *concatenate(const char *arg0,...) { char *result; va_list ap; - int len; + ssize_t len; char *arg; /* diff --git a/postfix/src/util/dict_cdb.c b/postfix/src/util/dict_cdb.c index 1c596ffea..6d8d11c8d 100644 --- a/postfix/src/util/dict_cdb.c +++ b/postfix/src/util/dict_cdb.c @@ -194,8 +194,8 @@ static DICT *dict_cdbq_open(const char *path, int dict_flags) * the source file changed only seconds ago. */ if (stat(path, &st) == 0 - && st.st_mtime > dict_cdbq->dict.mtime - && st.st_mtime < time((time_t *)0) - 100) + && st.st_mtime > dict_cdbq->dict.mtime + && st.st_mtime < time((time_t *) 0) - 100) msg_warn("database %s is older than source file %s", cdb_path, path); /* @@ -215,8 +215,7 @@ static DICT *dict_cdbq_open(const char *path, int dict_flags) static void dict_cdbm_update(DICT *dict, const char *name, const char *value) { DICT_CDBM *dict_cdbm = (DICT_CDBM *) dict; - unsigned ksize, - vsize; + unsigned ksize, vsize; int r; ksize = strlen(name); @@ -294,8 +293,7 @@ static DICT *dict_cdbm_open(const char *path, int dict_flags) char *cdb_path; char *tmp_path; int fd; - struct stat st0, - st1; + struct stat st0, st1; cdb_path = concatenate(path, CDB_SUFFIX, (char *) 0); tmp_path = concatenate(path, CDB_TMP_SUFFIX, (char *) 0); @@ -369,7 +367,7 @@ static DICT *dict_cdbm_open(const char *path, int dict_flags) DICT *dict_cdb_open(const char *path, int open_flags, int dict_flags) { switch (open_flags & (O_RDONLY | O_RDWR | O_WRONLY | O_CREAT | O_TRUNC)) { - case O_RDONLY: /* query mode */ + case O_RDONLY: /* query mode */ return dict_cdbq_open(path, dict_flags); case O_WRONLY | O_CREAT | O_TRUNC: /* create mode */ case O_RDWR | O_CREAT | O_TRUNC: /* sloppiness */ diff --git a/postfix/src/util/dict_ni.c b/postfix/src/util/dict_ni.c index dafb687df..c6497f888 100644 --- a/postfix/src/util/dict_ni.c +++ b/postfix/src/util/dict_ni.c @@ -102,9 +102,7 @@ static const char *dict_ni_do_lookup(char *path, char *key_prop, if (values.ni_namelist_len <= 0) ni_namelist_free(&values); else { - unsigned int i, - l, - n; + unsigned int i, l, n; for (i = l = 0; i < values.ni_namelist_len; i++) l += 1 + strlen(values.ni_namelist_val[i]); @@ -174,7 +172,7 @@ DICT *dict_ni_open(const char *path, int unused_flags, int dict_flags) d->dict.close = dict_ni_close; d->dict.flags = dict_flags | DICT_FLAG_FIXED; - return (DICT_DEBUG(&d->dict)); + return (DICT_DEBUG (&d->dict)); } #endif diff --git a/postfix/src/util/dummy_read.c b/postfix/src/util/dummy_read.c index f70dc38cb..6369dd415 100644 --- a/postfix/src/util/dummy_read.c +++ b/postfix/src/util/dummy_read.c @@ -6,10 +6,10 @@ /* SYNOPSIS /* #include /* -/* int dummy_read(fd, buf, buf_len, timeout, context) +/* ssize_t dummy_read(fd, buf, buf_len, timeout, context) /* int fd; /* void *buf; -/* unsigned len; +/* size_t len; /* int timeout; /* void *context; /* DESCRIPTION @@ -52,10 +52,10 @@ /* dummy_read - dummy read operation */ -int dummy_read(int fd, void *unused_buf, unsigned len, +ssize_t dummy_read(int fd, void *unused_buf, size_t len, int unused_timeout, void *unused_context) { if (msg_verbose) - msg_info("dummy_read: fd %d, len %d", fd, len); + msg_info("dummy_read: fd %d, len %lu", fd, (unsigned long) len); return (0); } diff --git a/postfix/src/util/dummy_write.c b/postfix/src/util/dummy_write.c index a9e69695b..5b7b1e0f4 100644 --- a/postfix/src/util/dummy_write.c +++ b/postfix/src/util/dummy_write.c @@ -6,10 +6,10 @@ /* SYNOPSIS /* #include /* -/* int dummy_write(fd, buf, buf_len, timeout, context) +/* ssize_t dummy_write(fd, buf, buf_len, timeout, context) /* int fd; /* void *buf; -/* unsigned len; +/* size_t len; /* int timeout; /* void *context; /* DESCRIPTION @@ -52,10 +52,10 @@ /* dummy_write - dummy write operation */ -int dummy_write(int fd, void *unused_buf, unsigned len, - int unused_timeout, void *unused_context) +ssize_t dummy_write(int fd, void *unused_buf, size_t len, + int unused_timeout, void *unused_context) { if (msg_verbose) - msg_info("dummy_write: fd %d, len %d", fd, len); + msg_info("dummy_write: fd %d, len %lu", fd, (unsigned long) len); return (len); } diff --git a/postfix/src/util/dup2_pass_on_exec.c b/postfix/src/util/dup2_pass_on_exec.c index 9ab982ca0..df0e21cd3 100644 --- a/postfix/src/util/dup2_pass_on_exec.c +++ b/postfix/src/util/dup2_pass_on_exec.c @@ -30,6 +30,8 @@ #include #include +#include +#include #define DO(s) if (s < 0) { perror(#s); exit(1); } diff --git a/postfix/src/util/environ.c b/postfix/src/util/environ.c index cec1a865c..294ca199b 100644 --- a/postfix/src/util/environ.c +++ b/postfix/src/util/environ.c @@ -24,7 +24,7 @@ static int allocated = 0; /* environ is, or is not, allocated */ /* namelength - determine length of name in "name=whatever" */ -static int namelength(const char *name) +static ssize_t namelength(const char *name) { char *equal; @@ -115,7 +115,7 @@ int setenv(const char *name, const char *value, int clobber) /* cmalloc - malloc and copy block of memory */ -static char *cmalloc(int new_len, char *old, int old_len) +static char *cmalloc(ssize_t new_len, char *old, ssize_t old_len) { char *new = malloc(new_len); @@ -129,9 +129,9 @@ static char *cmalloc(int new_len, char *old, int old_len) static int addenv(char *nameval) { char **envp; - int n_used; /* number of environment entries */ - int l_used; /* bytes used excl. terminator */ - int l_need; /* bytes needed incl. terminator */ + ssize_t n_used; /* number of environment entries */ + ssize_t l_used; /* bytes used excl. terminator */ + ssize_t l_need; /* bytes needed incl. terminator */ for (envp = environ; envp && *envp; envp++) /* void */ ; diff --git a/postfix/src/util/events.c b/postfix/src/util/events.c index 379e31c7f..fa8e2daee 100644 --- a/postfix/src/util/events.c +++ b/postfix/src/util/events.c @@ -619,6 +619,7 @@ void event_loop(int delay) */ #include #include +#include /* timer_event - display event */ diff --git a/postfix/src/util/fifo_open.c b/postfix/src/util/fifo_open.c index 6ea988a13..1587779e0 100644 --- a/postfix/src/util/fifo_open.c +++ b/postfix/src/util/fifo_open.c @@ -27,6 +27,7 @@ #include #include #include +#include #define FIFO_PATH "test-fifo" #define perrorexit(s) { perror(s); exit(1); } diff --git a/postfix/src/util/fifo_rdonly_bug.c b/postfix/src/util/fifo_rdonly_bug.c index 5c1355634..bf93467be 100644 --- a/postfix/src/util/fifo_rdonly_bug.c +++ b/postfix/src/util/fifo_rdonly_bug.c @@ -31,6 +31,7 @@ #include #include #include +#include #define FIFO_PATH "test-fifo" #define TRIGGER_DELAY 5 diff --git a/postfix/src/util/fifo_rdwr_bug.c b/postfix/src/util/fifo_rdwr_bug.c index c9be211c6..2486876d5 100644 --- a/postfix/src/util/fifo_rdwr_bug.c +++ b/postfix/src/util/fifo_rdwr_bug.c @@ -32,6 +32,7 @@ #include #include #include +#include #define FIFO_PATH "test-fifo" #define perrorexit(s) { perror(s); exit(1); } diff --git a/postfix/src/util/fifo_trigger.c b/postfix/src/util/fifo_trigger.c index 841011a1b..8b56cf02c 100644 --- a/postfix/src/util/fifo_trigger.c +++ b/postfix/src/util/fifo_trigger.c @@ -9,7 +9,7 @@ /* int fifo_trigger(service, buf, len, timeout) /* const char *service; /* const char *buf; -/* int len; +/* ssize_t len; /* int timeout; /* DESCRIPTION /* fifo_trigger() wakes up the named fifo server by writing @@ -55,7 +55,7 @@ /* fifo_trigger - wakeup fifo server */ -int fifo_trigger(const char *service, const char *buf, int len, int timeout) +int fifo_trigger(const char *service, const char *buf, ssize_t len, int timeout) { static VSTRING *why; char *myname = "fifo_trigger"; @@ -130,7 +130,7 @@ static void handler(int sig) static void read_event(int unused_event, char *context) { - int fd = (int) context; + int fd = CAST_CHAR_PTR_TO_INT(context); char ch; wakeup_count++; @@ -145,7 +145,7 @@ int main(int unused_argc, char **unused_argv) listen_fd = fifo_listen(TEST_FIFO, 0600, NON_BLOCKING); msg_cleanup(cleanup); - event_enable_read(listen_fd, read_event, (char *) listen_fd); + event_enable_read(listen_fd, read_event, CAST_INT_TO_CHAR_PTR(listen_fd)); signal(SIGINT, handler); signal(SIGALRM, handler); for (;;) { diff --git a/postfix/src/util/fullname.c b/postfix/src/util/fullname.c index 6a2868360..a9d4b32b5 100644 --- a/postfix/src/util/fullname.c +++ b/postfix/src/util/fullname.c @@ -105,6 +105,7 @@ int main(int unused_argc, char **unused_argv) const char *cp = fullname(); printf("%s\n", cp ? cp : "null!"); + return (0); } #endif diff --git a/postfix/src/util/hex_code.c b/postfix/src/util/hex_code.c index 1397b583f..42d844b88 100644 --- a/postfix/src/util/hex_code.c +++ b/postfix/src/util/hex_code.c @@ -9,12 +9,12 @@ /* VSTRING *hex_encode(result, in, len) /* VSTRING *result; /* const char *in; -/* int len; +/* ssize_t len; /* /* VSTRING *hex_decode(result, in, len) /* VSTRING *result; /* const char *in; -/* int len; +/* ssize_t len; /* DESCRIPTION /* hex_encode() takes a block of len bytes and encodes it as one /* upper-case null-terminated string. The result value is @@ -59,11 +59,11 @@ static const unsigned char hex_chars[] = "0123456789ABCDEF"; /* hex_encode - raw data to encoded */ -VSTRING *hex_encode(VSTRING *result, const char *in, int len) +VSTRING *hex_encode(VSTRING *result, const char *in, ssize_t len) { const unsigned char *cp; int ch; - int count; + ssize_t count; VSTRING_RESET(result); for (cp = UCHAR_PTR(in), count = len; count > 0; count--, cp++) { @@ -77,10 +77,10 @@ VSTRING *hex_encode(VSTRING *result, const char *in, int len) /* hex_decode - encoded data to raw */ -VSTRING *hex_decode(VSTRING *result, const char *in, int len) +VSTRING *hex_decode(VSTRING *result, const char *in, ssize_t len) { const unsigned char *cp; - int count; + ssize_t count; unsigned int hex; unsigned int bin; @@ -99,11 +99,11 @@ VSTRING *hex_decode(VSTRING *result, const char *in, int len) return (0); hex = cp[1]; if (hex >= '0' && hex <= '9') - bin |= (hex - '0') ; + bin |= (hex - '0'); else if (hex >= 'A' && hex <= 'F') - bin |= (hex - 'A' + 10) ; + bin |= (hex - 'A' + 10); else if (hex >= 'a' && hex <= 'f') - bin |= (hex - 'a' + 10) ; + bin |= (hex - 'a' + 10); else return (0); VSTRING_ADDCH(result, bin); diff --git a/postfix/src/util/hex_code.h b/postfix/src/util/hex_code.h index d437da16e..e868fe6b2 100644 --- a/postfix/src/util/hex_code.h +++ b/postfix/src/util/hex_code.h @@ -19,8 +19,8 @@ /* * External interface. */ -extern VSTRING *hex_encode(VSTRING *, const char *, int); -extern VSTRING *hex_decode(VSTRING *, const char *, int); +extern VSTRING *hex_encode(VSTRING *, const char *, ssize_t); +extern VSTRING *hex_decode(VSTRING *, const char *, ssize_t); /* LICENSE /* .ad diff --git a/postfix/src/util/hex_quote.c b/postfix/src/util/hex_quote.c index 5c752b499..f515441ad 100644 --- a/postfix/src/util/hex_quote.c +++ b/postfix/src/util/hex_quote.c @@ -115,9 +115,9 @@ VSTRING *hex_unquote(VSTRING *raw, const char *hex) #define BUFLEN 1024 -static int read_buf(VSTREAM *fp, VSTRING *buf) +static ssize_t read_buf(VSTREAM *fp, VSTRING *buf) { - int len; + ssize_t len; VSTRING_RESET(buf); len = vstream_fread(fp, STR(buf), vstring_avail(buf)); @@ -130,14 +130,14 @@ int main(int unused_argc, char **unused_argv) { VSTRING *raw = vstring_alloc(BUFLEN); VSTRING *hex = vstring_alloc(100); - int len; + ssize_t len; while ((len = read_buf(VSTREAM_IN, raw)) > 0) { hex_quote(hex, STR(raw)); if (hex_unquote(raw, STR(hex)) == 0) msg_fatal("bad input: %.100s", STR(hex)); if (LEN(raw) != len) - msg_fatal("len %d != raw len %d", len, LEN(raw)); + msg_fatal("len %ld != raw len %ld", len, LEN(raw)); if (vstream_fwrite(VSTREAM_OUT, STR(raw), LEN(raw)) != LEN(raw)) msg_fatal("write error: %m"); } diff --git a/postfix/src/util/htable.c b/postfix/src/util/htable.c index c64a64b33..e113e6a4c 100644 --- a/postfix/src/util/htable.c +++ b/postfix/src/util/htable.c @@ -128,9 +128,9 @@ static unsigned htable_hash(const char *s, unsigned size) */ while (*s) { - h = (h << 4) + *s++; + h = (h << 4U) + *s++; if ((g = (h & 0xf0000000)) != 0) { - h ^= (g >> 24); + h ^= (g >> 24U); h ^= g; } } @@ -352,7 +352,7 @@ int main(int unused_argc, char **unused_argv) */ hash = htable_create(10); while (vstring_get(buf, VSTREAM_IN) != VSTREAM_EOF) - htable_enter(hash, vstring_str(buf), (void *) count++); + htable_enter(hash, vstring_str(buf), CAST_INT_TO_CHAR_PTR(count++)); ht_info = htable_list(hash); for (i = 0; i < hash->used; i++) { r = myrand() % hash->used; diff --git a/postfix/src/util/inet_addr_host.c b/postfix/src/util/inet_addr_host.c index 3331ffee0..f330e5b5a 100644 --- a/postfix/src/util/inet_addr_host.c +++ b/postfix/src/util/inet_addr_host.c @@ -64,7 +64,7 @@ int inet_addr_host(INET_ADDR_LIST *addr_list, const char *hostname) struct addrinfo *res0; struct addrinfo *res; int aierr; - int hostnamelen; + ssize_t hostnamelen; const char *hname; const char *serv; int initial_count = addr_list->used; @@ -146,7 +146,8 @@ int main(int argc, char **argv) if (argc < 3) msg_fatal("usage: %s protocols hostname...", argv[0]); - proto_info = inet_proto_init(argv[0], *++argv); + proto_info = inet_proto_init(argv[0], argv[1]); + argv += 1; inet_addr_list_init(&list); diff --git a/postfix/src/util/inet_addr_local.c b/postfix/src/util/inet_addr_local.c index 6ebe3eb81..617c3820b 100644 --- a/postfix/src/util/inet_addr_local.c +++ b/postfix/src/util/inet_addr_local.c @@ -604,6 +604,7 @@ int main(int unused_argc, char **argv) } inet_addr_list_free(&addr_list); inet_addr_list_free(&mask_list); + return (0); } #endif diff --git a/postfix/src/util/inet_trigger.c b/postfix/src/util/inet_trigger.c index dddbcb62a..2d27b5f93 100644 --- a/postfix/src/util/inet_trigger.c +++ b/postfix/src/util/inet_trigger.c @@ -9,7 +9,7 @@ /* int inet_trigger(service, buf, len, timeout) /* char *service; /* const char *buf; -/* int len; +/* ssize_t len; /* int timeout; /* DESCRIPTION /* inet_trigger() wakes up the named INET-domain server by making @@ -90,7 +90,7 @@ static void inet_trigger_event(int event, char *context) /* inet_trigger - wakeup INET-domain server */ -int inet_trigger(const char *service, const char *buf, int len, int timeout) +int inet_trigger(const char *service, const char *buf, ssize_t len, int timeout) { char *myname = "inet_trigger"; struct inet_trigger *ip; diff --git a/postfix/src/util/iostuff.h b/postfix/src/util/iostuff.h index 7d04346c8..8d3c7a5ca 100644 --- a/postfix/src/util/iostuff.h +++ b/postfix/src/util/iostuff.h @@ -20,12 +20,12 @@ extern int readable(int); extern int writable(int); extern off_t get_file_limit(void); extern void set_file_limit(off_t); -extern int peekfd(int); +extern ssize_t peekfd(int); extern int read_wait(int, int); extern int write_wait(int, int); -extern int write_buf(int, const char *, int, int); -extern int timed_read(int, void *, unsigned, int, void *); -extern int timed_write(int, void *, unsigned, int, void *); +extern ssize_t write_buf(int, const char *, ssize_t, int); +extern ssize_t timed_read(int, void *, size_t, int, void *); +extern ssize_t timed_write(int, void *, size_t, int, void *); extern void doze(unsigned); extern void rand_sleep(unsigned, unsigned); extern int duplex_pipe(int *); @@ -33,8 +33,8 @@ extern int stream_recv_fd(int); extern int stream_send_fd(int, int); extern int unix_recv_fd(int); extern int unix_send_fd(int, int); -extern int dummy_read(int, void *, unsigned, int, void *); -extern int dummy_write(int, void *, unsigned, int, void *); +extern ssize_t dummy_read(int, void *, size_t, int, void *); +extern ssize_t dummy_write(int, void *, size_t, int, void *); #define BLOCKING 0 #define NON_BLOCKING 1 diff --git a/postfix/src/util/line_wrap.c b/postfix/src/util/line_wrap.c index 50d172cab..38c5558cf 100644 --- a/postfix/src/util/line_wrap.c +++ b/postfix/src/util/line_wrap.c @@ -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, int len, int indent, LINE_WRAP_FN output_fn, +void line_wrap(const char *str, ssize_t len, ssize_t indent, LINE_WRAP_FN output_fn, char *context) { const char *start_line; const char *word; const char *next_word; const char *next_space; - int line_len; - int curr_len; - int curr_indent; + ssize_t line_len; + ssize_t curr_len; + ssize_t curr_indent; if (indent < 0) { curr_indent = -indent; diff --git a/postfix/src/util/line_wrap.h b/postfix/src/util/line_wrap.h index b901c1f3d..d1b0c18ea 100644 --- a/postfix/src/util/line_wrap.h +++ b/postfix/src/util/line_wrap.h @@ -14,8 +14,8 @@ /* * External interface. */ -typedef void (*LINE_WRAP_FN) (const char *, int, int, char *); -extern void line_wrap(const char *, int, int, LINE_WRAP_FN, char *); +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 *); /* LICENSE /* .ad diff --git a/postfix/src/util/mac_expand.c b/postfix/src/util/mac_expand.c index 44724785a..3bd304616 100644 --- a/postfix/src/util/mac_expand.c +++ b/postfix/src/util/mac_expand.c @@ -116,13 +116,12 @@ typedef struct { static int mac_expand_callback(int type, VSTRING *buf, char *ptr) { - char *myname = "mac_expand_callback"; MAC_EXP *mc = (MAC_EXP *) ptr; int lookup_mode; const char *text; char *cp; int ch; - int len; + ssize_t len; /* * Sanity check. @@ -244,6 +243,7 @@ int mac_expand(VSTRING *result, const char *pattern, int flags, /* * This code certainly deserves a stand-alone test program. */ +#include #include #include #include diff --git a/postfix/src/util/mac_parse.c b/postfix/src/util/mac_parse.c index 6bd638d42..22398ad61 100644 --- a/postfix/src/util/mac_parse.c +++ b/postfix/src/util/mac_parse.c @@ -191,6 +191,7 @@ int main(int unused_argc, char **unused_argv) vstream_fflush(VSTREAM_OUT); } vstring_free(buf); + return (0); } #endif diff --git a/postfix/src/util/match_ops.c b/postfix/src/util/match_ops.c index 19c1d3244..29eff7e1c 100644 --- a/postfix/src/util/match_ops.c +++ b/postfix/src/util/match_ops.c @@ -213,7 +213,7 @@ int match_hostaddr(int unused_flags, const char *addr, const char *pattern) if (strcasecmp(addr, pattern) == 0) return (1); } else { - int addr_len = strlen(addr); + ssize_t addr_len = strlen(addr); if (strncasecmp(addr, pattern + 1, addr_len) == 0 && strcmp(pattern + 1 + addr_len, "]") == 0) diff --git a/postfix/src/util/myaddrinfo.c b/postfix/src/util/myaddrinfo.c index db2a60454..941d58b94 100644 --- a/postfix/src/util/myaddrinfo.c +++ b/postfix/src/util/myaddrinfo.c @@ -177,6 +177,7 @@ #include #include #include +#include /* sprintf() */ /* Utility library. */ @@ -536,7 +537,7 @@ int sockaddr_to_hostaddr(const struct sockaddr * sa, SOCKADDR_SIZE salen, { #ifdef EMULATE_IPV4_ADDRINFO char portbuf[sizeof("65535")]; - int len; + ssize_t len; /* * Emulated getnameinfo(3) version. The buffer length includes the space diff --git a/postfix/src/util/mymalloc.c b/postfix/src/util/mymalloc.c index 174215d79..91b4af281 100644 --- a/postfix/src/util/mymalloc.c +++ b/postfix/src/util/mymalloc.c @@ -7,11 +7,11 @@ /* #include /* /* char *mymalloc(len) -/* int len; +/* ssize_t len; /* /* char *myrealloc(ptr, len) /* char *ptr; -/* int len; +/* ssize_t len; /* /* void myfree(ptr) /* char *ptr; @@ -21,11 +21,11 @@ /* /* char *mystrndup(str, len) /* const char *str; -/* int len; +/* ssize_t len; /* /* char *mymemdup(ptr, len) /* const char *ptr; -/* int len; +/* ssize_t len; /* DESCRIPTION /* This module performs low-level memory management with error /* handling. A call of these functions either succeeds or it does @@ -89,11 +89,11 @@ */ typedef struct MBLOCK { int signature; /* set when block is active */ - int length; /* user requested length */ + ssize_t length; /* user requested length */ union { ALIGN_TYPE align; char payload[1]; /* actually a bunch of bytes */ - } u; + } u; } MBLOCK; #define SIGNATURE 0xdead @@ -120,13 +120,13 @@ typedef struct MBLOCK { /* mymalloc - allocate memory or bust */ -char *mymalloc(int len) +char *mymalloc(ssize_t len) { char *ptr; MBLOCK *real_ptr; if (len < 1) - msg_panic("mymalloc: requested length %d", len); + msg_panic("mymalloc: requested length %ld", (long) len); if ((real_ptr = (MBLOCK *) malloc(SPACE_FOR(len))) == 0) msg_fatal("mymalloc: insufficient memory: %m"); CHECK_OUT_PTR(ptr, real_ptr, len); @@ -136,13 +136,13 @@ char *mymalloc(int len) /* myrealloc - reallocate memory or bust */ -char *myrealloc(char *ptr, int len) +char *myrealloc(char *ptr, ssize_t len) { MBLOCK *real_ptr; - int old_len; + ssize_t old_len; if (len < 1) - msg_panic("myrealloc: requested length %d", len); + msg_panic("myrealloc: requested length %ld", (long) len); CHECK_IN_PTR(ptr, real_ptr, old_len, "myrealloc"); if ((real_ptr = (MBLOCK *) realloc((char *) real_ptr, SPACE_FOR(len))) == 0) msg_fatal("myrealloc: insufficient memory: %m"); @@ -157,7 +157,7 @@ char *myrealloc(char *ptr, int len) void myfree(char *ptr) { MBLOCK *real_ptr; - int len; + ssize_t len; CHECK_IN_PTR(ptr, real_ptr, len, "myfree"); memset((char *) real_ptr, FILLER, SPACE_FOR(len)); @@ -175,13 +175,15 @@ char *mystrdup(const char *str) /* mystrndup - save substring to heap */ -char *mystrndup(const char *str, int len) +char *mystrndup(const char *str, ssize_t len) { char *result; char *cp; if (str == 0) msg_panic("mystrndup: null pointer argument"); + if (len < 0) + msg_panic("mystrndup: requested length %ld", (long) len); if ((cp = memchr(str, 0, len)) != 0) len = cp - str; result = memcpy(mymalloc(len + 1), str, len); @@ -191,7 +193,7 @@ char *mystrndup(const char *str, int len) /* mymemdup - copy memory */ -char *mymemdup(const char *ptr, int len) +char *mymemdup(const char *ptr, ssize_t len) { if (ptr == 0) msg_panic("mymemdup: null pointer argument"); diff --git a/postfix/src/util/mymalloc.h b/postfix/src/util/mymalloc.h index 9503bcd17..0c3216d5d 100644 --- a/postfix/src/util/mymalloc.h +++ b/postfix/src/util/mymalloc.h @@ -14,12 +14,12 @@ /* * External interface. */ -extern char *mymalloc(int); -extern char *myrealloc(char *, int); +extern char *mymalloc(ssize_t); +extern char *myrealloc(char *, ssize_t); extern void myfree(char *); extern char *mystrdup(const char *); -extern char *mystrndup(const char *, int len); -extern char *mymemdup(const char *, int); +extern char *mystrndup(const char *, ssize_t); +extern char *mymemdup(const char *, ssize_t); /* LICENSE /* .ad diff --git a/postfix/src/util/mystrtok.c b/postfix/src/util/mystrtok.c index 7607a6b35..a87a58cba 100644 --- a/postfix/src/util/mystrtok.c +++ b/postfix/src/util/mystrtok.c @@ -87,6 +87,7 @@ int main(void) vstream_fflush(VSTREAM_OUT); } vstring_free(vp); + return (0); } #endif diff --git a/postfix/src/util/name_mask.c b/postfix/src/util/name_mask.c index cd73a5310..3ce83ffc4 100644 --- a/postfix/src/util/name_mask.c +++ b/postfix/src/util/name_mask.c @@ -195,7 +195,7 @@ const char *str_name_mask_opt(const char *context, NAME_MASK *table, /* * Stand-alone test program. */ - +#include #include int main(int argc, char **argv) diff --git a/postfix/src/util/netstring.c b/postfix/src/util/netstring.c index 4acea4fa5..82b54941c 100644 --- a/postfix/src/util/netstring.c +++ b/postfix/src/util/netstring.c @@ -17,17 +17,17 @@ /* VSTRING *netstring_get(stream, buf, limit) /* VSTREAM *stream; /* VSTRING *buf; -/* int limit; +/* ssize_t limit; /* /* void netstring_put(stream, data, len) /* VSTREAM *stream; /* const char *data; -/* int len; +/* int ssize_t; /* /* void netstring_put_multi(stream, data, len, data, len, ..., 0) /* VSTREAM *stream; /* const char *data; -/* int len; +/* ssize_t len; /* /* void NETSTRING_PUT_BUF(stream, buf) /* VSTREAM *stream; @@ -39,20 +39,20 @@ /* VSTRING *netstring_memcpy(buf, data, len) /* VSTRING *buf; /* const char *data; -/* int len; +/* int ssize_t; /* /* VSTRING *netstring_memcat(buf, data, len) /* VSTRING *buf; /* const char *src; -/* int len; +/* ssize_t len; /* AUXILIARY ROUTINES -/* int netstring_get_length(stream) +/* ssize_t netstring_get_length(stream) /* VSTREAM *stream; /* /* VSTRING *netstring_get_data(stream, buf, len) /* VSTREAM *stream; /* VSTRING *buf; -/* int len; +/* ssize_t len; /* /* void netstring_get_terminator(stream) /* VSTREAM *stream; @@ -185,10 +185,10 @@ void netstring_except(VSTREAM *stream, int exception) /* netstring_get_length - read netstring length + terminator */ -int netstring_get_length(VSTREAM *stream) +ssize_t netstring_get_length(VSTREAM *stream) { char *myname = "netstring_get_length"; - int len = 0; + ssize_t len = 0; int ch; for (;;) { @@ -198,7 +198,7 @@ int netstring_get_length(VSTREAM *stream) NETSTRING_ERR_TIME : NETSTRING_ERR_EOF); case ':': if (msg_verbose > 1) - msg_info("%s: read netstring length %d", myname, len); + msg_info("%s: read netstring length %ld", myname, (long) len); return (len); default: if (!ISDIGIT(ch)) @@ -211,7 +211,7 @@ int netstring_get_length(VSTREAM *stream) /* netstring_get_data - read netstring payload + terminator */ -VSTRING *netstring_get_data(VSTREAM *stream, VSTRING *buf, int len) +VSTRING *netstring_get_data(VSTREAM *stream, VSTRING *buf, ssize_t len) { char *myname = "netstring_get_data"; @@ -229,7 +229,7 @@ VSTRING *netstring_get_data(VSTREAM *stream, VSTRING *buf, int len) NETSTRING_ERR_TIME : NETSTRING_ERR_EOF); if (msg_verbose > 1) msg_info("%s: read netstring data %.*s", - myname, len < 30 ? len : 30, STR(buf)); + myname, (int) (len < 30 ? len : 30), STR(buf)); netstring_get_terminator(stream); /* @@ -249,9 +249,9 @@ void netstring_get_terminator(VSTREAM *stream) /* netstring_get - read string from netstring stream */ -VSTRING *netstring_get(VSTREAM *stream, VSTRING *buf, int limit) +VSTRING *netstring_get(VSTREAM *stream, VSTRING *buf, ssize_t limit) { - int len; + ssize_t len; len = netstring_get_length(stream); if (limit && len > limit) @@ -262,14 +262,14 @@ VSTRING *netstring_get(VSTREAM *stream, VSTRING *buf, int limit) /* netstring_put - send string as netstring */ -void netstring_put(VSTREAM *stream, const char *data, int len) +void netstring_put(VSTREAM *stream, const char *data, ssize_t len) { char *myname = "netstring_put"; if (msg_verbose > 1) - msg_info("%s: write netstring len %d data %.*s", - myname, len, len < 30 ? len : 30, data); - vstream_fprintf(stream, "%d:", len); + msg_info("%s: write netstring len %ld data %.*s", + myname, (long) len, (int) (len < 30 ? len : 30), data); + vstream_fprintf(stream, "%ld:", (long) len); vstream_fwrite(stream, data, len); VSTREAM_PUTC(',', stream); } @@ -279,9 +279,9 @@ void netstring_put(VSTREAM *stream, const char *data, int len) void netstring_put_multi(VSTREAM *stream,...) { char *myname = "netstring_put_multi"; - int total; + ssize_t total; char *data; - int data_len; + ssize_t data_len; va_list ap; /* @@ -289,8 +289,8 @@ void netstring_put_multi(VSTREAM *stream,...) */ va_start(ap, stream); for (total = 0; (data = va_arg(ap, char *)) != 0; total += data_len) - if ((data_len = va_arg(ap, int)) < 0) - msg_panic("netstring_put_multi: bad data length %d", data_len); + if ((data_len = va_arg(ap, ssize_t)) < 0) + msg_panic("netstring_put_multi: bad data length %ld", (long) data_len); va_end(ap); /* @@ -299,19 +299,19 @@ void netstring_put_multi(VSTREAM *stream,...) if (msg_verbose > 1) { va_start(ap, stream); data = va_arg(ap, char *); - data_len = va_arg(ap, int); - msg_info("%s: write netstring len %d data %.*s", - myname, total, data_len < 30 ? data_len : 30, data); + data_len = va_arg(ap, ssize_t); + msg_info("%s: write netstring len %ld data %.*s", + myname, (long) total, (int) (data_len < 30 ? data_len : 30), data); va_end(ap); } - + /* * Send the length, content and terminator. */ - vstream_fprintf(stream, "%d:", total); + vstream_fprintf(stream, "%ld:", (long) total); va_start(ap, stream); while ((data = va_arg(ap, char *)) != 0) { - data_len = va_arg(ap, int); + data_len = va_arg(ap, ssize_t); if (data_len > 0) if (vstream_fwrite(stream, data, data_len) != data_len) netstring_except(stream, vstream_ftimeout(stream) ? @@ -332,9 +332,9 @@ void netstring_fflush(VSTREAM *stream) /* netstring_memcpy - copy data as in-memory netstring */ -VSTRING *netstring_memcpy(VSTRING *buf, const char *src, int len) +VSTRING *netstring_memcpy(VSTRING *buf, const char *src, ssize_t len) { - vstring_sprintf(buf, "%d:", len); + vstring_sprintf(buf, "%ld:", (long) len); vstring_memcat(buf, src, len); VSTRING_ADDCH(buf, ','); return (buf); @@ -342,9 +342,9 @@ VSTRING *netstring_memcpy(VSTRING *buf, const char *src, int len) /* netstring_memcat - append data as in-memory netstring */ -VSTRING *netstring_memcat(VSTRING *buf, const char *src, int len) +VSTRING *netstring_memcat(VSTRING *buf, const char *src, ssize_t len) { - vstring_sprintf_append(buf, "%d:", len); + vstring_sprintf_append(buf, "%ld:", (long) len); vstring_memcat(buf, src, len); VSTRING_ADDCH(buf, ','); return (buf); diff --git a/postfix/src/util/netstring.h b/postfix/src/util/netstring.h index 6b82d90e4..e6908792e 100644 --- a/postfix/src/util/netstring.h +++ b/postfix/src/util/netstring.h @@ -27,15 +27,15 @@ extern void netstring_except(VSTREAM *, int); extern void netstring_setup(VSTREAM *, int); -extern int netstring_get_length(VSTREAM *); -extern VSTRING *netstring_get_data(VSTREAM *, VSTRING *, int); +extern ssize_t netstring_get_length(VSTREAM *); +extern VSTRING *netstring_get_data(VSTREAM *, VSTRING *, ssize_t); extern void netstring_get_terminator(VSTREAM *); -extern VSTRING *netstring_get(VSTREAM *, VSTRING *, int); -extern void netstring_put(VSTREAM *, const char *, int); +extern VSTRING *netstring_get(VSTREAM *, VSTRING *, ssize_t); +extern void netstring_put(VSTREAM *, const char *, ssize_t); extern void netstring_put_multi(VSTREAM *,...); extern void netstring_fflush(VSTREAM *); -extern VSTRING *netstring_memcpy(VSTRING *, const char *, int); -extern VSTRING *netstring_memcat(VSTRING *, const char *, int); +extern VSTRING *netstring_memcpy(VSTRING *, const char *, ssize_t); +extern VSTRING *netstring_memcat(VSTRING *, const char *, ssize_t); #define NETSTRING_PUT_BUF(str, buf) \ netstring_put((str), vstring_str(buf), VSTRING_LEN(buf)) diff --git a/postfix/src/util/open_lock.c b/postfix/src/util/open_lock.c index 9a9273d5f..87e852d9b 100644 --- a/postfix/src/util/open_lock.c +++ b/postfix/src/util/open_lock.c @@ -6,10 +6,10 @@ /* SYNOPSIS /* #include /* -/* VSTREAM *open_lock(path, int flags, int mode, why) +/* VSTREAM *open_lock(path, flags, mode, why) /* const char *path; /* int flags; -/* int mode; +/* mode_t mode; /* VSTRING *why; /* DESCRIPTION /* This module opens or creates the named file and attempts to @@ -55,7 +55,7 @@ /* open_lock - open file and lock it for exclusive access */ -VSTREAM *open_lock(const char *path, int flags, int mode, VSTRING *why) +VSTREAM *open_lock(const char *path, int flags, mode_t mode, VSTRING *why) { VSTREAM *fp; diff --git a/postfix/src/util/open_lock.h b/postfix/src/util/open_lock.h index 869233f95..ada9f4d65 100644 --- a/postfix/src/util/open_lock.h +++ b/postfix/src/util/open_lock.h @@ -25,7 +25,7 @@ /* * External interface. */ -extern VSTREAM *open_lock(const char *, int, int, VSTRING *); +extern VSTREAM *open_lock(const char *, int, mode_t, VSTRING *); /* LICENSE /* .ad diff --git a/postfix/src/util/peekfd.c b/postfix/src/util/peekfd.c index 90040ebbf..9e984908a 100644 --- a/postfix/src/util/peekfd.c +++ b/postfix/src/util/peekfd.c @@ -6,7 +6,7 @@ /* SYNOPSIS /* #include /* -/* int peekfd(fd) +/* ssize_t peekfd(fd) /* int fd; /* DESCRIPTION /* peekfd() attempts to find out how many bytes are available to @@ -44,17 +44,17 @@ /* peekfd - return amount of data ready to read */ -int peekfd(int fd) +ssize_t peekfd(int fd) { - int count; /* * Anticipate a series of system-dependent code fragments. */ #ifdef FIONREAD + int count; + return (ioctl(fd, FIONREAD, (char *) &count) < 0 ? -1 : count); #else #error "don't know how to look ahead" #endif } - diff --git a/postfix/src/util/readlline.c b/postfix/src/util/readlline.c index f3595517f..95bb29bb7 100644 --- a/postfix/src/util/readlline.c +++ b/postfix/src/util/readlline.c @@ -72,7 +72,7 @@ VSTRING *readlline(VSTRING *buf, VSTREAM *fp, int *lineno) { int ch; int next; - int start; + ssize_t start; char *cp; VSTRING_RESET(buf); diff --git a/postfix/src/util/safe_open.c b/postfix/src/util/safe_open.c index c047a5bac..d64840b11 100644 --- a/postfix/src/util/safe_open.c +++ b/postfix/src/util/safe_open.c @@ -9,7 +9,7 @@ /* VSTREAM *safe_open(path, flags, mode, st, user, group, why) /* const char *path; /* int flags; -/* int mode; +/* mode_t mode; /* struct stat *st; /* uid_t user; /* gid_t group; @@ -174,7 +174,7 @@ static VSTREAM *safe_open_exist(const char *path, int flags, /* safe_open_create - create new file */ -static VSTREAM *safe_open_create(const char *path, int flags, int mode, +static VSTREAM *safe_open_create(const char *path, int flags, mode_t mode, struct stat * st, uid_t user, uid_t group, VSTRING *why) { VSTREAM *fp; @@ -222,7 +222,7 @@ static VSTREAM *safe_open_create(const char *path, int flags, int mode, /* safe_open - safely open or create file */ -VSTREAM *safe_open(const char *path, int flags, int mode, +VSTREAM *safe_open(const char *path, int flags, mode_t mode, struct stat * st, uid_t user, gid_t group, VSTRING *why) { VSTREAM *fp; diff --git a/postfix/src/util/safe_open.h b/postfix/src/util/safe_open.h index 7bee82c09..88b534499 100644 --- a/postfix/src/util/safe_open.h +++ b/postfix/src/util/safe_open.h @@ -26,7 +26,7 @@ /* * External interface. */ -extern VSTREAM *safe_open(const char *, int, int, struct stat *, uid_t, gid_t, VSTRING *); +extern VSTREAM *safe_open(const char *, int, mode_t, struct stat *, uid_t, gid_t, VSTRING *); /* LICENSE /* .ad diff --git a/postfix/src/util/select_bug.c b/postfix/src/util/select_bug.c index ff5f36293..9b479ca45 100644 --- a/postfix/src/util/select_bug.c +++ b/postfix/src/util/select_bug.c @@ -29,6 +29,7 @@ #include #include #include +#include #include /* bzero() prototype for 44BSD */ /* Utility library. */ @@ -66,7 +67,7 @@ static pid_t fork_and_read_select(const char *what, int delay, int fd) } } -main(int argc, char **argv) +int main(int argc, char **argv) { int pair1[2]; int pair2[2]; @@ -90,4 +91,5 @@ main(int argc, char **argv) msg_fatal("write: %m"); while (wait((int *) 0) >= 0) /* void */ ; + return (0); } diff --git a/postfix/src/util/sigdelay.c b/postfix/src/util/sigdelay.c index c916fb46d..6f07a22ac 100644 --- a/postfix/src/util/sigdelay.c +++ b/postfix/src/util/sigdelay.c @@ -95,13 +95,14 @@ void sigdelay(void) #include #include +#include static void gotsig(int sig) { printf("Got signal %d\n", sig); } -int main(int unused_argc, int unused_argv) +int main(int unused_argc, char **unused_argv) { signal(SIGINT, gotsig); signal(SIGQUIT, gotsig); diff --git a/postfix/src/util/spawn_command.c b/postfix/src/util/spawn_command.c index ff9a12364..5fb30d297 100644 --- a/postfix/src/util/spawn_command.c +++ b/postfix/src/util/spawn_command.c @@ -42,10 +42,10 @@ /* .IP "SPAWN_CMD_STDERR (int)" /* Each of these specifies I/O redirection of one of the standard file /* descriptors for the command. -/* .IP "SPAWN_CMD_UID (int)" +/* .IP "SPAWN_CMD_UID (uid_t)" /* The user ID to execute the command as. The value -1 is reserved /* and cannot be specified. -/* .IP "SPAWN_CMD_GID (int)" +/* .IP "SPAWN_CMD_GID (gid_t)" /* The group ID to execute the command as. The value -1 is reserved /* and cannot be specified. /* .IP "SPAWN_CMD_TIME_LIMIT (int)" diff --git a/postfix/src/util/stream_recv_fd.c b/postfix/src/util/stream_recv_fd.c index 9698d7a26..185199c9c 100644 --- a/postfix/src/util/stream_recv_fd.c +++ b/postfix/src/util/stream_recv_fd.c @@ -73,6 +73,8 @@ int stream_recv_fd(int fd) * stream_send_fd test program) and copy its content until EOF. */ #include +#include +#include #include #include diff --git a/postfix/src/util/stream_send_fd.c b/postfix/src/util/stream_send_fd.c index 4d05de237..777f95cc0 100644 --- a/postfix/src/util/stream_send_fd.c +++ b/postfix/src/util/stream_send_fd.c @@ -59,6 +59,7 @@ int stream_send_fd(int fd, int sendfd) #ifdef STREAM_CONNECTIONS if (ioctl(fd, I_SENDFD, sendfd) < 0) msg_fatal("%s: send file descriptor: %m", myname); + return (0); #else msg_fatal("stream connections are not implemented"); #endif @@ -72,6 +73,8 @@ int stream_send_fd(int fd, int sendfd) */ #include #include +#include +#include #include #include diff --git a/postfix/src/util/stream_test.c b/postfix/src/util/stream_test.c index 1d51f31f4..5c8f82fa4 100644 --- a/postfix/src/util/stream_test.c +++ b/postfix/src/util/stream_test.c @@ -3,27 +3,29 @@ #include #include #include -#include -#include "iostuff.h" +#include "iostuff.h" #include "msg.h" #include "msg_vstream.h" #include "listen.h" #include "connect.h" +#ifdef SUNOS5 +#include + #define FIFO "/tmp/test-fifo" static const char *progname; -static print_fstat(int fd) +static void print_fstat(int fd) { struct stat st; if (fstat(fd, &st) < 0) msg_fatal("fstat: %m"); vstream_printf("fd %d\n", fd); - vstream_printf("dev %d\n", st.st_dev); - vstream_printf("ino %d\n", st.st_ino); + vstream_printf("dev %ld\n", (long) st.st_dev); + vstream_printf("ino %ld\n", (long) st.st_ino); vstream_fflush(VSTREAM_OUT); } @@ -32,7 +34,7 @@ static NORETURN usage(void) msg_fatal("usage: %s [-p] [-n count] [-v]", progname); } -main(int argc, char **argv) +int main(int argc, char **argv) { int server_fd; int client_fd; @@ -99,4 +101,11 @@ main(int argc, char **argv) } if (close(server_fd) < 0) msg_fatal("close server fd"); + return (0); +} +#else +int main(int argc, char **argv) +{ + return (0); } +#endif diff --git a/postfix/src/util/stream_trigger.c b/postfix/src/util/stream_trigger.c index 9cb57e513..0935a0d4e 100644 --- a/postfix/src/util/stream_trigger.c +++ b/postfix/src/util/stream_trigger.c @@ -9,7 +9,7 @@ /* int stream_trigger(service, buf, len, timeout) /* const char *service; /* const char *buf; -/* int len; +/* ssize_t len; /* int timeout; /* DESCRIPTION /* stream_trigger() wakes up the named stream server by making @@ -86,7 +86,7 @@ static void stream_trigger_event(int event, char *context) /* stream_trigger - wakeup stream server */ -int stream_trigger(const char *service, const char *buf, int len, int timeout) +int stream_trigger(const char *service, const char *buf, ssize_t len, int timeout) { char *myname = "stream_trigger"; struct stream_trigger *sp; diff --git a/postfix/src/util/sys_defs.h b/postfix/src/util/sys_defs.h index f2a1bb372..c2ac93137 100644 --- a/postfix/src/util/sys_defs.h +++ b/postfix/src/util/sys_defs.h @@ -1242,7 +1242,7 @@ typedef int pid_t; * not (Clive Jones). So we'll set the threshold at 2.7. */ #ifndef NORETURN -#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3 +#if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ >= 3 #define NORETURN void __attribute__((__noreturn__)) #endif #endif diff --git a/postfix/src/util/timed_connect.c b/postfix/src/util/timed_connect.c index ee4e150b1..3446e4fa6 100644 --- a/postfix/src/util/timed_connect.c +++ b/postfix/src/util/timed_connect.c @@ -10,7 +10,7 @@ /* int timed_connect(fd, buf, buf_len, timeout) /* int fd; /* struct sockaddr *buf; -/* unsigned buf_len; +/* int buf_len; /* int timeout; /* DESCRIPTION /* timed_connect() implement a BSD socket connect() operation that is diff --git a/postfix/src/util/timed_read.c b/postfix/src/util/timed_read.c index 509004ba3..51f1cc6f9 100644 --- a/postfix/src/util/timed_read.c +++ b/postfix/src/util/timed_read.c @@ -6,10 +6,10 @@ /* SYNOPSIS /* #include /* -/* int timed_read(fd, buf, buf_len, timeout, context) +/* ssize_t timed_read(fd, buf, len, timeout, context) /* int fd; /* void *buf; -/* unsigned len; +/* size_t len; /* int timeout; /* void *context; /* DESCRIPTION @@ -21,7 +21,7 @@ /* File descriptor in the range 0..FD_SETSIZE. /* .IP buf /* Read buffer pointer. -/* .IP buf_len +/* .IP len /* Read buffer size. /* .IP timeout /* The deadline in seconds. If this is <= 0, the deadline feature @@ -57,10 +57,10 @@ /* timed_read - read with deadline */ -int timed_read(int fd, void *buf, unsigned len, +ssize_t timed_read(int fd, void *buf, size_t len, int timeout, void *unused_context) { - int ret; + ssize_t ret; /* * Wait for a limited amount of time for something to happen. If nothing diff --git a/postfix/src/util/timed_write.c b/postfix/src/util/timed_write.c index 3089a8390..d6cf9da59 100644 --- a/postfix/src/util/timed_write.c +++ b/postfix/src/util/timed_write.c @@ -6,10 +6,10 @@ /* SYNOPSIS /* #include /* -/* int timed_write(fd, buf, buf_len, timeout, context) +/* ssize_t timed_write(fd, buf, len, timeout, context) /* int fd; /* const void *buf; -/* unsigned len; +/* size_t len; /* int timeout; /* void *context; /* DESCRIPTION @@ -21,7 +21,7 @@ /* File descriptor in the range 0..FD_SETSIZE. /* .IP buf /* Write buffer pointer. -/* .IP buf_len +/* .IP len /* Write buffer size. /* .IP timeout /* The deadline in seconds. If this is <= 0, the deadline feature @@ -57,10 +57,10 @@ /* timed_write - write with deadline */ -int timed_write(int fd, void *buf, unsigned len, +ssize_t timed_write(int fd, void *buf, size_t len, int timeout, void *unused_context) { - int ret; + ssize_t ret; /* * Wait for a limited amount of time for something to happen. If nothing diff --git a/postfix/src/util/trigger.h b/postfix/src/util/trigger.h index ffcf63c52..1f1548229 100644 --- a/postfix/src/util/trigger.h +++ b/postfix/src/util/trigger.h @@ -14,10 +14,10 @@ /* * External interface. */ -extern int unix_trigger(const char *, const char *, int, int); -extern int inet_trigger(const char *, const char *, int, int); -extern int fifo_trigger(const char *, const char *, int, int); -extern int stream_trigger(const char *, const char *, int, int); +extern int unix_trigger(const char *, const char *, ssize_t, int); +extern int inet_trigger(const char *, const char *, ssize_t, int); +extern int fifo_trigger(const char *, const char *, ssize_t, int); +extern int stream_trigger(const char *, const char *, ssize_t, int); /* LICENSE /* .ad diff --git a/postfix/src/util/unescape.c b/postfix/src/util/unescape.c index b8dc3ca80..ef76d6d64 100644 --- a/postfix/src/util/unescape.c +++ b/postfix/src/util/unescape.c @@ -123,6 +123,7 @@ VSTRING *unescape(VSTRING *result, const char *data) #ifdef TEST +#include #include int main(int unused_argc, char **unused_argv) diff --git a/postfix/src/util/unix_trigger.c b/postfix/src/util/unix_trigger.c index 6a3b19160..9c4cb8b65 100644 --- a/postfix/src/util/unix_trigger.c +++ b/postfix/src/util/unix_trigger.c @@ -9,7 +9,7 @@ /* int unix_trigger(service, buf, len, timeout) /* const char *service; /* const char *buf; -/* int len; +/* ssize_t len; /* int timeout; /* DESCRIPTION /* unix_trigger() wakes up the named UNIX-domain server by making @@ -87,7 +87,7 @@ static void unix_trigger_event(int event, char *context) /* unix_trigger - wakeup UNIX-domain server */ -int unix_trigger(const char *service, const char *buf, int len, int timeout) +int unix_trigger(const char *service, const char *buf, ssize_t len, int timeout) { char *myname = "unix_trigger"; struct unix_trigger *up; diff --git a/postfix/src/util/vbuf.c b/postfix/src/util/vbuf.c index 81019e83b..22eaffbc5 100644 --- a/postfix/src/util/vbuf.c +++ b/postfix/src/util/vbuf.c @@ -15,21 +15,21 @@ /* /* int VBUF_SPACE(bp, len) /* VBUF *bp; -/* int len; +/* ssize_t len; /* /* int vbuf_unget(bp, ch) /* VBUF *bp; /* int ch; /* -/* int vbuf_read(bp, buf, len) +/* ssize_t vbuf_read(bp, buf, len) /* VBUF *bp; /* char *buf; -/* int len; +/* ssize_t len; /* -/* int vbuf_write(bp, buf, len) +/* ssize_t vbuf_write(bp, buf, len) /* VBUF *bp; /* const char *buf; -/* int len; +/* ssize_t len; /* /* int vbuf_err(bp) /* VBUF *bp; @@ -101,7 +101,7 @@ /* /* int space(bp, len) /* VBUF *bp; -/* int len; +/* ssize_t len; /* APPLICATION CALLBACK DESCRIPTION /* .ad /* .fi @@ -166,11 +166,11 @@ int vbuf_put(VBUF *bp, int ch) /* vbuf_read - bulk read from buffer */ -int vbuf_read(VBUF *bp, char *buf, int len) +ssize_t vbuf_read(VBUF *bp, char *buf, ssize_t len) { - int count; + ssize_t count; char *cp; - int n; + ssize_t n; #if 0 for (count = 0; count < len; count++) @@ -192,11 +192,11 @@ int vbuf_read(VBUF *bp, char *buf, int len) /* vbuf_write - bulk write to buffer */ -int vbuf_write(VBUF *bp, const char *buf, int len) +ssize_t vbuf_write(VBUF *bp, const char *buf, ssize_t len) { - int count; + ssize_t count; const char *cp; - int n; + ssize_t n; #if 0 for (count = 0; count < len; count++) diff --git a/postfix/src/util/vbuf.h b/postfix/src/util/vbuf.h index 5c50f1a5d..d5f4a426c 100644 --- a/postfix/src/util/vbuf.h +++ b/postfix/src/util/vbuf.h @@ -26,18 +26,19 @@ * * This interface is pretty normal. With one exception: the number of bytes * left to read is negated. This is done so that we can change direction - * between reading and writing on the fly. + * between reading and writing on the fly. The alternative would be to use + * separate read and write counters per buffer. */ typedef struct VBUF VBUF; typedef int (*VBUF_GET_READY_FN) (VBUF *); typedef int (*VBUF_PUT_READY_FN) (VBUF *); -typedef int (*VBUF_SPACE_FN) (VBUF *, int); +typedef int (*VBUF_SPACE_FN) (VBUF *, ssize_t); struct VBUF { int flags; /* status, see below */ unsigned char *data; /* variable-length buffer */ - int len; /* buffer length */ - int cnt; /* bytes left to read/write */ + ssize_t len; /* buffer length */ + ssize_t cnt; /* bytes left to read/write */ unsigned char *ptr; /* read/write position */ VBUF_GET_READY_FN get_ready; /* read buffer empty action */ VBUF_PUT_READY_FN put_ready; /* write buffer full action */ @@ -83,8 +84,8 @@ struct VBUF { extern int vbuf_get(VBUF *); extern int vbuf_put(VBUF *, int); extern int vbuf_unget(VBUF *, int); -extern int vbuf_read(VBUF *, char *, int); -extern int vbuf_write(VBUF *, const char *, int); +extern ssize_t vbuf_read(VBUF *, char *, ssize_t); +extern ssize_t vbuf_write(VBUF *, const char *, ssize_t); /* LICENSE /* .ad diff --git a/postfix/src/util/vstream.c b/postfix/src/util/vstream.c index 9b7cb1151..d395d3176 100644 --- a/postfix/src/util/vstream.c +++ b/postfix/src/util/vstream.c @@ -9,7 +9,7 @@ /* VSTREAM *vstream_fopen(path, flags, mode) /* char *path; /* int flags; -/* int mode; +/* mode_t mode; /* /* VSTREAM *vstream_fdopen(fd, flags) /* int fd; @@ -58,15 +58,15 @@ /* int vstream_fflush(stream) /* VSTREAM *stream; /* -/* int vstream_fread(stream, buf, len) +/* ssize_t vstream_fread(stream, buf, len) /* VSTREAM *stream; /* char *buf; -/* int len; +/* ssize_t len; /* -/* int vstream_fwrite(stream, buf, len) +/* ssize_t vstream_fwrite(stream, buf, len) /* VSTREAM *stream; /* char *buf; -/* int len; +/* ssize_t len; /* /* void vstream_control(stream, name, ...) /* VSTREAM *stream; @@ -97,7 +97,7 @@ /* char *format; /* va_list *ap; /* -/* int vstream_peek(stream) +/* ssize_t vstream_peek(stream) /* VSTREAM *stream; /* /* int vstream_setjmp(stream) @@ -220,10 +220,10 @@ /* value) pairs, terminated with VSTREAM_CTL_END. /* The following lists the names and the types of the corresponding /* value arguments. -/* .IP "VSTREAM_CTL_READ_FN (int (*)(int, void *, unsigned, int, void *))" +/* .IP "VSTREAM_CTL_READ_FN (ssize_t (*)(int, void *, size_t, int, void *))" /* The argument specifies an alternative for the timed_read(3) function, /* for example, a read function that performs decryption. -/* .IP "VSTREAM_CTL_WRITE_FN (int (*)(int, void *, unsigned, int, void *))" +/* .IP "VSTREAM_CTL_WRITE_FN (ssize_t (*)(int, void *, size_t, int, void *))" /* The argument specifies an alternative for the timed_write(3) function, /* for example, a write function that performs encryption. /* .IP "VSTREAM_CTL_CONTEXT (char *)" @@ -345,7 +345,7 @@ */ static int vstream_buf_get_ready(VBUF *); static int vstream_buf_put_ready(VBUF *); -static int vstream_buf_space(VBUF *, int); +static int vstream_buf_space(VBUF *, ssize_t); /* * Initialization of the three pre-defined streams. Pre-allocate a static @@ -459,9 +459,9 @@ static void vstream_buf_init(VBUF *bp, int flags) /* vstream_buf_alloc - allocate buffer memory */ -static void vstream_buf_alloc(VBUF *bp, int len) +static void vstream_buf_alloc(VBUF *bp, ssize_t len) { - int used = bp->ptr - bp->data; + ssize_t used = bp->ptr - bp->data; char *myname = "vstream_buf_alloc"; if (len < bp->len) @@ -494,15 +494,15 @@ static void vstream_buf_wipe(VBUF *bp) /* vstream_fflush_some - flush some buffered data */ -static int vstream_fflush_some(VSTREAM *stream, int to_flush) +static int vstream_fflush_some(VSTREAM *stream, ssize_t to_flush) { char *myname = "vstream_fflush_some"; VBUF *bp = &stream->buf; - int used; - int left_over; + ssize_t used; + ssize_t left_over; char *data; - int len; - int n; + ssize_t len; + ssize_t n; /* * Sanity checks. It is illegal to flush a read-only stream. Otherwise, @@ -527,9 +527,9 @@ static int vstream_fflush_some(VSTREAM *stream, int to_flush) left_over = used - to_flush; if (msg_verbose > 2 && stream != VSTREAM_ERR) - msg_info("%s: fd %d flush %d", myname, stream->fd, to_flush); + msg_info("%s: fd %d flush %ld", myname, stream->fd, (long) to_flush); if (to_flush < 0 || left_over < 0) - msg_panic("%s: bad to_flush %d", myname, to_flush); + msg_panic("%s: bad to_flush %ld", myname, (long) to_flush); if (to_flush < left_over) msg_panic("%s: to_flush < left_over", myname); if (to_flush == 0) @@ -552,7 +552,8 @@ static int vstream_fflush_some(VSTREAM *stream, int to_flush) if (stream->timeout) stream->iotime = time((time_t *) 0); if (msg_verbose > 2 && stream != VSTREAM_ERR && n != to_flush) - msg_info("%s: %d flushed %d/%d", myname, stream->fd, n, to_flush); + msg_info("%s: %d flushed %ld/%ld", myname, stream->fd, + (long) n, (long) to_flush); } if (bp->flags & VSTREAM_FLAG_SEEK) stream->offset += to_flush; @@ -609,7 +610,7 @@ static int vstream_buf_get_ready(VBUF *bp) { VSTREAM *stream = VBUF_TO_APPL(bp, VSTREAM, buf); char *myname = "vstream_buf_get_ready"; - int n; + ssize_t n; /* * Detect a change of I/O direction or position. If so, flush any @@ -687,7 +688,7 @@ static int vstream_buf_get_ready(VBUF *bp) if (stream->timeout) stream->iotime = time((time_t *) 0); if (msg_verbose > 2) - msg_info("%s: fd %d got %d", myname, stream->fd, n); + msg_info("%s: fd %d got %ld", myname, stream->fd, (long) n); bp->cnt = -n; bp->ptr = bp->data; if (bp->flags & VSTREAM_FLAG_SEEK) @@ -744,12 +745,12 @@ static int vstream_buf_put_ready(VBUF *bp) /* vstream_buf_space - reserve space ahead of time */ -static int vstream_buf_space(VBUF *bp, int want) +static int vstream_buf_space(VBUF *bp, ssize_t want) { VSTREAM *stream = VBUF_TO_APPL(bp, VSTREAM, buf); - int used; - int incr; - int shortage; + ssize_t used; + ssize_t incr; + ssize_t shortage; char *myname = "vstream_buf_space"; /* @@ -945,7 +946,7 @@ VSTREAM *vstream_fdopen(int fd, int flags) /* vstream_fopen - open buffered file stream */ -VSTREAM *vstream_fopen(const char *path, int flags, int mode) +VSTREAM *vstream_fopen(const char *path, int flags, mode_t mode) { VSTREAM *stream; int fd; @@ -1135,7 +1136,7 @@ VSTREAM *vstream_vfprintf(VSTREAM *vp, const char *format, va_list ap) /* vstream_peek - peek at a stream */ -int vstream_peek(VSTREAM *vp) +ssize_t vstream_peek(VSTREAM *vp) { if (vp->buf.flags & VSTREAM_FLAG_READ) { return (-vp->buf.cnt); diff --git a/postfix/src/util/vstream.h b/postfix/src/util/vstream.h index 2e3824a2a..013dc8e7f 100644 --- a/postfix/src/util/vstream.h +++ b/postfix/src/util/vstream.h @@ -29,7 +29,7 @@ * Simple buffered stream. The members of this structure are not part of the * official interface and can change without prior notice. */ -typedef int (*VSTREAM_FN) (int, void *, unsigned, int, void *); +typedef ssize_t(*VSTREAM_FN) (int, void *, size_t, int, void *); typedef int (*VSTREAM_WAITPID_FN) (pid_t, WAIT_STATUS_T *, int); typedef struct VSTREAM { @@ -71,7 +71,7 @@ extern VSTREAM vstream_fstd[]; /* pre-defined streams */ #define VSTREAM_BUFSIZE 4096 -extern VSTREAM *vstream_fopen(const char *, int, int); +extern VSTREAM *vstream_fopen(const char *, int, mode_t); extern int vstream_fclose(VSTREAM *); extern off_t vstream_fseek(VSTREAM *, off_t, int); extern off_t vstream_ftell(VSTREAM *); @@ -134,7 +134,7 @@ extern int vstream_pclose(VSTREAM *); extern VSTREAM *vstream_vfprintf(VSTREAM *, const char *, va_list); -extern int vstream_peek(VSTREAM *); +extern ssize_t vstream_peek(VSTREAM *); /* * Exception handling. We use pointer to jmp_buf to avoid a lot of unused diff --git a/postfix/src/util/vstream_popen.c b/postfix/src/util/vstream_popen.c index 1b947c49a..e8804d0a1 100644 --- a/postfix/src/util/vstream_popen.c +++ b/postfix/src/util/vstream_popen.c @@ -40,9 +40,9 @@ /* .IP "VSTREAM_POPEN_EXPORT (char **)" /* Null-terminated array of names of environment parameters /* that can be exported. By default, everything is exported. -/* .IP "VSTREAM_POPEN_UID (int)" +/* .IP "VSTREAM_POPEN_UID (uid_t)" /* The user ID to execute the command as. The user ID must be non-zero. -/* .IP "VSTREAM_POPEN_GID (int)" +/* .IP "VSTREAM_POPEN_GID (gid_t)" /* The group ID to execute the command as. The group ID must be non-zero. /* .IP "VSTREAM_POPEN_SHELL (char *)" /* The shell to use when executing the command specified with @@ -156,11 +156,11 @@ static void vstream_parse_args(VSTREAM_POPEN_ARGS *args, va_list ap) break; case VSTREAM_POPEN_UID: args->privileged = 1; - args->uid = va_arg(ap, int); + args->uid = va_arg(ap, uid_t); break; case VSTREAM_POPEN_GID: args->privileged = 1; - args->gid = va_arg(ap, int); + args->gid = va_arg(ap, gid_t); break; case VSTREAM_POPEN_ENV: args->env = va_arg(ap, char **); diff --git a/postfix/src/util/vstring.c b/postfix/src/util/vstring.c index dacd537e7..c4a4a9114 100644 --- a/postfix/src/util/vstring.c +++ b/postfix/src/util/vstring.c @@ -7,7 +7,7 @@ /* #include /* /* VSTRING *vstring_alloc(len) -/* int len; +/* ssize_t len; /* /* vstring_ctl(vp, type, value, ..., VSTRING_CTL_END) /* VSTRING *vp; @@ -19,7 +19,7 @@ /* char *vstring_str(vp) /* VSTRING *vp; /* -/* VSTRING *VSTRING_LEN(vp) +/* ssize_t VSTRING_LEN(vp) /* VSTRING *vp; /* /* char *vstring_end(vp) @@ -31,14 +31,14 @@ /* /* int VSTRING_SPACE(vp, len) /* VSTRING *vp; -/* int len; +/* ssize_t len; /* -/* int vstring_avail(vp) +/* ssize_t vstring_avail(vp) /* VSTRING *vp; /* /* VSTRING *vstring_truncate(vp, len) /* VSTRING *vp; -/* int len; +/* ssize_t len; /* /* void VSTRING_RESET(vp) /* VSTRING *vp; @@ -56,7 +56,7 @@ /* VSTRING *vstring_strncpy(vp, src, len) /* VSTRING *vp; /* const char *src; -/* int len; +/* ssize_t len; /* /* VSTRING *vstring_strcat(vp, src) /* VSTRING *vp; @@ -65,17 +65,17 @@ /* VSTRING *vstring_strncat(vp, src, len) /* VSTRING *vp; /* const char *src; -/* int len; +/* ssize_t len; /* /* VSTRING *vstring_memcpy(vp, src, len) /* VSTRING *vp; /* const char *src; -/* int len; +/* ssize_t len; /* /* VSTRING *vstring_memcat(vp, src, len) /* VSTRING *vp; /* const char *src; -/* int len; +/* ssize_t len; /* /* char *vstring_memchr(vp, ch) /* VSTRING *vp; @@ -84,7 +84,7 @@ /* VSTRING *vstring_prepend(vp, src, len) /* VSTRING *vp; /* const char *src; -/* int len; +/* ssize_t len; /* /* VSTRING *vstring_sprintf(vp, format, ...) /* VSTRING *vp; @@ -128,7 +128,7 @@ /* The function takes a VSTRING pointer and a list of zero /* or more (name,value) pairs. The expected value type /* depends on the specified name. The value name codes are: -/* .IP "VSTRING_CTL_MAXLEN (int)" +/* .IP "VSTRING_CTL_MAXLEN (ssize_t)" /* Specifies a hard upper limit on a string's length. When the /* length would be exceeded, the program simulates a memory /* allocation problem (i.e. it terminates through msg_fatal()). @@ -208,7 +208,7 @@ /* /* vstring_memchr() locates a byte in a variable-length string. /* -/* vstring_prepend() prepends a buffer content to a variable-length +/* vstring_prepend() prepends a buffer content to a variable-length /* string. The result is null-terminated. /* /* vstring_sprintf() produces a formatted string according to its @@ -271,10 +271,10 @@ /* vstring_extend - variable-length string buffer extension policy */ -static void vstring_extend(VBUF *bp, int incr) +static void vstring_extend(VBUF *bp, ssize_t incr) { - unsigned used = bp->ptr - bp->data; - int new_len; + size_t used = bp->ptr - bp->data; + ssize_t new_len; /* * Note: vp->vbuf.len is the current buffer size (both on entry and on @@ -282,8 +282,13 @@ static void vstring_extend(VBUF *bp, int incr) * size to avoid silly little buffer increments. With really large * strings we might want to abandon the length doubling strategy, and go * to fixed increments. + * + * The length overflow tests here and in vstring_alloc() should protect us + * against all length overflow problems within vstring library routines. */ new_len = bp->len + (bp->len > incr ? bp->len : incr); + if (new_len < 0) + msg_fatal("vstring_extend: length overflow"); bp->data = (unsigned char *) myrealloc((char *) bp->data, new_len); bp->len = new_len; bp->ptr = bp->data + used; @@ -307,12 +312,12 @@ static int vstring_buf_put_ready(VBUF *bp) /* vstring_buf_space - vbuf callback to reserve space */ -static int vstring_buf_space(VBUF *bp, int len) +static int vstring_buf_space(VBUF *bp, ssize_t len) { - int need; + ssize_t need; if (len < 0) - msg_panic("vstring_buf_space: bad length %d", len); + msg_panic("vstring_buf_space: bad length %ld", (long) len); if ((need = len - bp->cnt) > 0) vstring_extend(bp, need); return (0); @@ -320,12 +325,12 @@ static int vstring_buf_space(VBUF *bp, int len) /* vstring_alloc - create variable-length string */ -VSTRING *vstring_alloc(int len) +VSTRING *vstring_alloc(ssize_t len) { VSTRING *vp; if (len < 1) - msg_panic("vstring_alloc: bad length %d", len); + msg_panic("vstring_alloc: bad length %ld", (long) len); vp = (VSTRING *) mymalloc(sizeof(*vp)); vp->vbuf.flags = 0; vp->vbuf.len = 0; @@ -363,9 +368,9 @@ void vstring_ctl(VSTRING *vp,...) default: msg_panic("vstring_ctl: unknown code: %d", code); case VSTRING_CTL_MAXLEN: - vp->maxlen = va_arg(ap, int); + vp->maxlen = va_arg(ap, ssize_t); if (vp->maxlen < 0) - msg_panic("vstring_ctl: bad max length %d", vp->maxlen); + msg_panic("vstring_ctl: bad max length %ld", (long) vp->maxlen); break; } } @@ -374,10 +379,10 @@ void vstring_ctl(VSTRING *vp,...) /* vstring_truncate - truncate string */ -VSTRING *vstring_truncate(VSTRING *vp, int len) +VSTRING *vstring_truncate(VSTRING *vp, ssize_t len) { if (len < 0) - msg_panic("vstring_truncate: bad length %d", len); + msg_panic("vstring_truncate: bad length %ld", (long) len); if (len < VSTRING_LEN(vp)) VSTRING_AT_OFFSET(vp, len); return (vp); @@ -399,7 +404,7 @@ VSTRING *vstring_strcpy(VSTRING *vp, const char *src) /* vstring_strncpy - copy string of limited length */ -VSTRING *vstring_strncpy(VSTRING *vp, const char *src, int len) +VSTRING *vstring_strncpy(VSTRING *vp, const char *src, ssize_t len) { VSTRING_RESET(vp); @@ -425,7 +430,7 @@ VSTRING *vstring_strcat(VSTRING *vp, const char *src) /* vstring_strncat - append string of limited length */ -VSTRING *vstring_strncat(VSTRING *vp, const char *src, int len) +VSTRING *vstring_strncat(VSTRING *vp, const char *src, ssize_t len) { while (len-- > 0 && *src) { VSTRING_ADDCH(vp, *src); @@ -437,7 +442,7 @@ VSTRING *vstring_strncat(VSTRING *vp, const char *src, int len) /* vstring_memcpy - copy buffer of limited length */ -VSTRING *vstring_memcpy(VSTRING *vp, const char *src, int len) +VSTRING *vstring_memcpy(VSTRING *vp, const char *src, ssize_t len) { VSTRING_RESET(vp); @@ -449,7 +454,7 @@ VSTRING *vstring_memcpy(VSTRING *vp, const char *src, int len) /* vstring_memcat - append buffer of limited length */ -VSTRING *vstring_memcat(VSTRING *vp, const char *src, int len) +VSTRING *vstring_memcat(VSTRING *vp, const char *src, ssize_t len) { VSTRING_SPACE(vp, len); memcpy(vstring_end(vp), src, len); @@ -472,15 +477,15 @@ char *vstring_memchr(VSTRING *vp, int ch) /* vstring_prepend - prepend text to string */ -VSTRING *vstring_prepend(VSTRING *vp, const char *buf, int len) +VSTRING *vstring_prepend(VSTRING *vp, const char *buf, ssize_t len) { - int new_len; + ssize_t new_len; /* * Sanity check. */ if (len < 0) - msg_panic("vstring_prepend: bad length %d", len); + msg_panic("vstring_prepend: bad length %ld", (long) len); /* * Move the existing content and copy the new content. @@ -511,7 +516,7 @@ char *vstring_export(VSTRING *vp) VSTRING *vstring_import(char *str) { VSTRING *vp; - int len; + ssize_t len; vp = (VSTRING *) mymalloc(sizeof(*vp)); len = strlen(str); @@ -567,11 +572,11 @@ VSTRING *vstring_vsprintf_append(VSTRING *vp, const char *format, va_list ap) /* vstring_sprintf_prepend - format + prepend string, vsprintf-like interface */ -VSTRING *vstring_sprintf_prepend(VSTRING *vp, const char *format, ...) +VSTRING *vstring_sprintf_prepend(VSTRING *vp, const char *format,...) { va_list ap; - int old_len = VSTRING_LEN(vp); - int result_len; + ssize_t old_len = VSTRING_LEN(vp); + ssize_t result_len; /* Construct: old|new|free */ va_start(ap, format); @@ -606,6 +611,7 @@ int main(int argc, char **argv) } printf("argv concatenated: %s\n", vstring_str(vp)); vstring_free(vp); + return (0); } #endif diff --git a/postfix/src/util/vstring.h b/postfix/src/util/vstring.h index 085739126..3c792005e 100644 --- a/postfix/src/util/vstring.h +++ b/postfix/src/util/vstring.h @@ -27,21 +27,21 @@ */ typedef struct VSTRING { VBUF vbuf; - int maxlen; + ssize_t maxlen; } VSTRING; -extern VSTRING *vstring_alloc(int); +extern VSTRING *vstring_alloc(ssize_t); extern void vstring_ctl(VSTRING *,...); -extern VSTRING *vstring_truncate(VSTRING *, int); +extern VSTRING *vstring_truncate(VSTRING *, ssize_t); extern VSTRING *vstring_free(VSTRING *); extern VSTRING *vstring_strcpy(VSTRING *, const char *); -extern VSTRING *vstring_strncpy(VSTRING *, const char *, int); +extern VSTRING *vstring_strncpy(VSTRING *, const char *, ssize_t); extern VSTRING *vstring_strcat(VSTRING *, const char *); -extern VSTRING *vstring_strncat(VSTRING *, const char *, int); -extern VSTRING *vstring_memcpy(VSTRING *, const char *, int); -extern VSTRING *vstring_memcat(VSTRING *, const char *, int); +extern VSTRING *vstring_strncat(VSTRING *, const char *, ssize_t); +extern VSTRING *vstring_memcpy(VSTRING *, const char *, ssize_t); +extern VSTRING *vstring_memcat(VSTRING *, const char *, ssize_t); extern char *vstring_memchr(VSTRING *, int); -extern VSTRING *vstring_prepend(VSTRING *, const char *, int); +extern VSTRING *vstring_prepend(VSTRING *, const char *, ssize_t); extern VSTRING *PRINTFLIKE(2, 3) vstring_sprintf(VSTRING *, const char *,...); extern VSTRING *PRINTFLIKE(2, 3) vstring_sprintf_append(VSTRING *, const char *,...); extern VSTRING *PRINTFLIKE(2, 3) vstring_sprintf_prepend(VSTRING *, const char *, ...); @@ -56,7 +56,7 @@ extern VSTRING *vstring_import(char *); */ #define VSTRING_SPACE(vp, len) ((vp)->vbuf.space(&(vp)->vbuf, len)) #define vstring_str(vp) ((char *) (vp)->vbuf.data) -#define VSTRING_LEN(vp) ((vp)->vbuf.ptr - (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) \ VSTRING_SPACE((vp),1); \ diff --git a/postfix/src/util/vstring_vstream.c b/postfix/src/util/vstring_vstream.c index e19fd3822..7c7842733 100644 --- a/postfix/src/util/vstring_vstream.c +++ b/postfix/src/util/vstring_vstream.c @@ -196,6 +196,7 @@ int main(void) vstream_fclose(fp); vstream_fflush(VSTREAM_OUT); vstring_free(vp); + return (0); } #endif diff --git a/postfix/src/util/watchdog.c b/postfix/src/util/watchdog.c index 1c0c088cc..9b4f5ebfa 100644 --- a/postfix/src/util/watchdog.c +++ b/postfix/src/util/watchdog.c @@ -245,6 +245,7 @@ int main(int unused_argc, char **unused_argv) watchdog_pat(); } while (VSTREAM_GETCHAR() != VSTREAM_EOF); watchdog_destroy(wp); + return (0); } #endif diff --git a/postfix/src/util/write_buf.c b/postfix/src/util/write_buf.c index c6b0ad792..2bce6c972 100644 --- a/postfix/src/util/write_buf.c +++ b/postfix/src/util/write_buf.c @@ -6,10 +6,10 @@ /* SYNOPSIS /* #include /* -/* int write_buf(fd, buf, len, timeout) +/* ssize_t write_buf(fd, buf, len, timeout) /* int fd; /* const char *buf; -/* int len; +/* ssize_t len; /* int timeout; /* DESCRIPTION /* write_buf() writes a buffer to the named stream in as many @@ -54,9 +54,9 @@ /* write_buf - write buffer or bust */ -int write_buf(int fd, const char *buf, int len, int timeout) +ssize_t write_buf(int fd, const char *buf, ssize_t len, int timeout) { - int count; + ssize_t count; while (len > 0) { if (timeout > 0 && write_wait(fd, timeout) < 0) diff --git a/postfix/src/verify/verify.c b/postfix/src/verify/verify.c index 6a61ad99b..0ae579b97 100644 --- a/postfix/src/verify/verify.c +++ b/postfix/src/verify/verify.c @@ -370,7 +370,6 @@ static void verify_query_service(VSTREAM *client_stream) long probed; long updated; char *text; - VSTREAM *post; if (attr_scan(client_stream, ATTR_FLAG_STRICT, ATTR_TYPE_STR, MAIL_ATTR_ADDR, addr,