gnu: ytnef: Fix CVE-2021-3403 and CVE-2021-3404.
[jackhill/guix/guix.git] / gnu / packages / patches / ytnef-CVE-2021-3404.patch
1 From f9ff4a203b8c155d51a208cadadb62f224fba715 Mon Sep 17 00:00:00 2001
2 From: Oliver Giles <ohw.giles@gmail.com>
3 Date: Mon, 1 Feb 2021 10:18:17 +1300
4 Subject: [PATCH] Ensure the size of the version field is 4 bytes
5
6 A corrupted version field size can cause TNEFVersion to access outside
7 of allocated memory. Check the version is the expected size and raise
8 an error if not.
9
10 Resolves: #86
11 Reported-by: jasperla
12 ---
13 lib/ytnef.c | 4 ++++
14 1 file changed, 4 insertions(+)
15
16 diff --git a/lib/ytnef.c b/lib/ytnef.c
17 index b148719..ffede44 100644
18 --- a/lib/ytnef.c
19 +++ b/lib/ytnef.c
20 @@ -335,6 +335,10 @@ int TNEFRendData STD_ARGLIST {
21 int TNEFVersion STD_ARGLIST {
22 WORD major;
23 WORD minor;
24 + if (size != 2 * sizeof(WORD)) {
25 + printf("Incorrect size of version field, suspected corruption\n");
26 + return -1;
27 + }
28 minor = SwapWord((BYTE*)data, size);
29 major = SwapWord((BYTE*)data + 2, size - 2);
30