summaryrefslogtreecommitdiffstats
path: root/mbox.c
diff options
context:
space:
mode:
authorVincent Lefevre <vincent@vinc17.net>2018-02-14 10:33:41 +0100
committerVincent Lefevre <vincent@vinc17.net>2018-02-14 10:33:41 +0100
commitebd93b509fe195500bb6aa1fdc36df05377b4ae3 (patch)
treef9b43600d8562809d45bc80f46cf1c25f7893a3f /mbox.c
parent088e1903488a6e35945763563d24f91bb0c5e6f8 (diff)
Avoid a potential integer overflow if a Content-Length value is huge.
Diffstat (limited to 'mbox.c')
-rw-r--r--mbox.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mbox.c b/mbox.c
index 37933273..34668832 100644
--- a/mbox.c
+++ b/mbox.c
@@ -317,7 +317,11 @@ int mbox_parse_mailbox (CONTEXT *ctx)
LOFF_T tmploc;
loc = ftello (ctx->fp);
- tmploc = loc + curhdr->content->length + 1;
+
+ /* The test below avoids a potential integer overflow if the
+ * content-length is huge (thus necessarily invalid).
+ */
+ tmploc = curhdr->content->length < ctx->size ? loc + curhdr->content->length + 1 : -1;
if (0 < tmploc && tmploc < ctx->size)
{