[Commits] [SCM] claws branch, master, updated. 4.3.1-32-g3e1c1a122
wwp at claws-mail.org
wwp at claws-mail.org
Wed Mar 5 22:56:54 UTC 2025
The branch, master has been updated
via 3e1c1a122f72827d5be12bb33e091045c2e3cacd (commit)
from ef3630094e7f857f1f377ba1e61cfaa299bd0506 (commit)
Summary of changes:
src/mimeview.c | 2 +-
src/plugins/pgpcore/sgpgme.c | 2 +-
src/plugins/tnef_parse/tnef_parse.c | 2 +-
src/procmime.c | 59 +++++++++++++++++++------------------
src/procmime.h | 4 +--
src/textview.c | 10 +++----
6 files changed, 41 insertions(+), 38 deletions(-)
- Log -----------------------------------------------------------------
commit 3e1c1a122f72827d5be12bb33e091045c2e3cacd
Author: wwp <subscript at free.fr>
Date: Wed Mar 5 23:56:43 2025 +0100
Make sure all data manipulation around mimeinfo->length and mimeinfo->offset
use at least long integers (they are more or less all bound to ftell), this
solves mismatch in comparisons and also:
CID 1498802: Improper use of negative value (NEGATIVE_RETURNS)
diff --git a/src/mimeview.c b/src/mimeview.c
index 60a0ded0a..b3ddacff5 100644
--- a/src/mimeview.c
+++ b/src/mimeview.c
@@ -181,7 +181,7 @@ static void mimeview_copy_cb(GtkAction *action, gpointer data)
} else {
void *data = procmime_get_part_as_string(mimeinfo, FALSE);
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
- data, mimeinfo->length);
+ data, (gint)mimeinfo->length);
g_free(data);
}
}
diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c
index 2749a3238..91a93ce72 100644
--- a/src/plugins/pgpcore/sgpgme.c
+++ b/src/plugins/pgpcore/sgpgme.c
@@ -649,7 +649,7 @@ gpgme_data_t sgpgme_data_from_mimeinfo(MimeInfo *mimeinfo)
err = gpgme_data_new_from_filepart(&data, NULL, fp, mimeinfo->offset, mimeinfo->length);
claws_fclose(fp);
- debug_print("data %p (%d %d)\n", (void *)&data, mimeinfo->offset, mimeinfo->length);
+ debug_print("data %p (%ld %ld)\n", (void *)&data, mimeinfo->offset, mimeinfo->length);
if (err) {
debug_print ("gpgme_data_new_from_file failed: %s\n",
gpgme_strerror (err));
diff --git a/src/plugins/tnef_parse/tnef_parse.c b/src/plugins/tnef_parse/tnef_parse.c
index 4f033b402..bc893ea7b 100644
--- a/src/plugins/tnef_parse/tnef_parse.c
+++ b/src/plugins/tnef_parse/tnef_parse.c
@@ -297,7 +297,7 @@ static gboolean tnef_parse (MimeParser *parser, MimeInfo *mimeinfo)
debug_print("error decoding\n");
return FALSE;
}
- debug_print("Tnef parser parsing part (%d).\n", mimeinfo->length);
+ debug_print("Tnef parser parsing part (%ld).\n", mimeinfo->length);
if (mimeinfo->content == MIMECONTENT_FILE)
debug_print("content: %s\n", mimeinfo->data.filename);
else
diff --git a/src/procmime.c b/src/procmime.c
index 3d1cd7e35..7d6f19b2a 100644
--- a/src/procmime.c
+++ b/src/procmime.c
@@ -292,7 +292,7 @@ const gchar *procmime_mimeinfo_get_parameter(MimeInfo *mimeinfo, const gchar *na
gboolean procmime_decode_content(MimeInfo *mimeinfo)
{
gchar buf[BUFFSIZE];
- gint readend;
+ glong readend;
gchar *tmpfilename;
FILE *outfp, *infp;
GStatBuf statbuf;
@@ -364,7 +364,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
*buf = '\0';
if (encoding == ENC_QUOTED_PRINTABLE) {
while ((ftell(infp) < readend) && (claws_fgets(buf, sizeof(buf), infp) != NULL)) {
- gint len;
+ size_t len;
len = qp_decode_line(buf);
buf[len] = '\0';
if (!flowed) {
@@ -378,7 +378,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
FLUSH_LASTLINE();
} else if (encoding == ENC_BASE64) {
gchar outbuf[BUFFSIZE + 1];
- gint len, inlen, inread;
+ glong len;
+ gsize inlen, inread;
gboolean got_error = FALSE;
gboolean uncanonicalize = FALSE;
FILE *tmpfp = NULL;
@@ -403,8 +404,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
while ((inlen = MIN(readend - ftell(infp), sizeof(buf))) > 0 && !err) {
inread = claws_fread(buf, 1, inlen, infp);
memset(outbuf, 0, sizeof(buf));
- len = g_base64_decode_step(buf, inlen, outbuf, &state, &save);
- if (uncanonicalize == TRUE && strlen(outbuf) < len && starting) {
+ len = (glong)g_base64_decode_step(buf, inlen, outbuf, &state, &save);
+ if (uncanonicalize == TRUE && strlen(outbuf) < (size_t)len && starting) {
uncanonicalize = FALSE;
null_bytes = TRUE;
}
@@ -423,10 +424,10 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
* per block */
if (null_bytes) {
/* we won't uncanonicalize, output to outfp directly */
- if (claws_fwrite(outbuf, sizeof(gchar), len, outfp) < len)
+ if (claws_fwrite(outbuf, sizeof(gchar), (size_t)len, outfp) < (size_t)len)
err = TRUE;
} else {
- if (claws_fwrite(outbuf, sizeof(gchar), len, tmpfp) < len)
+ if (claws_fwrite(outbuf, sizeof(gchar), (size_t)len, tmpfp) < (size_t)len)
err = TRUE;
}
got_error = FALSE;
@@ -446,7 +447,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
}
} else if (encoding == ENC_X_UUENCODE) {
gchar outbuf[BUFFSIZE];
- gint len;
+ glong len;
gboolean flag = FALSE;
while ((ftell(infp) < readend) && (claws_fgets(buf, sizeof(buf), infp) != NULL)) {
@@ -456,10 +457,10 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
len = fromuutobits(outbuf, buf);
if (len <= 0) {
if (len < 0)
- g_warning("bad UUENCODE content (%d)", len);
+ g_warning("bad UUENCODE content (%ld)", len);
break;
}
- if (claws_fwrite(outbuf, sizeof(gchar), len, outfp) < len)
+ if (claws_fwrite(outbuf, sizeof(gchar), (size_t)len, outfp) < (size_t)len)
err = TRUE;
} else
flag = TRUE;
@@ -510,7 +511,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
{
FILE *infp = NULL, *outfp;
- gint len;
+ glong len;
gchar *tmpfilename;
GStatBuf statbuf;
gboolean err = FALSE;
@@ -592,7 +593,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
}
}
- while ((len = claws_fread(inbuf, sizeof(gchar),
+ while ((len = (glong)claws_fread(inbuf, sizeof(gchar),
B64_LINE_SIZE, tmp_fp))
== B64_LINE_SIZE) {
out = g_base64_encode(inbuf, B64_LINE_SIZE);
@@ -603,7 +604,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
err = TRUE;
}
if (len > 0 && claws_feof(tmp_fp)) {
- out = g_base64_encode(inbuf, len);
+ out = g_base64_encode(inbuf, (gsize)len);
if (claws_fputs(out, outfp) == EOF)
err = TRUE;
g_free(out);
@@ -682,7 +683,7 @@ static gint procmime_get_part_to_stream(FILE *outfp, MimeInfo *mimeinfo)
{
FILE *infp;
gchar buf[BUFFSIZE];
- gint restlength, readlength;
+ glong restlength, readlength;
gint saved_errno = 0;
cm_return_val_if_fail(outfp != NULL, -1);
@@ -706,7 +707,7 @@ static gint procmime_get_part_to_stream(FILE *outfp, MimeInfo *mimeinfo)
restlength = mimeinfo->length;
while ((restlength > 0) && ((readlength = claws_fread(buf, 1, restlength > BUFFSIZE ? BUFFSIZE : restlength, infp)) > 0)) {
- if (claws_fwrite(buf, 1, readlength, outfp) != readlength) {
+ if (claws_fwrite(buf, 1, (size_t)readlength, outfp) != (size_t)readlength) {
saved_errno = errno;
claws_fclose(infp);
return -(saved_errno);
@@ -1286,7 +1287,7 @@ EncodingType procmime_get_encoding_for_text_file(const gchar *file, gboolean *ha
while ((len = claws_fread(buf, sizeof(guchar), sizeof(buf), fp)) > 0) {
guchar *p;
- gint i;
+ gulong i;
for (p = buf, i = 0; i < len; ++p, ++i) {
if (*p & 0x80)
@@ -1445,7 +1446,7 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
guint i;
FILE *fp;
gchar *tmp;
- gint len = 0;
+ glong len = 0;
procmime_decode_content(mimeinfo);
@@ -1641,7 +1642,9 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
{NULL, NULL, FALSE}};
gchar *tmp;
gchar *boundary;
- gint boundary_len = 0, lastoffset = -1, i;
+ gsize boundary_len = 0;
+ glong lastoffset = -1;
+ gulong i;
gchar buf[BUFFSIZE];
FILE *fp;
int result = 0;
@@ -1675,7 +1678,7 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
start_found = TRUE;
if (lastoffset != -1) {
- gint len = (ftell(fp) - strlen(buf)) - lastoffset - 1;
+ glong len = (ftell(fp) - strlen(buf)) - lastoffset - 1;
if (len < 0)
len = 0;
result = procmime_parse_mimepart(mimeinfo,
@@ -1705,7 +1708,7 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
}
if (start_found && !end_found && lastoffset != -1) {
- gint len = (ftell(fp) - strlen(buf)) - lastoffset - 1;
+ glong len = (ftell(fp) - strlen(buf)) - lastoffset - 1;
if (len >= 0) {
result = procmime_parse_mimepart(mimeinfo,
@@ -1736,7 +1739,7 @@ static void parse_parameters(const gchar *parameters, GHashTable *table)
next = params;
for (; next != NULL; param = next) {
gchar *attribute, *value, *tmp, *down_attr, *orig_down_attr;
- gint len;
+ glong len;
gboolean convert = FALSE;
next = strchr_with_skip_quote(param, '"', ';');
@@ -2149,7 +2152,7 @@ static gboolean output_func(GNode *node, gpointer data)
depth = g_node_depth(node);
for (i = 0; i < depth; i++)
g_print(" ");
- g_print("%s/%s (offset:%d length:%d encoding: %d)\n",
+ g_print("%s/%s (offset:%ld length:%ld encoding: %d)\n",
(mimeinfo->type <= MIMETYPE_UNKNOWN)? typenames[mimeinfo->type] : "unknown",
mimeinfo->subtype, mimeinfo->offset, mimeinfo->length, mimeinfo->encoding_type);
@@ -2161,7 +2164,7 @@ static void output_mime_structure(MimeInfo *mimeinfo, int indent)
g_node_traverse(mimeinfo->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, output_func, NULL);
}
-static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offset, gboolean short_scan)
+static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, glong offset, gboolean short_scan)
{
MimeInfo *mimeinfo;
GStatBuf buf;
@@ -2213,7 +2216,7 @@ static MimeInfo *procmime_scan_queue_file_full(const gchar *filename, gboolean s
FILE *fp;
MimeInfo *mimeinfo;
gchar buf[BUFFSIZE];
- gint offset = 0;
+ glong offset = 0;
cm_return_val_if_fail(filename != NULL, NULL);
@@ -2276,7 +2279,7 @@ static void write_parameters(gpointer key, gpointer value, gpointer user_data)
gchar *val = value, *valpos, *tmp;
ParametersData *pdata = (ParametersData *)user_data;
GString *buf = g_string_new("");
- gint len;
+ glong len;
EncodeAs encas = ENC_AS_TOKEN;
@@ -2713,7 +2716,7 @@ void *procmime_get_part_as_string(MimeInfo *mimeinfo,
{
FILE *infp;
gchar *data;
- gint length, readlength;
+ glong length, readlength;
cm_return_val_if_fail(mimeinfo != NULL, NULL);
@@ -2739,7 +2742,7 @@ void *procmime_get_part_as_string(MimeInfo *mimeinfo,
data = g_malloc(null_terminate ? length + 1 : length);
if (data == NULL) {
- g_warning("could not allocate %d bytes for procmime_get_part_as_string",
+ g_warning("could not allocate %ld bytes for procmime_get_part_as_string",
(null_terminate ? length + 1 : length));
claws_fclose(infp);
return NULL;
@@ -2777,7 +2780,7 @@ GInputStream *procmime_get_part_as_inputstream(MimeInfo *mimeinfo)
* the data for the stream. */
return g_memory_input_stream_new_from_data(
mimeinfo->data.mem,
- mimeinfo->length, NULL);
+ (gssize)mimeinfo->length, NULL);
} else {
return g_memory_input_stream_new_from_data(
procmime_get_part_as_string(mimeinfo, FALSE),
diff --git a/src/procmime.h b/src/procmime.h
index ba385cca8..dfc94fa44 100644
--- a/src/procmime.h
+++ b/src/procmime.h
@@ -143,8 +143,8 @@ struct _MimeInfo
/* Content-Location */
gchar *location;
- guint offset;
- guint length;
+ glong offset;
+ glong length;
/* Content-Disposition */
DispositionType disposition;
diff --git a/src/textview.c b/src/textview.c
index 0961ce3dd..f6e9f653b 100644
--- a/src/textview.c
+++ b/src/textview.c
@@ -705,10 +705,10 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
if (name == NULL)
name = procmime_mimeinfo_get_parameter(mimeinfo, "name");
if (name != NULL)
- g_snprintf(buf, sizeof(buf), _("[%s %s (%d bytes)]"),
+ g_snprintf(buf, sizeof(buf), _("[%s %s (%ld bytes)]"),
name, content_type, mimeinfo->length);
else
- g_snprintf(buf, sizeof(buf), _("[%s (%d bytes)]"),
+ g_snprintf(buf, sizeof(buf), _("[%s (%ld bytes)]"),
content_type, mimeinfo->length);
g_free(content_type);
@@ -1017,7 +1017,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
#endif
GSList *cur;
gboolean continue_write = TRUE;
- size_t wrote = 0, i = 0;
+ glong wrote = 0, i = 0;
if (textview->messageview->forced_charset)
charset = textview->messageview->forced_charset;
@@ -1088,7 +1088,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
if (procmime_get_part(fname, mimeinfo)) goto textview_default;
g_snprintf(buf, sizeof(buf), cmd, fname);
- debug_print("Viewing text content of type: %s (length: %d) "
+ debug_print("Viewing text content of type: %s (length: %ld) "
"using %s\n", mimeinfo->subtype, mimeinfo->length, buf);
if (pipe(pfd) < 0) {
@@ -1173,7 +1173,7 @@ textview_default:
conv_code_converter_destroy(conv);
return;
}
- debug_print("Viewing text content of type: %s (length: %d)\n", mimeinfo->subtype, mimeinfo->length);
+ debug_print("Viewing text content of type: %s (length: %ld)\n", mimeinfo->subtype, mimeinfo->length);
while (((i = ftell(tmpfp)) < mimeinfo->offset + mimeinfo->length) &&
(claws_fgets(buf, sizeof(buf), tmpfp) != NULL)
&& continue_write) {
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list