Blame SOURCES/0001-Fixed-reporting-an-error-when-failed-to-build-the-mo.patch

3d59c1
From 85c1634a26faa572d3c558d4cf8aaaca5202d4e9 Mon Sep 17 00:00:00 2001
3d59c1
From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= <jean-pierre.andre@wanadoo.fr>
3d59c1
Date: Wed, 19 Dec 2018 15:57:50 +0100
3d59c1
Subject: [PATCH] Fixed reporting an error when failed to build the mountpoint
3d59c1
3d59c1
The size check was inefficient because getcwd() uses an unsigned int
3d59c1
argument.
3d59c1
---
3d59c1
 src/lowntfs-3g.c | 6 +++++-
3d59c1
 src/ntfs-3g.c    | 6 +++++-
3d59c1
 2 files changed, 10 insertions(+), 2 deletions(-)
3d59c1
3d59c1
diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c
3d59c1
index 993867fa..0660439b 100644
3d59c1
--- a/src/lowntfs-3g.c
3d59c1
+++ b/src/lowntfs-3g.c
3d59c1
@@ -4411,7 +4411,8 @@ int main(int argc, char *argv[])
3d59c1
 	else {
3d59c1
 		ctx->abs_mnt_point = (char*)ntfs_malloc(PATH_MAX);
3d59c1
 		if (ctx->abs_mnt_point) {
3d59c1
-			if (getcwd(ctx->abs_mnt_point,
3d59c1
+			if ((strlen(opts.mnt_point) < PATH_MAX)
3d59c1
+			    && getcwd(ctx->abs_mnt_point,
3d59c1
 				     PATH_MAX - strlen(opts.mnt_point) - 1)) {
3d59c1
 				strcat(ctx->abs_mnt_point, "/");
3d59c1
 				strcat(ctx->abs_mnt_point, opts.mnt_point);
3d59c1
@@ -4419,6 +4420,9 @@ int main(int argc, char *argv[])
3d59c1
 			/* Solaris also wants the absolute mount point */
3d59c1
 				opts.mnt_point = ctx->abs_mnt_point;
3d59c1
 #endif /* defined(__sun) && defined (__SVR4) */
3d59c1
+			} else {
3d59c1
+				free(ctx->abs_mnt_point);
3d59c1
+				ctx->abs_mnt_point = (char*)NULL;
3d59c1
 			}
3d59c1
 		}
3d59c1
 	}
3d59c1
diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c
3d59c1
index 6ce89fef..4e0912ae 100644
3d59c1
--- a/src/ntfs-3g.c
3d59c1
+++ b/src/ntfs-3g.c
3d59c1
@@ -4148,7 +4148,8 @@ int main(int argc, char *argv[])
3d59c1
 	else {
3d59c1
 		ctx->abs_mnt_point = (char*)ntfs_malloc(PATH_MAX);
3d59c1
 		if (ctx->abs_mnt_point) {
3d59c1
-			if (getcwd(ctx->abs_mnt_point,
3d59c1
+			if ((strlen(opts.mnt_point) < PATH_MAX)
3d59c1
+			    && getcwd(ctx->abs_mnt_point,
3d59c1
 				     PATH_MAX - strlen(opts.mnt_point) - 1)) {
3d59c1
 				strcat(ctx->abs_mnt_point, "/");
3d59c1
 				strcat(ctx->abs_mnt_point, opts.mnt_point);
3d59c1
@@ -4156,6 +4157,9 @@ int main(int argc, char *argv[])
3d59c1
 			/* Solaris also wants the absolute mount point */
3d59c1
 				opts.mnt_point = ctx->abs_mnt_point;
3d59c1
 #endif /* defined(__sun) && defined (__SVR4) */
3d59c1
+			} else {
3d59c1
+				free(ctx->abs_mnt_point);
3d59c1
+				ctx->abs_mnt_point = (char*)NULL;
3d59c1
 			}
3d59c1
 		}
3d59c1
 	}
3d59c1
-- 
3d59c1
2.20.1
3d59c1