summaryrefslogtreecommitdiffstats
path: root/crypt-gpgme.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-12-21 15:34:58 -0800
committerKevin McCarthy <kevin@8t8.us>2020-12-22 18:12:24 -0800
commit03e17ef7f70279d36f95083fcb952b9f386256f7 (patch)
tree8f18998004beba815a280cb41db2edf1ab9c3cf9 /crypt-gpgme.c
parenta4a2a1ed7abf02507a35e2a6d49da102cbd117dd (diff)
Correct length to use LOFF_T.
This is a part two, made in master, to the stable branch commit 11b18027. These are mostly length adjustments to use LOFF_T, matching the BODY->length type. An argument could be made for size_t instead, and a few places in Mutt do assign between those types. I've used LOFF_T because off_t is a signed integer. Some changes in this commit affect loops that decrement a length pointer while > 0. Switching to a size_t could create a wraparound infinite loop bug. This also changes the Content-Length header parser to use atoll() intead of atol(). I noticed from the man page that atol() doesn't seem to return -1 on error. But I've kept the check anyway.
Diffstat (limited to 'crypt-gpgme.c')
-rw-r--r--crypt-gpgme.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index f2ccbebc..9f65c597 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -714,7 +714,7 @@ cleanup:
/* Create a GPGME data object from the stream FP but limit the object
to LENGTH bytes starting at OFFSET bytes from the beginning of the
file. */
-static gpgme_data_t file_to_data_object (FILE *fp, long offset, long length)
+static gpgme_data_t file_to_data_object (FILE *fp, LOFF_T offset, long length)
{
int err = 0;
gpgme_data_t data;
@@ -2756,8 +2756,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
{
int needpass = -1, pgp_keyblock = 0;
int clearsign = 0;
- long bytes;
- LOFF_T last_pos, offset, block_begin, block_end;
+ LOFF_T bytes, last_pos, offset, block_begin, block_end;
char buf[HUGE_STRING];
FILE *pgpout = NULL;