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

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