aboutsummaryrefslogtreecommitdiffstats
path: root/main/ntfs-3g/CVE-2019-9755.patch
blob: 577f1686282e1dfb2e076139987226c8369490f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 85c1634a26faa572d3c558d4cf8aaaca5202d4e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= <jean-pierre.andre@wanadoo.fr>
Date: Wed, 19 Dec 2018 15:57:50 +0100
Subject: [PATCH] Fixed reporting an error when failed to build the mountpoint

The size check was inefficient because getcwd() uses an unsigned int
argument.
---
 src/lowntfs-3g.c | 6 +++++-
 src/ntfs-3g.c    | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c
index 993867fa..0660439b 100644
--- a/src/lowntfs-3g.c
+++ b/src/lowntfs-3g.c
@@ -4323,7 +4323,8 @@
 	else {
 		ctx->abs_mnt_point = (char*)ntfs_malloc(PATH_MAX);
 		if (ctx->abs_mnt_point) {
-			if (getcwd(ctx->abs_mnt_point,
+			if ((strlen(opts.mnt_point) < PATH_MAX)
+			    && getcwd(ctx->abs_mnt_point,
 				     PATH_MAX - strlen(opts.mnt_point) - 1)) {
 				strcat(ctx->abs_mnt_point, "/");
 				strcat(ctx->abs_mnt_point, opts.mnt_point);
@@ -4331,6 +4332,9 @@
 			/* Solaris also wants the absolute mount point */
 				opts.mnt_point = ctx->abs_mnt_point;
 #endif /* defined(__sun) && defined (__SVR4) */
+			} else {
+				free(ctx->abs_mnt_point);
+				ctx->abs_mnt_point = (char*)NULL;
 			}
 		}
 	}
diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c
index 6ce89fef..4e0912ae 100644
--- a/src/ntfs-3g.c
+++ b/src/ntfs-3g.c
@@ -4123,7 +4123,8 @@
 	else {
 		ctx->abs_mnt_point = (char*)ntfs_malloc(PATH_MAX);
 		if (ctx->abs_mnt_point) {
-			if (getcwd(ctx->abs_mnt_point,
+			if ((strlen(opts.mnt_point) < PATH_MAX)
+			    && getcwd(ctx->abs_mnt_point,
 				     PATH_MAX - strlen(opts.mnt_point) - 1)) {
 				strcat(ctx->abs_mnt_point, "/");
 				strcat(ctx->abs_mnt_point, opts.mnt_point);
@@ -4131,6 +4132,9 @@
 			/* Solaris also wants the absolute mount point */
 				opts.mnt_point = ctx->abs_mnt_point;
 #endif /* defined(__sun) && defined (__SVR4) */
+			} else {
+				free(ctx->abs_mnt_point);
+				ctx->abs_mnt_point = (char*)NULL;
 			}
 		}
 	}
-- 
2.22.0