Mercurial > dovecot > core-2.2
changeset 184:4223b9ed0c80 HEAD
move size_t fixes
line wrap: on
line diff
--- a/src/auth/auth-digest-md5.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/auth/auth-digest-md5.c Sun Sep 08 17:39:05 2002 +0300 @@ -441,7 +441,7 @@ } static int parse_digest_response(AuthData *auth, const char *data, - unsigned int size, const char **error) + size_t size, const char **error) { char *copy, *key, *value; int failed;
--- a/src/auth/auth-interface.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/auth/auth-interface.h Sun Sep 08 17:39:05 2002 +0300 @@ -52,7 +52,7 @@ unsigned char cookie[AUTH_COOKIE_SIZE]; int id; /* AuthReplyData.id will contain this value */ - unsigned int data_size; + size_t data_size; /* unsigned char data[]; */ } AuthContinuedRequestData; @@ -62,7 +62,7 @@ unsigned char cookie[AUTH_COOKIE_SIZE]; AuthResult result; - unsigned int data_size; + size_t data_size; /* unsigned char data[]; */ } AuthReplyData;
--- a/src/auth/auth-plain.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/auth/auth-plain.c Sun Sep 08 17:39:05 2002 +0300 @@ -13,7 +13,7 @@ AuthCookieReplyData *cookie_reply = cookie->context; AuthReplyData reply; const char *user, *pass; - unsigned int i, count; + size_t i, count; /* initialize reply */ memset(&reply, 0, sizeof(reply));
--- a/src/auth/login-connection.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/auth/login-connection.c Sun Sep 08 17:39:05 2002 +0300 @@ -45,7 +45,7 @@ { LoginConnection *conn = context; unsigned char *data; - unsigned int size; + size_t size; switch (io_buffer_read(conn->inbuf)) { case 0:
--- a/src/auth/userinfo-passwd-file.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/auth/userinfo-passwd-file.c Sun Sep 08 17:39:05 2002 +0300 @@ -193,8 +193,7 @@ /* password[type] - we're being libpam-pwdfile compatible here. it uses 13 = DES and 34 = MD5. We add 56 = Digest-MD5. */ - pu->password = p_strndup(pw->pool, pass, - (unsigned int) (p-pass)); + pu->password = p_strndup(pw->pool, pass, (size_t) (p-pass)); if (p[1] == '3' && p[2] == '4') { pu->password_type = PASSWORD_MD5; str_lcase(pu->password);
--- a/src/imap/client.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/imap/client.c Sun Sep 08 17:39:05 2002 +0300 @@ -114,7 +114,7 @@ void client_send_line(Client *client, const char *data) { unsigned char *buf; - unsigned int len; + size_t len; if (client->outbuf->closed) return; @@ -141,7 +141,7 @@ { const char *tag = client->cmd_tag; unsigned char *buf; - unsigned int taglen, len; + size_t taglen, len; if (client->outbuf->closed) return; @@ -259,7 +259,7 @@ static int client_skip_line(Client *client) { unsigned char *data; - unsigned int i, data_size; + size_t i, data_size; /* get the beginning of data in input buffer */ data = io_buffer_get_data(client->inbuf, &data_size);
--- a/src/imap/cmd-append.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/imap/cmd-append.c Sun Sep 08 17:39:05 2002 +0300 @@ -11,7 +11,7 @@ set when successful. */ static int validate_args(Client *client, const char **mailbox, ImapArgList **flags, const char **internal_date, - unsigned int *msg_size, unsigned int count) + uoff_t *msg_size, unsigned int count) { ImapArg *args; @@ -76,7 +76,7 @@ time_t internal_date; const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT]; const char *mailbox, *internal_date_str; - unsigned int msg_size; + uoff_t msg_size; int failed; /* <mailbox> [<flags>] [<internal date>] <message literal> */
--- a/src/lib-imap/imap-envelope.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-imap/imap-envelope.c Sun Sep 08 17:39:05 2002 +0300 @@ -21,10 +21,9 @@ (c) == '<' || (c) == '>' || (c) == '(' || (c) == ')' || \ (c) == '[' || (c) == ']' || (c) == '=') -static unsigned int next_token_quoted(const char *value, unsigned int len, - int *need_qp) +static size_t next_token_quoted(const char *value, size_t len, int *need_qp) { - unsigned int i; + size_t i; i_assert(value[0] == '"'); @@ -43,10 +42,9 @@ return i; } -static unsigned int next_token(const char *value, unsigned int len, - int *need_qp, int qp_on) +static size_t next_token(const char *value, size_t len, int *need_qp, int qp_on) { - unsigned int i = 0; + size_t i = 0; if (value[0] == '"') return next_token_quoted(value, len, need_qp); @@ -83,10 +81,9 @@ return i; } -static void append_quoted_qp(TempString *str, const char *value, - unsigned int len) +static void append_quoted_qp(TempString *str, const char *value, size_t len) { - unsigned int i; + size_t i; unsigned char c; /* do this the easy way, it's already broken behaviour to leave the @@ -110,9 +107,9 @@ } } -static void append_quoted(TempString *str, const char *value, unsigned int len) +static void append_quoted(TempString *str, const char *value, size_t len) { - unsigned int i; + size_t i; for (i = 0; i < len; i++) { if (value[i] == '\\' || value[i] == '"') @@ -122,10 +119,10 @@ } /* does two things: 1) escape '\' and '"' characters, 2) 8bit text -> QP */ -static TempString *get_quoted_str(const char *value, unsigned int value_len) +static TempString *get_quoted_str(const char *value, size_t value_len) { TempString *str; - unsigned int token_len; + size_t token_len; int qp, need_qp; str = t_string_new(value_len * 2); @@ -172,7 +169,7 @@ get_quoted_str(value, strlen(value))->str; } -static char *quote_value(Pool pool, const char *value, unsigned int value_len) +static char *quote_value(Pool pool, const char *value, size_t value_len) { TempString *str; @@ -181,7 +178,7 @@ } static Rfc822Address *parse_address(Pool pool, const char *value, - unsigned int value_len) + size_t value_len) { Rfc822Address *ret; @@ -193,7 +190,7 @@ void imap_envelope_parse_header(Pool pool, MessagePartEnvelopeData **data, const char *name, - const char *value, unsigned int value_len) + const char *value, size_t value_len) { if (*data == NULL) { *data = p_new(pool, MessagePartEnvelopeData, 1);
--- a/src/lib-imap/imap-envelope.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-imap/imap-envelope.h Sun Sep 08 17:39:05 2002 +0300 @@ -5,7 +5,7 @@ void imap_envelope_parse_header(Pool pool, MessagePartEnvelopeData **data, const char *name, - const char *value, unsigned int value_len); + const char *value, size_t value_len); void imap_envelope_write_part_data(MessagePartEnvelopeData *data, TempString *str);
--- a/src/lib-imap/imap-message-cache.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-imap/imap-message-cache.c Sun Sep 08 17:39:05 2002 +0300 @@ -142,8 +142,8 @@ } static void parse_envelope_header(MessagePart *part, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context) { CachedMessage *msg = context; @@ -426,7 +426,7 @@ MessageSize *partial, MessageSize *dest) { unsigned char *msg; - unsigned int size; + size_t size; int cr_skipped; /* see if we can use the existing partial */
--- a/src/lib-imap/imap-parser.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-imap/imap-parser.c Sun Sep 08 17:39:05 2002 +0300 @@ -23,7 +23,7 @@ ImapArg *args; ArgParseType cur_type; - unsigned int cur_pos; + size_t cur_pos; ImapArg *cur_arg; ImapArg *cur_list_arg; /* argument which contains current list */ @@ -75,9 +75,9 @@ } static int imap_parser_skip_whitespace(ImapParser *parser, char **data, - unsigned int *data_size) + size_t *data_size) { - unsigned int i; + size_t i; for (i = parser->cur_pos; i < *data_size; i++) { if ((*data)[i] != ' ') @@ -149,7 +149,7 @@ } static void imap_parser_save_arg(ImapParser *parser, char *data, - unsigned int lastpos) + size_t lastpos) { ImapArg *arg; @@ -200,9 +200,9 @@ } static int imap_parser_read_atom(ImapParser *parser, char *data, - unsigned int data_size) + size_t data_size) { - unsigned int i; + size_t i; /* read until we've found space, CR or LF. Data inside '[' and ']' characters are an exception though, allow spaces inside them. */ @@ -235,9 +235,9 @@ } static int imap_parser_read_string(ImapParser *parser, char *data, - unsigned int data_size) + size_t data_size) { - unsigned int i; + size_t i; /* read until we've found non-escaped ", CR or LF */ for (i = parser->cur_pos; i < data_size; i++) { @@ -277,9 +277,9 @@ } static int imap_parser_read_literal(ImapParser *parser, char *data, - unsigned int data_size) + size_t data_size) { - unsigned int i, prev_size; + size_t i, prev_size; /* expecting digits + "}" */ for (i = parser->cur_pos; i < data_size; i++) { @@ -318,7 +318,7 @@ } static int imap_parser_read_literal_data(ImapParser *parser, char *data, - unsigned int data_size) + size_t data_size) { if (parser->literal_skip_crlf) { /* skip \r\n or \n, anything else gives an error */ @@ -344,8 +344,8 @@ /* now we just wait until we've read enough data */ if (data_size >= parser->literal_size) { imap_parser_save_arg(parser, data, - parser->literal_size); - parser->cur_pos = (unsigned int) parser->literal_size; + (size_t)parser->literal_size); + parser->cur_pos = (size_t) parser->literal_size; } } else { /* we want to save only literal size, not the literal itself. */ @@ -360,7 +360,7 @@ static int imap_parser_read_arg(ImapParser *parser, ImapArg *root_arg) { char *data; - unsigned int data_size; + size_t data_size; data = (char *) io_buffer_get_data(parser->inbuf, &data_size); if (data_size == 0) @@ -488,7 +488,7 @@ const char *imap_parser_read_word(ImapParser *parser) { unsigned char *data; - unsigned int i, data_size; + size_t i, data_size; /* get the beginning of data in input buffer */ data = io_buffer_get_data(parser->inbuf, &data_size); @@ -509,7 +509,7 @@ const char *imap_parser_read_line(ImapParser *parser) { unsigned char *data; - unsigned int i, data_size; + size_t i, data_size; /* get the beginning of data in input buffer */ data = io_buffer_get_data(parser->inbuf, &data_size);
--- a/src/lib-imap/imap-util.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-imap/imap-util.c Sun Sep 08 17:39:05 2002 +0300 @@ -48,7 +48,7 @@ const char *imap_escape(const char *str) { char *ret, *p; - unsigned int i, esc; + size_t i, esc; /* get length of string and number of chars to escape */ esc = 0;
--- a/src/lib-index/mail-custom-flags.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mail-custom-flags.c Sun Sep 08 17:39:05 2002 +0300 @@ -305,7 +305,7 @@ static int custom_flags_add(MailCustomFlags *mcf, int idx, const char *name) { const char *buf; - unsigned int len; + size_t len; off_t pos; i_assert(idx < MAIL_CUSTOM_FLAGS_COUNT);
--- a/src/lib-index/mail-hash.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mail-hash.c Sun Sep 08 17:39:05 2002 +0300 @@ -79,8 +79,8 @@ if it was only partially written. */ hash->header = NULL; index_set_error(hash->index, "Corrupted hash file %s: " - "Invalid file size %lu", hash->filepath, - (unsigned long) hash->mmap_length); + "Invalid file size %"PRIuSIZE_T"", + hash->filepath, hash->mmap_length); return FALSE; } @@ -195,7 +195,6 @@ static int file_set_size(int fd, off_t size) { char block[1024]; - unsigned int i, full_blocks; int ret, old_errno; off_t pos; @@ -224,16 +223,15 @@ size -= pos; memset(block, 0, sizeof(block)); - /* write in 1kb blocks */ - full_blocks = size / sizeof(block); - for (i = 0; i < full_blocks; i++) { + while (size > sizeof(block)) { + /* write in 1kb blocks */ if (write_full(fd, block, sizeof(block)) < 0) return FALSE; + size -= sizeof(block); } /* write the remainder */ - i = size % sizeof(block); - return i == 0 ? TRUE : write_full(fd, block, i) == 0; + return write_full(fd, block, (size_t)size) == 0; } static int hash_rebuild_to_file(MailIndex *index, int fd, @@ -253,9 +251,8 @@ /* fill the file with zeros */ new_size = sizeof(MailHashHeader) + hash_size * sizeof(MailHashRecord); if (!file_set_size(fd, (off_t)new_size)) { - index_set_error(index, - "Failed to fill temp hash to size %lu: %m", - (unsigned long) new_size); + index_set_error(index, "Failed to fill temp hash to size " + "%"PRIuSIZE_T": %m", new_size); return FALSE; }
--- a/src/lib-index/mail-index-data.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mail-index-data.c Sun Sep 08 17:39:05 2002 +0300 @@ -31,7 +31,7 @@ unsigned int dirty_mmap:1; }; -static int mmap_update(MailIndexData *data, uoff_t pos, unsigned int size) +static int mmap_update(MailIndexData *data, uoff_t pos, size_t size) { if (!data->dirty_mmap || (size != 0 && pos <= data->mmap_length && pos+size <= data->mmap_length)) @@ -235,8 +235,7 @@ return (uoff_t)pos; } -int mail_index_data_add_deleted_space(MailIndexData *data, - unsigned int data_size) +int mail_index_data_add_deleted_space(MailIndexData *data, size_t data_size) { MailIndexDataHeader *hdr; uoff_t max_del_space; @@ -300,10 +299,9 @@ INDEX_MARK_CORRUPTED(data->index); index_set_error(data->index, "Error in data file %s: " "Given data size larger than file size " - "(%lu + %u > %lu)", data->filepath, - (unsigned long) index_rec->data_position, - index_rec->data_size, - (unsigned long) data->mmap_length); + "(%"PRIuUOFF_T" + %u > %"PRIuSIZE_T")", + data->filepath, index_rec->data_position, + index_rec->data_size, data->mmap_length); return NULL; } @@ -321,9 +319,8 @@ INDEX_MARK_CORRUPTED(data->index); index_set_error(data->index, "Error in data file %s: " "Field size points outside file " - "(%lu / %lu)", data->filepath, - (unsigned long) pos, - (unsigned long) max_pos); + "(%"PRIuUOFF_T" / %"PRIuUOFF_T")", + data->filepath, pos, max_pos); break; } @@ -366,10 +363,9 @@ INDEX_MARK_CORRUPTED(data->index); index_set_error(data->index, "Error in data file %s: " "Field size points outside file " - "(%lu + %u > %lu)", data->filepath, - (unsigned long) pos, - rec->full_field_size, - (unsigned long) max_pos); + "(%"PRIuUOFF_T" + %u > %"PRIuUOFF_T")", + data->filepath, pos, rec->full_field_size, + max_pos); return NULL; } @@ -399,15 +395,15 @@ INDEX_MARK_CORRUPTED(data->index); index_set_error(data->index, "Error in data file %s: " - "Missing \\0 with field %u (%lu)", + "Missing \\0 with field %u (%"PRIuUOFF_T")", data->filepath, rec->field, - (unsigned long) DATA_FILE_POSITION(data, rec)); + DATA_FILE_POSITION(data, rec)); return FALSE; } void *mail_index_data_get_mmaped(MailIndexData *data, size_t *size) { - if (!mmap_update(data, 0, UINT_MAX)) + if (!mmap_update(data, 0, 0)) return NULL; *size = data->mmap_length;
--- a/src/lib-index/mail-index-data.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mail-index-data.h Sun Sep 08 17:39:05 2002 +0300 @@ -20,8 +20,7 @@ size_t size); /* Increase header->deleted_space field */ -int mail_index_data_add_deleted_space(MailIndexData *data, - unsigned int data_size); +int mail_index_data_add_deleted_space(MailIndexData *data, size_t data_size); /* Synchronize the data into disk */ int mail_index_data_sync_file(MailIndexData *data);
--- a/src/lib-index/mail-index-update.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mail-index-update.c Sun Sep 08 17:39:05 2002 +0300 @@ -176,7 +176,7 @@ "full_field_size points outside " "data_size (field %d?)", update->index->filepath, - rec == NULL ? -1 : rec->field); + rec == NULL ? -1 : (int)rec->field); update->index->header->flags |= MAIL_INDEX_FLAG_REBUILD; return FALSE; } @@ -278,7 +278,13 @@ void mail_index_update_field(MailIndexUpdate *update, MailField field, const char *value, unsigned int extra_space) { - update_field_full(update, field, value, strlen(value)+1, extra_space); + size_t len; + + len = strlen(value); + i_assert(len < SSIZE_T_MAX); + + update_field_full(update, field, value, + (unsigned int)len + 1, extra_space); } void mail_index_update_field_raw(MailIndexUpdate *update, MailField field, @@ -287,7 +293,7 @@ update_field_full(update, field, value, size, 0); } -static MailField mail_header_get_field(const char *str, unsigned int len) +static MailField mail_header_get_field(const char *str, size_t len) { if (len == 7 && strncasecmp(str, "Subject", 7) == 0) return FIELD_TYPE_SUBJECT; @@ -336,8 +342,8 @@ } HeaderUpdateContext; static void update_header_func(MessagePart *part, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context) { HeaderUpdateContext *ctx = context;
--- a/src/lib-index/mail-index.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mail-index.h Sun Sep 08 17:39:05 2002 +0300 @@ -144,6 +144,8 @@ uoff_t data_position; unsigned int data_size; + + unsigned int alignment; }; struct _MailIndexDataRecord {
--- a/src/lib-index/maildir/maildir-build.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/maildir/maildir-build.c Sun Sep 08 17:39:05 2002 +0300 @@ -45,9 +45,8 @@ if (st.st_size < 10) { /* This cannot be a mail file - delete it */ - index_set_error(index, - "Invalid size %lu with mail in %s - deleted", - (unsigned long) st.st_size, path); + index_set_error(index, "Invalid size %"PRIuUOFF_T + " with mail in %s - deleted", st.st_size, path); (void)unlink(path); return TRUE; }
--- a/src/lib-index/mbox/mbox-append.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mbox/mbox-append.c Sun Sep 08 17:39:05 2002 +0300 @@ -26,7 +26,7 @@ static void mbox_read_message(IOBuffer *inbuf) { unsigned char *msg; - unsigned int i, size, startpos; + size_t i, size, startpos; int lastmsg; /* read until "[\r]\nFrom " is found */ @@ -83,7 +83,7 @@ time_t internal_date; uoff_t abs_start_offset, stop_offset, old_size; unsigned char *data, md5_digest[16]; - unsigned int size, pos; + size_t size, pos; /* get the From-line */ pos = 0;
--- a/src/lib-index/mbox/mbox-from.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mbox/mbox-from.c Sun Sep 08 17:39:05 2002 +0300 @@ -15,7 +15,7 @@ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -time_t mbox_from_parse_date(const char *msg, unsigned int size) +time_t mbox_from_parse_date(const char *msg, size_t size) { const char *msg_end; struct tm tm; @@ -95,7 +95,8 @@ { struct tm *tm; char *ret, *p; - unsigned int len, year; + size_t len; + int year; len = strlen(sender); ret = t_malloc(len + 24 + 1);
--- a/src/lib-index/mbox/mbox-index.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mbox/mbox-index.c Sun Sep 08 17:39:05 2002 +0300 @@ -18,10 +18,10 @@ ctx->custom_flags = mail_custom_flags_list_get(index->custom_flags); } -static MailFlags mbox_get_status_flags(const char *value, unsigned int len) +static MailFlags mbox_get_status_flags(const char *value, size_t len) { MailFlags flags; - unsigned int i; + size_t i; flags = 0; for (i = 0; i < len; i++) { @@ -48,7 +48,7 @@ } static void mbox_update_custom_flags(const char *value __attr_unused__, - unsigned int len __attr_unused__, + size_t len __attr_unused__, int index, void *context) { MailFlags *flags = context; @@ -58,7 +58,7 @@ } static MailFlags -mbox_get_keyword_flags(const char *value, unsigned int len, +mbox_get_keyword_flags(const char *value, size_t len, const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT]) { MailFlags flags; @@ -69,10 +69,10 @@ return flags; } -static void mbox_parse_imapbase(const char *value, unsigned int len, +static void mbox_parse_imapbase(const char *value, size_t len, MboxHeaderContext *ctx) { - unsigned int i, spaces; + size_t i, spaces; /* skip <uid validity> and <last uid> fields */ spaces = 0; @@ -99,8 +99,8 @@ } void mbox_header_func(MessagePart *part __attr_unused__, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context) { MboxHeaderContext *ctx = context; @@ -175,13 +175,13 @@ md5_update(&ctx->md5, value, value_len); } -void mbox_keywords_parse(const char *value, unsigned int len, +void mbox_keywords_parse(const char *value, size_t len, const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT], - void (*func)(const char *, unsigned int, int, void *), + void (*func)(const char *, size_t, int, void *), void *context) { - unsigned int custom_len[MAIL_CUSTOM_FLAGS_COUNT]; - unsigned int item_len; + size_t custom_len[MAIL_CUSTOM_FLAGS_COUNT]; + size_t item_len; int i; for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) { @@ -225,7 +225,7 @@ int mbox_skip_crlf(IOBuffer *inbuf) { unsigned char *data; - unsigned int size, pos; + size_t size, pos; pos = 0; while (io_buffer_read_data(inbuf, &data, &size, pos) >= 0) { @@ -256,7 +256,7 @@ uoff_t *offset) { const uoff_t *location; - unsigned int size; + size_t size; location = index->lookup_field_raw(index, rec, FIELD_TYPE_LOCATION, &size);
--- a/src/lib-index/mbox/mbox-index.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mbox/mbox-index.h Sun Sep 08 17:39:05 2002 +0300 @@ -16,12 +16,12 @@ void mbox_header_init_context(MboxHeaderContext *ctx, MailIndex *index); void mbox_header_func(MessagePart *part __attr_unused__, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context); -void mbox_keywords_parse(const char *value, unsigned int len, +void mbox_keywords_parse(const char *value, size_t len, const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT], - void (*func)(const char *, unsigned int, int, void *), + void (*func)(const char *, size_t, int, void *), void *context); int mbox_skip_crlf(IOBuffer *inbuf); int mbox_mail_get_start_offset(MailIndex *index, MailIndexRecord *rec, @@ -34,7 +34,7 @@ int mbox_index_append(MailIndex *index, IOBuffer *inbuf); -time_t mbox_from_parse_date(const char *msg, unsigned int size); +time_t mbox_from_parse_date(const char *msg, size_t size); const char *mbox_from_create(const char *sender, time_t time); int mbox_index_rewrite(MailIndex *index);
--- a/src/lib-index/mbox/mbox-rewrite.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-index/mbox/mbox-rewrite.c Sun Sep 08 17:39:05 2002 +0300 @@ -15,7 +15,6 @@ typedef struct { IOBuffer *outbuf; - unsigned int size; int failed; unsigned int seq; @@ -58,7 +57,7 @@ return TRUE; } -static const char *strip_chars(const char *value, unsigned int value_len, +static const char *strip_chars(const char *value, size_t value_len, const char *list) { /* leave only unknown flags, very likely none */ @@ -74,11 +73,11 @@ if (ret == p) return NULL; *p = '\0'; - t_buffer_alloc((unsigned int) (p-ret)+1); + t_buffer_alloc((size_t) (p-ret)+1); return ret; } -static void update_stripped_custom_flags(const char *value, unsigned int len, +static void update_stripped_custom_flags(const char *value, size_t len, int index, void *context) { TempString *str = context; @@ -91,7 +90,7 @@ } } -static const char *strip_custom_flags(const char *value, unsigned int len, +static const char *strip_custom_flags(const char *value, size_t len, MboxRewriteContext *ctx) { TempString *str; @@ -103,8 +102,8 @@ } static void header_func(MessagePart *part __attr_unused__, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context) { MboxRewriteContext *ctx = context; @@ -139,7 +138,6 @@ if (ctx->outbuf->closed) ctx->failed = TRUE; - ctx->size += name_len + 2 + value_len + 1; } }
--- a/src/lib-mail/message-parser.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/message-parser.c Sun Sep 08 17:39:05 2002 +0300 @@ -12,7 +12,7 @@ MessagePart *part; const char *boundary; - unsigned int len; + size_t len; } MessageBoundary; typedef struct { @@ -109,8 +109,8 @@ } static void parse_header_field(MessagePart *part, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context) { MessageParseContext *parse_ctx = context; @@ -263,7 +263,7 @@ static void message_skip_line(IOBuffer *inbuf, MessageSize *msg_size) { unsigned char *msg; - unsigned int i, size, startpos; + size_t i, size, startpos; startpos = 0; @@ -309,8 +309,8 @@ MessageHeaderFunc func, void *context) { unsigned char *msg; - unsigned int i, size, startpos, missing_cr_count; - unsigned int line_start, colon_pos, end_pos, name_len, value_len; + size_t i, size, startpos, missing_cr_count; + size_t line_start, colon_pos, end_pos, name_len, value_len; int ret; if (hdr_size != NULL) @@ -434,7 +434,7 @@ } static MessageBoundary *boundary_find(MessageBoundary *boundaries, - const char *msg, unsigned int len) + const char *msg, size_t len) { while (boundaries != NULL) { if (boundaries->len <= len && @@ -456,7 +456,7 @@ { MessageBoundary *boundary; unsigned char *msg; - unsigned int i, size, startpos, line_start, missing_cr_count; + size_t i, size, startpos, line_start, missing_cr_count; boundary = NULL; missing_cr_count = startpos = line_start = 0; @@ -572,7 +572,7 @@ { MessageBoundary *boundary; unsigned char *msg; - unsigned int size; + size_t size; int end_boundary; boundary = message_find_boundary(inbuf, boundaries,
--- a/src/lib-mail/message-parser.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/message-parser.h Sun Sep 08 17:39:05 2002 +0300 @@ -38,8 +38,8 @@ /* NOTE: name and value aren't \0-terminated */ typedef void (*MessageHeaderFunc)(MessagePart *part, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context); /* func is called for each field in message header. */
--- a/src/lib-mail/message-part-serialize.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/message-part-serialize.c Sun Sep 08 17:39:05 2002 +0300 @@ -35,10 +35,10 @@ static void message_part_serialize_part(MessagePart *part, unsigned int *children_count, SerializedMessagePart **spart_base, - unsigned int *pos, unsigned int *size) + size_t *pos, size_t *size) { SerializedMessagePart *spart; - unsigned int buf_size; + size_t buf_size; while (part != NULL) { /* make sure we have space */ @@ -79,10 +79,10 @@ } } -const void *message_part_serialize(MessagePart *part, unsigned int *size) +const void *message_part_serialize(MessagePart *part, size_t *size) { SerializedMessagePart *spart_base; - unsigned int pos, buf_size; + size_t pos, buf_size; buf_size = 32; spart_base = t_buffer_get(sizeof(SerializedMessagePart) * buf_size); @@ -98,7 +98,7 @@ static MessagePart * message_part_deserialize_part(Pool pool, MessagePart *parent, const SerializedMessagePart **spart_pos, - unsigned int *count, unsigned int child_count) + size_t *count, unsigned int child_count) { const SerializedMessagePart *spart; MessagePart *part, *first_part, **next_part; @@ -140,10 +140,10 @@ } MessagePart *message_part_deserialize(Pool pool, const void *data, - unsigned int size) + size_t size) { const SerializedMessagePart *spart; - unsigned int count; + size_t count; /* make sure it looks valid */ if (size == 0 || (size % sizeof(SerializedMessagePart)) != 0) @@ -151,16 +151,20 @@ spart = data; count = size / sizeof(SerializedMessagePart); - return message_part_deserialize_part(pool, NULL, &spart, &count, count); + if (count > UINT_MAX) + return NULL; + + return message_part_deserialize_part(pool, NULL, &spart, &count, + (unsigned int)count); } -int message_part_serialize_update_header(void *data, unsigned int size, +int message_part_serialize_update_header(void *data, size_t size, MessageSize *hdr_size) { SerializedMessagePart *spart = data; uoff_t first_pos; off_t pos_diff; - unsigned int i, count; + size_t i, count; /* make sure it looks valid */ if (size == 0 || (size % sizeof(SerializedMessagePart)) != 0) @@ -193,7 +197,7 @@ return TRUE; } -int message_part_deserialize_size(const void *data, unsigned int size, +int message_part_deserialize_size(const void *data, size_t size, MessageSize *hdr_size, MessageSize *body_size) {
--- a/src/lib-mail/message-part-serialize.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/message-part-serialize.h Sun Sep 08 17:39:05 2002 +0300 @@ -3,18 +3,17 @@ /* Serialize message part, allocating memory from temporary pool. size is updated to contain the size of returned data. */ -const void *message_part_serialize(MessagePart *part, unsigned int *size); +const void *message_part_serialize(MessagePart *part, size_t *size); /* Generate MessagePart from serialized data. */ -MessagePart *message_part_deserialize(Pool pool, const void *data, - unsigned int size); +MessagePart *message_part_deserialize(Pool pool, const void *data, size_t size); /* Update header size in serialized MessagePart. */ -int message_part_serialize_update_header(void *data, unsigned int size, +int message_part_serialize_update_header(void *data, size_t size, MessageSize *hdr_size); /* Get message size from serialized MessagePart data. */ -int message_part_deserialize_size(const void *data, unsigned int size, +int message_part_deserialize_size(const void *data, size_t size, MessageSize *hdr_size, MessageSize *body_size);
--- a/src/lib-mail/message-send.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/message-send.c Sun Sep 08 17:39:05 2002 +0300 @@ -9,7 +9,7 @@ uoff_t virtual_skip, uoff_t max_virtual_size) { unsigned char *msg; - unsigned int i, size; + size_t i, size; int cr_skipped, add_cr; if (msg_size->physical_size == 0 ||
--- a/src/lib-mail/message-size.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/message-size.c Sun Sep 08 17:39:05 2002 +0300 @@ -8,7 +8,7 @@ void message_get_header_size(IOBuffer *inbuf, MessageSize *hdr) { unsigned char *msg; - unsigned int i, size, startpos, missing_cr_count; + size_t i, size, startpos, missing_cr_count; memset(hdr, 0, sizeof(MessageSize)); @@ -61,7 +61,7 @@ uoff_t max_virtual_size) { unsigned char *msg; - unsigned int i, size, startpos, missing_cr_count; + size_t i, size, startpos, missing_cr_count; memset(body, 0, sizeof(MessageSize)); @@ -111,7 +111,7 @@ MessageSize *msg_size, int *cr_skipped) { unsigned char *msg; - unsigned int i, size, startpos; + size_t i, size, startpos; *cr_skipped = FALSE; if (virtual_skip == 0)
--- a/src/lib-mail/rfc822-date.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/rfc822-date.c Sun Sep 08 17:39:05 2002 +0300 @@ -16,7 +16,7 @@ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -static int parse_timezone(const char *str, unsigned int len) +static int parse_timezone(const char *str, size_t len) { int offset; char chr; @@ -101,7 +101,7 @@ { struct tm tm; const Rfc822Token *tokens, *tok; - unsigned int i; + size_t i; int zone_offset; if (str == NULL || *str == '\0')
--- a/src/lib-mail/rfc822-tokenize.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/rfc822-tokenize.c Sun Sep 08 17:39:05 2002 +0300 @@ -188,7 +188,7 @@ const char *rfc822_tokens_get_value(const Rfc822Token *tokens, int count) { char *buf; - unsigned int i, len, buf_size; + size_t i, len, buf_size; int last_atom; if (count <= 0) @@ -250,7 +250,7 @@ int count) { char *buf; - unsigned int len, buf_size; + size_t len, buf_size; int last_atom; if (count <= 0)
--- a/src/lib-mail/rfc822-tokenize.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-mail/rfc822-tokenize.h Sun Sep 08 17:39:05 2002 +0300 @@ -31,7 +31,7 @@ - '\' isn't expanded - [CR+]LF+LWSP (continued header) isn't removed */ const char *ptr; - unsigned int len; + size_t len; }; /* Parsing is aborted if returns FALSE. There's two kinds of errors:
--- a/src/lib-storage/index/index-fetch-section.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/index-fetch-section.c Sun Sep 08 17:39:05 2002 +0300 @@ -46,7 +46,7 @@ return FALSE; } - str = t_strdup_printf("{%lu}\r\n", (unsigned long) size.virtual_size); + str = t_strdup_printf("{%"PRIuUOFF_T"}\r\n", size.virtual_size); (void)io_buffer_send(ctx->outbuf, str, strlen(str)); (void)message_send(ctx->outbuf, inbuf, &size, 0, sect->max_size); @@ -73,8 +73,7 @@ return field_list; } -static int header_match(char *const *fields, const char *name, - unsigned int size) +static int header_match(char *const *fields, const char *name, size_t size) { const char *field, *name_start, *name_end; @@ -106,14 +105,13 @@ return FALSE; } -static int header_match_not(char *const *fields, const char *name, - unsigned int size) +static int header_match_not(char *const *fields, const char *name, size_t size) { return !header_match(fields, name, size); } static int header_match_mime(char *const *fields __attr_unused__, - const char *name, unsigned int size) + const char *name, size_t size) { if (size > 8 && strncasecmp(name, "Content-", 8) == 0) return TRUE; @@ -127,18 +125,18 @@ typedef struct { char *dest; char *const *fields; - int (*match_func) (char *const *, const char *, unsigned int); + int (*match_func) (char *const *, const char *, size_t); } FetchHeaderFieldContext; static void fetch_header_field(MessagePart *part __attr_unused__, - const char *name, unsigned int name_len, + const char *name, size_t name_len, const char *value __attr_unused__, - unsigned int value_len __attr_unused__, + size_t value_len __attr_unused__, void *context) { FetchHeaderFieldContext *ctx = context; const char *field_start, *field_end, *cr, *p; - unsigned int len; + size_t len; /* see if we want this field */ if (!ctx->match_func(ctx->fields, name, name_len)) @@ -155,7 +153,7 @@ cr = p; else if (*p == '\n' && cr != p-1) { /* missing CR */ - len = (unsigned int) (p-field_start); + len = (size_t) (p-field_start); memcpy(ctx->dest, field_start, len); ctx->dest[len++] = '\r'; @@ -167,7 +165,7 @@ } if (field_start != field_end) { - len = (unsigned int) (field_end-field_start); + len = (size_t) (field_end-field_start); memcpy(ctx->dest, field_start, len); ctx->dest += len; } @@ -178,10 +176,9 @@ } /* Store headers into dest, returns number of bytes written. */ -static unsigned int +static size_t fetch_header_fields(IOBuffer *inbuf, char *dest, char *const *fields, - int (*match_func) (char *const *, const char *, - unsigned int)) + int (*match_func) (char *const *, const char *, size_t)) { FetchHeaderFieldContext ctx; @@ -190,7 +187,7 @@ ctx.match_func = match_func; message_parse_header(NULL, inbuf, NULL, fetch_header_field, &ctx); - return (unsigned int) (ctx.dest - dest); + return (size_t) (ctx.dest - dest); } /* fetch wanted headers from given data */ @@ -200,14 +197,14 @@ { const char *str; char *dest; - unsigned int len; + size_t len; /* HEADER, MIME, HEADER.FIELDS (list), HEADER.FIELDS.NOT (list) */ if (strcasecmp(section, "HEADER") == 0) { /* all headers */ - str = t_strdup_printf("{%lu}\r\n", - (unsigned long) size->virtual_size); + str = t_strdup_printf("{%"PRIuUOFF_T"}\r\n", + size->virtual_size); (void)io_buffer_send(ctx->outbuf, str, strlen(str)); (void)message_send(ctx->outbuf, inbuf, size, sect->skip, sect->max_size); @@ -215,9 +212,15 @@ } /* partial headers - copy the wanted fields into temporary memory. - Insert missing CRs on the way. */ + Insert missing CRs on the way. FIXME: not a good idea with huge + headers. */ + if (size->virtual_size > SSIZE_T_MAX) { + io_buffer_send(ctx->outbuf, "{0}\r\n", 5); + return; + } + t_push(); - dest = t_malloc(size->virtual_size); + dest = t_malloc((size_t)size->virtual_size); if (strncasecmp(section, "HEADER.FIELDS ", 14) == 0) { len = fetch_header_fields(inbuf, dest, @@ -247,7 +250,7 @@ len = sect->max_size; } - str = t_strdup_printf("{%u}\r\n", len); + str = t_strdup_printf("{%"PRIuSIZE_T"}\r\n", len); io_buffer_send(ctx->outbuf, str, strlen(str)); if (len > 0) io_buffer_send(ctx->outbuf, dest, len); @@ -322,8 +325,8 @@ skip_pos = part->physical_pos + part->header_size.physical_size; io_buffer_skip(inbuf, skip_pos); - str = t_strdup_printf("{%lu}\r\n", - (unsigned long) part->body_size.virtual_size); + str = t_strdup_printf("{%"PRIuUOFF_T"}\r\n", + part->body_size.virtual_size); (void)io_buffer_send(ctx->outbuf, str, strlen(str)); /* FIXME: potential performance problem with big messages: @@ -376,8 +379,8 @@ str = !sect->skip_set ? t_strdup_printf(" BODY[%s] ", sect->section) : - t_strdup_printf(" BODY[%s]<%lu> ", sect->section, - (unsigned long) sect->skip); + t_strdup_printf(" BODY[%s]<%"PRIuUOFF_T"> ", + sect->section, sect->skip); if (ctx->first) str++; else ctx->first = FALSE; (void)io_buffer_send(ctx->outbuf, str, strlen(str));
--- a/src/lib-storage/index/index-save.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/index-save.c Sun Sep 08 17:39:05 2002 +0300 @@ -9,19 +9,19 @@ #include <unistd.h> static int write_with_crlf(int fd, const unsigned char *data, - unsigned int size, unsigned int *last_cr) + size_t size, unsigned int *last_cr) { - int i, cr; + ssize_t i, cr; - i_assert(size < INT_MAX); + i_assert(size <= SSIZE_T_MAX); cr = *last_cr ? -1 : -2; - for (i = 0; i < (int)size; i++) { + for (i = 0; i < (ssize_t)size; i++) { if (data[i] == '\r') cr = i; else if (data[i] == '\n' && cr != i-1) { /* missing CR */ - if (write_full(fd, data, (unsigned int) i) < 0) + if (write_full(fd, data, (size_t)i) < 0) return FALSE; if (write_full(fd, "\r", 1) < 0) return FALSE; @@ -38,16 +38,16 @@ } int index_storage_save_into_fd(MailStorage *storage, int fd, const char *path, - IOBuffer *buf, size_t data_size) + IOBuffer *buf, uoff_t data_size) { unsigned char *data; - unsigned int size, last_cr; - int ret; + size_t size, last_cr; + ssize_t ret; last_cr = FALSE; while (data_size > 0) { - ret = io_buffer_read_blocking(buf, (unsigned int)-1); + ret = io_buffer_read_blocking(buf, (size_t)-1); if (ret < 0) { mail_storage_set_critical(storage, "Error reading mail: %m"); @@ -56,7 +56,7 @@ data = io_buffer_get_data(buf, &size); if (size > data_size) - size = data_size; + size = (size_t)data_size; data_size -= size; if (write_with_crlf(fd, data, size, &last_cr) != 0) {
--- a/src/lib-storage/index/index-search.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/index-search.c Sun Sep 08 17:39:05 2002 +0300 @@ -28,7 +28,7 @@ int custom_header; const char *name, *value; - unsigned int name_len, value_len; + size_t name_len, value_len; } SearchHeaderContext; typedef struct { @@ -36,7 +36,7 @@ const char *msg; size_t size; - unsigned int max_searchword_len; + size_t max_searchword_len; } SearchTextContext; static int msgset_contains(const char *set, unsigned int match_num, @@ -203,7 +203,7 @@ MailField field, const char *value) { const char *field_value; - unsigned int i, value_len; + size_t i, value_len; field_value = index->lookup_field(index, rec, field); if (field_value == NULL) @@ -299,11 +299,11 @@ } /* needle must be uppercased */ -static int header_value_match(const char *haystack, unsigned int haystack_len, +static int header_value_match(const char *haystack, size_t haystack_len, const char *needle) { const char *n; - unsigned int i, j, needle_len, max; + size_t i, j, needle_len, max; if (*needle == '\0') return TRUE; @@ -344,7 +344,7 @@ { SearchHeaderContext *ctx = context; const char *value; - unsigned int len; + size_t len; int ret; /* first check that the field name matches to argument. */ @@ -398,8 +398,8 @@ } static void search_header(MessagePart *part __attr_unused__, - const char *name, unsigned int name_len, - const char *value, unsigned int value_len, + const char *name, size_t name_len, + const char *value, size_t value_len, void *context) { SearchHeaderContext *ctx = context; @@ -423,7 +423,7 @@ static void search_text(MailSearchArg *arg, SearchTextContext *ctx) { const char *p; - unsigned int i, len, max; + size_t i, len, max; if (arg->result != 0) return; @@ -473,8 +473,8 @@ MailSearchForeachFunc search_func) { SearchTextContext ctx; - unsigned int size; - int ret; + size_t size; + ssize_t ret; memset(&ctx, 0, sizeof(ctx)); ctx.args = args;
--- a/src/lib-storage/index/index-storage.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/index-storage.h Sun Sep 08 17:39:05 2002 +0300 @@ -36,7 +36,7 @@ MailIndexRecord **rec); int index_storage_save_into_fd(MailStorage *storage, int fd, const char *path, - IOBuffer *buf, size_t data_size); + IOBuffer *buf, uoff_t data_size); void *index_msgcache_get_context(MailIndex *index, MailIndexRecord *rec);
--- a/src/lib-storage/index/maildir/maildir-save.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/maildir/maildir-save.c Sun Sep 08 17:39:05 2002 +0300 @@ -36,7 +36,7 @@ } static const char *maildir_read_into_tmp(MailStorage *storage, const char *dir, - IOBuffer *buf, size_t data_size) + IOBuffer *buf, uoff_t data_size) { const char *fname, *path; int fd; @@ -58,7 +58,7 @@ int maildir_storage_save(Mailbox *box, MailFlags flags, const char *custom_flags[], time_t internal_date, - IOBuffer *data, size_t data_size) + IOBuffer *data, uoff_t data_size) { IndexMailbox *ibox = (IndexMailbox *) box; struct utimbuf buf;
--- a/src/lib-storage/index/maildir/maildir-storage.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.h Sun Sep 08 17:39:05 2002 +0300 @@ -7,7 +7,7 @@ const char *messageset, int uidset); int maildir_storage_save(Mailbox *box, MailFlags flags, const char *custom_flags[], time_t internal_date, - IOBuffer *data, size_t data_size); + IOBuffer *data, uoff_t data_size); int maildir_find_mailboxes(MailStorage *storage, const char *mask, MailboxFunc func, void *context);
--- a/src/lib-storage/index/mbox/mbox-save.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/mbox/mbox-save.c Sun Sep 08 17:39:05 2002 +0300 @@ -45,7 +45,7 @@ } int mbox_storage_save(Mailbox *box, MailFlags flags, const char *custom_flags[], - time_t internal_date, IOBuffer *data, size_t data_size) + time_t internal_date, IOBuffer *data, uoff_t data_size) { IndexMailbox *ibox = (IndexMailbox *) box; off_t pos;
--- a/src/lib-storage/index/mbox/mbox-storage.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.h Sun Sep 08 17:39:05 2002 +0300 @@ -6,7 +6,7 @@ int mbox_storage_copy(Mailbox *box, Mailbox *destbox, const char *messageset, int uidset); int mbox_storage_save(Mailbox *box, MailFlags flags, const char *custom_flags[], - time_t internal_date, IOBuffer *data, size_t data_size); + time_t internal_date, IOBuffer *data, uoff_t data_size); int mbox_find_mailboxes(MailStorage *storage, const char *mask, MailboxFunc func, void *context);
--- a/src/lib-storage/mail-storage.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/mail-storage.h Sun Sep 08 17:39:05 2002 +0300 @@ -162,7 +162,7 @@ /* Save a new mail into mailbox. */ int (*save)(Mailbox *box, MailFlags flags, const char *custom_flags[], - time_t internal_date, IOBuffer *data, size_t data_size); + time_t internal_date, IOBuffer *data, uoff_t data_size); /* Returns TRUE if mailbox is now in inconsistent state, meaning that the message IDs etc. may have changed - only way to recover this
--- a/src/lib-storage/subscription-file/subscription-file.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib-storage/subscription-file/subscription-file.c Sun Sep 08 17:39:05 2002 +0300 @@ -73,8 +73,7 @@ } static int subscription_append(MailStorage *storage, int fd, const char *name, - unsigned int len, int prefix_lf, - const char *path) + size_t len, int prefix_lf, const char *path) { char *buf; @@ -111,7 +110,7 @@ size_t mmap_length; const char *path; char *subscriptions, *end, *p; - unsigned int namelen, afterlen, removelen; + size_t namelen, afterlen, removelen; int fd, failed, prefix_lf; if (strcasecmp(name, "INBOX") == 0) @@ -145,7 +144,7 @@ failed = FALSE; if (p != NULL && !set) { /* remove it */ - afterlen = mmap_length - (unsigned int) (p - subscriptions); + afterlen = mmap_length - (size_t) (p - subscriptions); removelen = namelen < afterlen ? namelen+1 : namelen; if (removelen < afterlen)
--- a/src/lib/base64.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib/base64.c Sun Sep 08 17:39:05 2002 +0300 @@ -100,7 +100,7 @@ }; #define CHAR64(c) (index_64[(int)(unsigned char)(c)]) -int base64_decode(char *data) +ssize_t base64_decode(char *data) { char *p, *start; int c1, c2, c3, c4; @@ -141,5 +141,5 @@ *p++ = (((CHAR64(c3) & 0x3) << 6) | CHAR64(c4)); } - return (int) (p-start); + return (ssize_t) (p-start); }
--- a/src/lib/base64.h Sun Sep 08 16:20:28 2002 +0300 +++ b/src/lib/base64.h Sun Sep 08 17:39:05 2002 +0300 @@ -6,6 +6,6 @@ /* Translates base64 data into binary modifying the data itself. Returns size of the binary data, or -1 if error occured. */ -int base64_decode(char *data); +ssize_t base64_decode(char *data); #endif
--- a/src/login/auth-connection.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/login/auth-connection.c Sun Sep 08 17:39:05 2002 +0300 @@ -123,7 +123,7 @@ i_free(conn); } -static AuthConnection *auth_connection_get(AuthMethod method, unsigned int size, +static AuthConnection *auth_connection_get(AuthMethod method, size_t size, const char **error) { AuthConnection *conn; @@ -203,7 +203,7 @@ AuthConnection *conn = context; AuthInitData init_data; unsigned char *data; - unsigned int size; + size_t size; switch (io_buffer_read(conn->inbuf)) { case 0: @@ -294,7 +294,7 @@ } void auth_continue_request(AuthRequest *request, const unsigned char *data, - unsigned int data_size) + size_t data_size) { AuthContinuedRequestData request_data;
--- a/src/login/client-authenticate.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/login/client-authenticate.c Sun Sep 08 17:39:05 2002 +0300 @@ -101,7 +101,7 @@ } static void client_send_auth_data(Client *client, const unsigned char *data, - unsigned int size) + size_t size) { const char *base64_data; @@ -117,7 +117,7 @@ static int auth_callback(AuthRequest *request, int auth_process, AuthResult result, const unsigned char *reply_data, - unsigned int reply_data_size, void *context) + size_t reply_data_size, void *context) { Client *client = context; @@ -160,7 +160,7 @@ static void login_callback(AuthRequest *request, int auth_process, AuthResult result, const unsigned char *reply_data, - unsigned int reply_data_size, void *context) + size_t reply_data_size, void *context) { Client *client = context; @@ -178,7 +178,7 @@ { const char *error; char *p; - unsigned int len, user_len, pass_len; + size_t len, user_len, pass_len; if (!client->tls && disable_plaintext_auth) { client_send_tagline(client, @@ -217,7 +217,7 @@ static void authenticate_callback(AuthRequest *request, int auth_process, AuthResult result, const unsigned char *reply_data, - unsigned int reply_data_size, void *context) + size_t reply_data_size, void *context) { Client *client = context; @@ -231,7 +231,7 @@ { Client *client = context; char *line; - int size; + ssize_t size; if (!client_read(client)) return; @@ -258,7 +258,7 @@ } auth_continue_request(client->auth_request, (unsigned char *) line, - (unsigned int) size); + (size_t)size); } int cmd_authenticate(Client *client, const char *method_name)
--- a/src/login/ssl-proxy.c Sun Sep 08 16:20:28 2002 +0300 +++ b/src/login/ssl-proxy.c Sun Sep 08 17:39:05 2002 +0300 @@ -23,7 +23,7 @@ unsigned char outbuf_plain[1024]; unsigned int outbuf_pos_plain; - unsigned int send_left_ssl, send_left_plain; + size_t send_left_ssl, send_left_plain; } SSLProxy; #define DH_BITS 1024 @@ -46,7 +46,7 @@ static void plain_input(void *context, int handle, IO io); static int ssl_proxy_destroy(SSLProxy *proxy); -static int proxy_recv_ssl(SSLProxy *proxy, void *data, unsigned int size) +static int proxy_recv_ssl(SSLProxy *proxy, void *data, size_t size) { int rcvd; @@ -71,7 +71,7 @@ return -1; } -static int proxy_send_ssl(SSLProxy *proxy, const void *data, unsigned int size) +static int proxy_send_ssl(SSLProxy *proxy, const void *data, size_t size) { int sent; @@ -148,8 +148,7 @@ if (rcvd <= 0) return; - sent = net_transmit(proxy->fd_plain, proxy->outbuf_plain, - (unsigned int) rcvd); + sent = net_transmit(proxy->fd_plain, proxy->outbuf_plain, (size_t)rcvd); if (sent == rcvd) return; @@ -195,7 +194,7 @@ { SSLProxy *proxy = context; char buf[1024]; - int rcvd, sent; + ssize_t rcvd, sent; rcvd = net_receive(proxy->fd_plain, buf, sizeof(buf)); if (rcvd < 0) { @@ -205,7 +204,7 @@ return; } - sent = proxy_send_ssl(proxy, buf, (unsigned int) rcvd); + sent = proxy_send_ssl(proxy, buf, (size_t)rcvd); if (sent < 0 || sent == rcvd) return;