[balsa] Fix accessing MBox files > 2 GByte
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Fix accessing MBox files > 2 GByte
- Date: Sat, 28 May 2016 02:39:36 +0000 (UTC)
commit ff370da3abab70a1969095f913f3e30a6d1ea7ad
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri May 27 22:39:15 2016 -0400
Fix accessing MBox files > 2 GByte
* libbalsa/mailbox_mbox.c (lbm_mbox_check_file),
(lbm_mbox_newline), (libbalsa_mailbox_mbox_add_message): use
64-bit sizes;
* libbalsa/send.c (libbalsa_message_cb): comment warning about
file size.
ChangeLog | 10 ++++++++++
libbalsa/mailbox_mbox.c | 28 ++++++++++++++++------------
libbalsa/send.c | 2 ++
3 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a7bb402..4a86bf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-05-27 Albrecht Dreß
+
+ Fix accessing MBox files > 2 GByte
+
+ * libbalsa/mailbox_mbox.c (lbm_mbox_check_file),
+ (lbm_mbox_newline), (libbalsa_mailbox_mbox_add_message): use
+ 64-bit sizes;
+ * libbalsa/send.c (libbalsa_message_cb): comment warning about
+ file size.
+
2015-03-03 Albrecht Dreß
Improve display and printing of text/rfc822-headers parts
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index a097a75..6da6575 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -113,7 +113,7 @@ struct _LibBalsaMailboxMbox {
GPtrArray *msgno_2_msg_info;
GMimeStream *gmime_stream;
- gint size;
+ off_t size;
gboolean messages_info_changed;
};
@@ -921,10 +921,10 @@ lbm_mbox_check_file(LibBalsaMailboxMbox * mbox,
if (content_length) {
/* Seek past the content. */
- ssize_t remaining;
+ off_t remaining;
buffer->start += content_length;
- remaining = buffer->end - buffer->start;
+ remaining = (off_t) buffer->end - (off_t) buffer->start;
if (remaining < 0) {
g_mime_stream_seek(buffer->stream, -remaining,
GMIME_STREAM_SEEK_CUR);
@@ -1167,15 +1167,19 @@ static gint
lbm_mbox_newline(GMimeStream * stream)
{
gint retval;
- gchar buf[1];
- static gchar newlines[] = "\n\n";
+ static const gchar newlines[] = "\n\n";
- retval = g_mime_stream_seek(stream, -1, GMIME_STREAM_SEEK_CUR);
- if (retval >= 0)
- retval = g_mime_stream_read(stream, buf, 1);
- if (retval == 1)
- retval =
- g_mime_stream_write(stream, newlines, buf[0] == '\n' ? 1 : 2);
+ if (g_mime_stream_seek(stream, -1, GMIME_STREAM_SEEK_CUR) < 0) {
+ retval = -1;
+ } else {
+ gchar buf;
+
+ retval = g_mime_stream_read(stream, &buf, 1);
+ if (retval == 1) {
+ retval =
+ g_mime_stream_write(stream, newlines, buf == '\n' ? 1 : 2);
+ }
+ }
return retval;
}
@@ -1950,7 +1954,7 @@ libbalsa_mailbox_mbox_add_message(LibBalsaMailbox * mailbox,
GMimeObject *armored_object;
GMimeStream *armored_dest;
GMimeStream *dest;
- gint retval;
+ off_t retval;
off_t orig_length;
message = libbalsa_message_new();
diff --git a/libbalsa/send.c b/libbalsa/send.c
index a441f03..32521cd 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -588,6 +588,8 @@ libbalsa_message_cb (void **buf, int *len, void *arg)
return NULL;
}
+ /* note: the following calculation works *only* for messages < 2 GB
+ * due to the limited range of int, but this should be safe... */
*len = g_mime_stream_length(current_message->stream)
- g_mime_stream_tell(current_message->stream);
ptr = (char *) mem_stream->buffer->data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]