Skip to content

Commit

Permalink
Add test for mime parsing reportedly crash-inducing message
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Bogatov authored and hpk42 committed Sep 18, 2019
1 parent b680319 commit 7b73103
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# ensures this even if the user has not set core.autocrlf.
* text=auto

# This directory contains email messages verbatim, and changing CRLF to
# LF will corrupt them.
test-data/* text=false

# binary files should be detected by git, however, to be sure, you can add them here explicitly
*.png binary
*.jpg binary
Expand Down
10 changes: 10 additions & 0 deletions src/dc_mimeparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,16 @@ mod tests {
mailmime_free(mime);
}
}

#[test]
fn test_dc_mimeparser_crash() {
let context = dummy_context();
let raw = include_bytes!("../test-data/message/issue_523.txt");
let mimeparser = unsafe { dc_mimeparser_parse(&context.ctx, &raw[..]) };
assert_eq!(mimeparser.subject, None);
assert_eq!(mimeparser.parts.len(), 1);
}

#[test]
fn test_mimeparser_with_context() {
unsafe {
Expand Down
21 changes: 21 additions & 0 deletions test-data/message/issue_523.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Return-Path: <[email protected]>
Received: from hq5.merlinux.eu
by hq5.merlinux.eu (Dovecot) with LMTP id yRKOBakcfV1AewAAPzvFDg
; Sat, 14 Sep 2019 19:00:25 +0200
Received: from localhost (unknown 7.165.105.24])
by hq5.merlinux.eu (Postfix) with ESMTPSA id 8D9844E023;
Sat, 14 Sep 2019 19:00:22 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=testrun.org;
s=testrun; t=1568480425;
bh=GrziQ9bkbioILHZ1tEn81B53bDgaZK+ENbW4MUBiMUM=;
h=Date:From:To:In-Reply-To:References:Subject:From;
b=eHP/GdBQD1cq601Gaqpz7fd+nQvBJLH7c+bk9KGGC3BKZrRAzehEDOaFlGP2+9oFq
cl+y11nGowenVAw7M5ljjxCpOVy0Aa+atn3e7iZeufgOJPr5Hggg2nPe4qfyP6OmOJ
i9RazyXN1rp4fY7ku9x29g818UL8aWiloJHJ9wqDhMe8OXtIAhJA0gpHDCT1SLgo/a
Kv7/Yj4CA8XS/mRxkbBmpWgcF7SluNjuXU9Npo3aTfjQQ5xSzn72Jsai4n0ppLcQ5k
KobttFy+gkmfQRAe8v7vx51qn82BSsGRlxZWevOB9zit/uk7zb8ZbBqPMeCoWsihRM
LdSqwIpokmYmQ==
Date: Sat, 14 Sep 2019 19:00:13 +0200
From: lmn <[email protected]>
To: abc <[email protected]>, def <[email protected]>,
jik

0 comments on commit 7b73103

Please sign in to comment.