Rebase to 2017.3.23.
Remove patches which are now upstream. Resynch with Fedora package. Enable all architectures for RHEL 8.
This commit is contained in:
parent
9729ef9f9c
commit
7ca90a0318
@ -1,172 +0,0 @@
|
||||
From d9c61dd60ec484909f70b7a916ada3a93af94b60 Mon Sep 17 00:00:00 2001
|
||||
From: Erik Larsson <mechie@users.sourceforge.net>
|
||||
Date: Fri, 8 Apr 2016 05:39:48 +0200
|
||||
Subject: [PATCH 1/2] unistr.c: Enable encoding broken UTF-16 into broken
|
||||
UTF-8, A.K.A. WTF-8.
|
||||
|
||||
Windows filenames may contain invalid UTF-16 sequences (specifically
|
||||
broken surrogate pairs), which cannot be converted to UTF-8 if we do
|
||||
strict conversion.
|
||||
|
||||
This patch enables encoding broken UTF-16 into similarly broken UTF-8 by
|
||||
encoding any surrogate character that don't have a match into a separate
|
||||
3-byte UTF-8 sequence.
|
||||
|
||||
This is "sort of" valid UTF-8, but not valid Unicode since the code
|
||||
points used for surrogate pair encoding are not supposed to occur in a
|
||||
valid Unicode string... but on the other hand the source UTF-16 data is
|
||||
also broken, so we aren't really making things any worse.
|
||||
|
||||
This format is sometimes referred to as WTF-8 (Wobbly Translation
|
||||
Format, 8-bit encoding) and is a common solution to represent broken
|
||||
UTF-16 as UTF-8.
|
||||
|
||||
It is a lossless round-trip conversion, i.e converting from broken
|
||||
UTF-16 to "WTF-8" and back to UTF-16 yields the same broken UTF-16
|
||||
sequence. Because of this property it enables accessing these files
|
||||
by filename through ntfs-3g and the ntfsprogs (e.g. ls -la works as
|
||||
expected).
|
||||
|
||||
To disable this behaviour you can pass the preprocessor/compiler flag
|
||||
'-DALLOW_BROKEN_SURROGATES=0' when building ntfs-3g.
|
||||
---
|
||||
libntfs-3g/unistr.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 65 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c
|
||||
index 7f278cd..71802aa 100644
|
||||
--- a/libntfs-3g/unistr.c
|
||||
+++ b/libntfs-3g/unistr.c
|
||||
@@ -61,6 +61,11 @@
|
||||
|
||||
#define NOREVBOM 0 /* JPA rejecting U+FFFE and U+FFFF, open to debate */
|
||||
|
||||
+#ifndef ALLOW_BROKEN_SURROGATES
|
||||
+/* Erik allowing broken UTF-16 surrogate pairs by default, open to debate. */
|
||||
+#define ALLOW_BROKEN_SURROGATES 1
|
||||
+#endif /* !defined(ALLOW_BROKEN_SURROGATES) */
|
||||
+
|
||||
/*
|
||||
* IMPORTANT
|
||||
* =========
|
||||
@@ -462,8 +467,22 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
if ((c >= 0xdc00) && (c < 0xe000)) {
|
||||
surrog = FALSE;
|
||||
count += 4;
|
||||
- } else
|
||||
+ } else {
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ /* The first UTF-16 unit of a surrogate pair has
|
||||
+ * a value between 0xd800 and 0xdc00. It can be
|
||||
+ * encoded as an individual UTF-8 sequence if we
|
||||
+ * cannot combine it with the next UTF-16 unit
|
||||
+ * unit as a surrogate pair. */
|
||||
+ surrog = FALSE;
|
||||
+ count += 3;
|
||||
+
|
||||
+ --i;
|
||||
+ continue;
|
||||
+#else
|
||||
goto fail;
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+ }
|
||||
} else
|
||||
if (c < 0x80)
|
||||
count++;
|
||||
@@ -473,6 +492,10 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
count += 3;
|
||||
else if (c < 0xdc00)
|
||||
surrog = TRUE;
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ else if (c < 0xe000)
|
||||
+ count += 3;
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
#if NOREVBOM
|
||||
else if ((c >= 0xe000) && (c < 0xfffe))
|
||||
#else
|
||||
@@ -487,7 +510,11 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
}
|
||||
}
|
||||
if (surrog)
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ count += 3; /* ending with a single surrogate */
|
||||
+#else
|
||||
goto fail;
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
|
||||
ret = count;
|
||||
out:
|
||||
@@ -548,8 +575,24 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
*t++ = 0x80 + ((c >> 6) & 15) + ((halfpair & 3) << 4);
|
||||
*t++ = 0x80 + (c & 63);
|
||||
halfpair = 0;
|
||||
- } else
|
||||
+ } else {
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ /* The first UTF-16 unit of a surrogate pair has
|
||||
+ * a value between 0xd800 and 0xdc00. It can be
|
||||
+ * encoded as an individual UTF-8 sequence if we
|
||||
+ * cannot combine it with the next UTF-16 unit
|
||||
+ * unit as a surrogate pair. */
|
||||
+ *t++ = 0xe0 | (halfpair >> 12);
|
||||
+ *t++ = 0x80 | ((halfpair >> 6) & 0x3f);
|
||||
+ *t++ = 0x80 | (halfpair & 0x3f);
|
||||
+ halfpair = 0;
|
||||
+
|
||||
+ --i;
|
||||
+ continue;
|
||||
+#else
|
||||
goto fail;
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+ }
|
||||
} else if (c < 0x80) {
|
||||
*t++ = c;
|
||||
} else {
|
||||
@@ -562,6 +605,13 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
*t++ = 0x80 | (c & 0x3f);
|
||||
} else if (c < 0xdc00)
|
||||
halfpair = c;
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ else if (c < 0xe000) {
|
||||
+ *t++ = 0xe0 | (c >> 12);
|
||||
+ *t++ = 0x80 | ((c >> 6) & 0x3f);
|
||||
+ *t++ = 0x80 | (c & 0x3f);
|
||||
+ }
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
else if (c >= 0xe000) {
|
||||
*t++ = 0xe0 | (c >> 12);
|
||||
*t++ = 0x80 | ((c >> 6) & 0x3f);
|
||||
@@ -570,6 +620,13 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ if (halfpair) { /* ending with a single surrogate */
|
||||
+ *t++ = 0xe0 | (halfpair >> 12);
|
||||
+ *t++ = 0x80 | ((halfpair >> 6) & 0x3f);
|
||||
+ *t++ = 0x80 | (halfpair & 0x3f);
|
||||
+ }
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
*t = '\0';
|
||||
|
||||
#if defined(__APPLE__) || defined(__DARWIN__)
|
||||
@@ -693,10 +750,16 @@ static int utf8_to_unicode(u32 *wc, const char *s)
|
||||
/* Check valid ranges */
|
||||
#if NOREVBOM
|
||||
if (((*wc >= 0x800) && (*wc <= 0xD7FF))
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ || ((*wc >= 0xD800) && (*wc <= 0xDFFF))
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
|| ((*wc >= 0xe000) && (*wc <= 0xFFFD)))
|
||||
return 3;
|
||||
#else
|
||||
if (((*wc >= 0x800) && (*wc <= 0xD7FF))
|
||||
+#if ALLOW_BROKEN_SURROGATES
|
||||
+ || ((*wc >= 0xD800) && (*wc <= 0xDFFF))
|
||||
+#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
|| ((*wc >= 0xe000) && (*wc <= 0xFFFF)))
|
||||
return 3;
|
||||
#endif
|
||||
--
|
||||
2.10.2
|
||||
|
@ -1,170 +0,0 @@
|
||||
From f0370bfa9c47575d4e47c94e443aa91983683a43 Mon Sep 17 00:00:00 2001
|
||||
From: Erik Larsson <mechie@users.sourceforge.net>
|
||||
Date: Tue, 12 Apr 2016 17:02:40 +0200
|
||||
Subject: [PATCH 2/2] unistr.c: Unify the two defines NOREVBOM and
|
||||
ALLOW_BROKEN_SURROGATES.
|
||||
|
||||
In the mailing list discussion we came to the conclusion that there
|
||||
doesn't seem to be any reason to keep these declarations separate since
|
||||
they address the same issue, namely libntfs-3g's tolerance for bad
|
||||
Unicode data in filenames and other UTF-16 strings in the file system,
|
||||
so merge the two defines into the new define ALLOW_BROKEN_UNICODE.
|
||||
---
|
||||
libntfs-3g/unistr.c | 58 +++++++++++++++++++++++------------------------------
|
||||
1 file changed, 25 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c
|
||||
index 71802aa..753acc0 100644
|
||||
--- a/libntfs-3g/unistr.c
|
||||
+++ b/libntfs-3g/unistr.c
|
||||
@@ -59,12 +59,11 @@
|
||||
#include "logging.h"
|
||||
#include "misc.h"
|
||||
|
||||
-#define NOREVBOM 0 /* JPA rejecting U+FFFE and U+FFFF, open to debate */
|
||||
-
|
||||
-#ifndef ALLOW_BROKEN_SURROGATES
|
||||
-/* Erik allowing broken UTF-16 surrogate pairs by default, open to debate. */
|
||||
-#define ALLOW_BROKEN_SURROGATES 1
|
||||
-#endif /* !defined(ALLOW_BROKEN_SURROGATES) */
|
||||
+#ifndef ALLOW_BROKEN_UNICODE
|
||||
+/* Erik allowing broken UTF-16 surrogate pairs and U+FFFE and U+FFFF by default,
|
||||
+ * open to debate. */
|
||||
+#define ALLOW_BROKEN_UNICODE 1
|
||||
+#endif /* !defined(ALLOW_BROKEN_UNICODE) */
|
||||
|
||||
/*
|
||||
* IMPORTANT
|
||||
@@ -468,7 +467,7 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
surrog = FALSE;
|
||||
count += 4;
|
||||
} else {
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
/* The first UTF-16 unit of a surrogate pair has
|
||||
* a value between 0xd800 and 0xdc00. It can be
|
||||
* encoded as an individual UTF-8 sequence if we
|
||||
@@ -481,7 +480,7 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
continue;
|
||||
#else
|
||||
goto fail;
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
}
|
||||
} else
|
||||
if (c < 0x80)
|
||||
@@ -492,15 +491,13 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
count += 3;
|
||||
else if (c < 0xdc00)
|
||||
surrog = TRUE;
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
else if (c < 0xe000)
|
||||
count += 3;
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
-#if NOREVBOM
|
||||
- else if ((c >= 0xe000) && (c < 0xfffe))
|
||||
-#else
|
||||
else if (c >= 0xe000)
|
||||
-#endif
|
||||
+#else
|
||||
+ else if ((c >= 0xe000) && (c < 0xfffe))
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
count += 3;
|
||||
else
|
||||
goto fail;
|
||||
@@ -510,11 +507,11 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
|
||||
}
|
||||
}
|
||||
if (surrog)
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
count += 3; /* ending with a single surrogate */
|
||||
#else
|
||||
goto fail;
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
|
||||
ret = count;
|
||||
out:
|
||||
@@ -576,7 +573,7 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
*t++ = 0x80 + (c & 63);
|
||||
halfpair = 0;
|
||||
} else {
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
/* The first UTF-16 unit of a surrogate pair has
|
||||
* a value between 0xd800 and 0xdc00. It can be
|
||||
* encoded as an individual UTF-8 sequence if we
|
||||
@@ -591,7 +588,7 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
continue;
|
||||
#else
|
||||
goto fail;
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
}
|
||||
} else if (c < 0x80) {
|
||||
*t++ = c;
|
||||
@@ -605,13 +602,13 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
*t++ = 0x80 | (c & 0x3f);
|
||||
} else if (c < 0xdc00)
|
||||
halfpair = c;
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
else if (c < 0xe000) {
|
||||
*t++ = 0xe0 | (c >> 12);
|
||||
*t++ = 0x80 | ((c >> 6) & 0x3f);
|
||||
*t++ = 0x80 | (c & 0x3f);
|
||||
}
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
else if (c >= 0xe000) {
|
||||
*t++ = 0xe0 | (c >> 12);
|
||||
*t++ = 0x80 | ((c >> 6) & 0x3f);
|
||||
@@ -620,13 +617,13 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
if (halfpair) { /* ending with a single surrogate */
|
||||
*t++ = 0xe0 | (halfpair >> 12);
|
||||
*t++ = 0x80 | ((halfpair >> 6) & 0x3f);
|
||||
*t++ = 0x80 | (halfpair & 0x3f);
|
||||
}
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
*t = '\0';
|
||||
|
||||
#if defined(__APPLE__) || defined(__DARWIN__)
|
||||
@@ -748,21 +745,16 @@ static int utf8_to_unicode(u32 *wc, const char *s)
|
||||
| ((u32)(s[1] & 0x3F) << 6)
|
||||
| ((u32)(s[2] & 0x3F));
|
||||
/* Check valid ranges */
|
||||
-#if NOREVBOM
|
||||
+#if ALLOW_BROKEN_UNICODE
|
||||
if (((*wc >= 0x800) && (*wc <= 0xD7FF))
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
|| ((*wc >= 0xD800) && (*wc <= 0xDFFF))
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
- || ((*wc >= 0xe000) && (*wc <= 0xFFFD)))
|
||||
- return 3;
|
||||
-#else
|
||||
- if (((*wc >= 0x800) && (*wc <= 0xD7FF))
|
||||
-#if ALLOW_BROKEN_SURROGATES
|
||||
- || ((*wc >= 0xD800) && (*wc <= 0xDFFF))
|
||||
-#endif /* ALLOW_BROKEN_SURROGATES */
|
||||
|| ((*wc >= 0xe000) && (*wc <= 0xFFFF)))
|
||||
return 3;
|
||||
-#endif
|
||||
+#else
|
||||
+ if (((*wc >= 0x800) && (*wc <= 0xD7FF))
|
||||
+ || ((*wc >= 0xe000) && (*wc <= 0xFFFD)))
|
||||
+ return 3;
|
||||
+#endif /* ALLOW_BROKEN_UNICODE */
|
||||
}
|
||||
goto fail;
|
||||
/* four-byte */
|
||||
--
|
||||
2.10.2
|
||||
|
12
check-mftmirr.patch
Normal file
12
check-mftmirr.patch
Normal file
@ -0,0 +1,12 @@
|
||||
--- libntfs-3g/volume.c.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ libntfs-3g/volume.c 2017-12-20 08:11:51.842424300 +0100
|
||||
@@ -959,7 +959,8 @@
|
||||
vol->mftmirr_size = l;
|
||||
}
|
||||
ntfs_log_debug("Comparing $MFTMirr to $MFT...\n");
|
||||
- for (i = 0; i < vol->mftmirr_size; ++i) {
|
||||
+ /* Windows 10 does not update the full $MFTMirr any more */
|
||||
+ for (i = 0; (i < vol->mftmirr_size) && (i < FILE_first_user); ++i) {
|
||||
MFT_RECORD *mrec, *mrec2;
|
||||
const char *ESTR[12] = { "$MFT", "$MFTMirr", "$LogFile",
|
||||
"$Volume", "$AttrDef", "root directory", "$Bitmap",
|
@ -1,11 +1,11 @@
|
||||
%global ntfs_version 2015.3.14
|
||||
%global ntfs_version 2017.3.23
|
||||
|
||||
# debuginfo makes no sense for this package, so disable it
|
||||
%global debug_package %{nil}
|
||||
|
||||
Name: libguestfs-winsupport
|
||||
Version: 7.2
|
||||
Release: 3%{?dist}
|
||||
Version: 8.0
|
||||
Release: 1%{?dist}
|
||||
Summary: Add support for Windows guests to virt-v2v and virt-p2v
|
||||
|
||||
URL: http://www.ntfs-3g.org/
|
||||
@ -13,17 +13,14 @@ License: GPLv2+
|
||||
|
||||
# This package shouldn't be installed without installing the base
|
||||
# libguestfs package.
|
||||
Requires: libguestfs >= 1:1.28.1
|
||||
Requires: libguestfs >= 1:1.38.2
|
||||
|
||||
# Source and patches for ntfs. Try to keep this in step with Fedora.
|
||||
Source0: http://tuxera.com/opensource/ntfs-3g_ntfsprogs-%{ntfs_version}.tgz
|
||||
|
||||
Patch0: ntfs-3g_ntfsprogs-2011.10.9-RC-ntfsck-unsupported-return-0.patch
|
||||
Patch1: CVE-2015-3202.patch
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1301593#c8
|
||||
Patch2: 0001-unistr.c-Enable-encoding-broken-UTF-16-into-broken-U.patch
|
||||
Patch3: 0002-unistr.c-Unify-the-two-defines-NOREVBOM-and-ALLOW_BR.patch
|
||||
|
||||
Patch1: check-mftmirr.patch
|
||||
Patch2: ntfs-3g-big-sectors.patch
|
||||
BuildRequires: libtool, libattr-devel
|
||||
BuildRequires: libconfig-devel, libgcrypt-devel, gnutls-devel, libuuid-devel
|
||||
|
||||
@ -36,9 +33,8 @@ virt-v2v and virt-p2v programs.
|
||||
%prep
|
||||
%setup -q -n ntfs-3g_ntfsprogs-%{ntfs_version}
|
||||
%patch0 -p1 -b .unsupported
|
||||
%patch1 -p1 -b .cve
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch1 -p0 -b .check-mftmirr
|
||||
%patch2 -p0 -b .big-sectors
|
||||
|
||||
|
||||
%build
|
||||
@ -47,6 +43,8 @@ CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
|
||||
--disable-static \
|
||||
--disable-ldconfig \
|
||||
--exec-prefix=/ \
|
||||
--enable-posix-acls \
|
||||
--enable-xattr-mappings \
|
||||
--enable-crypto \
|
||||
--enable-extras \
|
||||
--enable-quarantined
|
||||
@ -100,7 +98,10 @@ popd
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Jul 11 2018 Richard W.M. Jones <rjones@redhat.com> - 7.2-3
|
||||
* Wed Jul 11 2018 Richard W.M. Jones <rjones@redhat.com> - 8.0-1
|
||||
- Rebase to 2017.3.23.
|
||||
- Remove patches which are now upstream.
|
||||
- Resynch with Fedora package.
|
||||
- Enable all architectures for RHEL 8.
|
||||
|
||||
* Wed Feb 22 2017 Richard W.M. Jones <rjones@redhat.com> - 7.2-2
|
||||
|
379
ntfs-3g-big-sectors.patch
Normal file
379
ntfs-3g-big-sectors.patch
Normal file
@ -0,0 +1,379 @@
|
||||
--- libntfs-3g/bootsect.c.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ libntfs-3g/bootsect.c 2018-05-07 09:11:13.004710800 +0200
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
+#include "param.h"
|
||||
#include "compat.h"
|
||||
#include "bootsect.h"
|
||||
#include "debug.h"
|
||||
@@ -61,6 +62,7 @@
|
||||
{
|
||||
u32 i;
|
||||
BOOL ret = FALSE;
|
||||
+ u16 sectors_per_cluster;
|
||||
|
||||
ntfs_log_debug("Beginning bootsector check.\n");
|
||||
|
||||
@@ -83,15 +85,27 @@
|
||||
case 1: case 2: case 4: case 8: case 16: case 32: case 64: case 128:
|
||||
break;
|
||||
default:
|
||||
- ntfs_log_error("Unexpected sectors per cluster value (%d).\n",
|
||||
- b->bpb.sectors_per_cluster);
|
||||
- goto not_ntfs;
|
||||
+ if ((b->bpb.sectors_per_cluster < 240)
|
||||
+ || (b->bpb.sectors_per_cluster > 249)) {
|
||||
+ if (b->bpb.sectors_per_cluster > 128)
|
||||
+ ntfs_log_error("Unexpected sectors"
|
||||
+ " per cluster value (code 0x%x)\n",
|
||||
+ b->bpb.sectors_per_cluster);
|
||||
+ else
|
||||
+ ntfs_log_error("Unexpected sectors"
|
||||
+ " per cluster value (%d).\n",
|
||||
+ b->bpb.sectors_per_cluster);
|
||||
+ goto not_ntfs;
|
||||
+ }
|
||||
}
|
||||
|
||||
ntfs_log_debug("Checking cluster size.\n");
|
||||
- i = (u32)le16_to_cpu(b->bpb.bytes_per_sector) *
|
||||
- b->bpb.sectors_per_cluster;
|
||||
- if (i > 65536) {
|
||||
+ if (b->bpb.sectors_per_cluster > 128)
|
||||
+ sectors_per_cluster = 1 << (256 - b->bpb.sectors_per_cluster);
|
||||
+ else
|
||||
+ sectors_per_cluster = b->bpb.sectors_per_cluster;
|
||||
+ i = (u32)le16_to_cpu(b->bpb.bytes_per_sector) * sectors_per_cluster;
|
||||
+ if (i > NTFS_MAX_CLUSTER_SIZE) {
|
||||
ntfs_log_error("Unexpected cluster size (%d).\n", i);
|
||||
goto not_ntfs;
|
||||
}
|
||||
@@ -171,7 +185,7 @@
|
||||
int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
|
||||
{
|
||||
s64 sectors;
|
||||
- u8 sectors_per_cluster;
|
||||
+ u16 sectors_per_cluster;
|
||||
s8 c;
|
||||
|
||||
/* We return -1 with errno = EINVAL on error. */
|
||||
@@ -186,7 +200,10 @@
|
||||
* below or equal the number_of_clusters) really belong in the
|
||||
* ntfs_boot_sector_is_ntfs but in this way we can just do this once.
|
||||
*/
|
||||
- sectors_per_cluster = bs->bpb.sectors_per_cluster;
|
||||
+ if (bs->bpb.sectors_per_cluster > 128)
|
||||
+ sectors_per_cluster = 1 << (256 - bs->bpb.sectors_per_cluster);
|
||||
+ else
|
||||
+ sectors_per_cluster = bs->bpb.sectors_per_cluster;
|
||||
ntfs_log_debug("SectorsPerCluster = 0x%x\n", sectors_per_cluster);
|
||||
if (sectors_per_cluster & (sectors_per_cluster - 1)) {
|
||||
ntfs_log_error("sectors_per_cluster (%d) is not a power of 2."
|
||||
--- ntfsprogs/mkntfs.8.in.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ ntfsprogs/mkntfs.8.in 2018-05-07 09:11:13.014132400 +0200
|
||||
@@ -132,7 +132,7 @@
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-cluster\-size\fR BYTES
|
||||
Specify the size of clusters in bytes. Valid cluster size values are powers of
|
||||
-two, with at least 256, and at most 65536 bytes per cluster. If omitted,
|
||||
+two, with at least 256, and at most 2097152 bytes (2MB) per cluster. If omitted,
|
||||
.B mkntfs
|
||||
uses 4096 bytes as the default cluster size.
|
||||
.sp
|
||||
--- ntfsprogs/mkntfs.c.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ ntfsprogs/mkntfs.c 2018-05-07 09:11:13.035522300 +0200
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 2002-2006 Szabolcs Szakacsits
|
||||
* Copyright (c) 2005 Erik Sornes
|
||||
* Copyright (c) 2007 Yura Pakhuchiy
|
||||
- * Copyright (c) 2010-2014 Jean-Pierre Andre
|
||||
+ * Copyright (c) 2010-2018 Jean-Pierre Andre
|
||||
*
|
||||
* This utility will create an NTFS 1.2 or 3.1 volume on a user
|
||||
* specified (block) device.
|
||||
@@ -119,6 +119,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
+#include "param.h"
|
||||
#include "security.h"
|
||||
#include "types.h"
|
||||
#include "attrib.h"
|
||||
@@ -287,7 +288,7 @@
|
||||
ntfs_log_info("Copyright (c) 2002-2006 Szabolcs Szakacsits\n");
|
||||
ntfs_log_info("Copyright (c) 2005 Erik Sornes\n");
|
||||
ntfs_log_info("Copyright (c) 2007 Yura Pakhuchiy\n");
|
||||
- ntfs_log_info("Copyright (c) 2010-2014 Jean-Pierre Andre\n");
|
||||
+ ntfs_log_info("Copyright (c) 2010-2018 Jean-Pierre Andre\n");
|
||||
ntfs_log_info("\n%s\n%s%s\n", ntfs_gpl, ntfs_bugs, ntfs_home);
|
||||
}
|
||||
|
||||
@@ -3719,11 +3720,11 @@
|
||||
/*
|
||||
* For huge volumes, grow the cluster size until the number of
|
||||
* clusters fits into 32 bits or the cluster size exceeds the
|
||||
- * maximum limit of 64kiB.
|
||||
+ * maximum limit of NTFS_MAX_CLUSTER_SIZE.
|
||||
*/
|
||||
while (volume_size >> (ffs(vol->cluster_size) - 1 + 32)) {
|
||||
vol->cluster_size <<= 1;
|
||||
- if (vol->cluster_size > 65535) {
|
||||
+ if (vol->cluster_size >= NTFS_MAX_CLUSTER_SIZE) {
|
||||
ntfs_log_error("Device is too large to hold an "
|
||||
"NTFS volume (maximum size is "
|
||||
"256TiB).\n");
|
||||
@@ -3744,15 +3745,18 @@
|
||||
"to, or larger than, the sector size.\n");
|
||||
return FALSE;
|
||||
}
|
||||
- if (vol->cluster_size > 128 * (u32)opts.sector_size) {
|
||||
+ /* Before Windows 10 Creators, the limit was 128 */
|
||||
+ if (vol->cluster_size > 4096 * (u32)opts.sector_size) {
|
||||
ntfs_log_error("The cluster size is invalid. It cannot be "
|
||||
- "more that 128 times the size of the sector "
|
||||
+ "more that 4096 times the size of the sector "
|
||||
"size.\n");
|
||||
return FALSE;
|
||||
}
|
||||
- if (vol->cluster_size > 65536) {
|
||||
+ if (vol->cluster_size > NTFS_MAX_CLUSTER_SIZE) {
|
||||
ntfs_log_error("The cluster size is invalid. The maximum "
|
||||
- "cluster size is 65536 bytes (64kiB).\n");
|
||||
+ "cluster size is %lu bytes (%lukiB).\n",
|
||||
+ (unsigned long)NTFS_MAX_CLUSTER_SIZE,
|
||||
+ (unsigned long)(NTFS_MAX_CLUSTER_SIZE >> 10));
|
||||
return FALSE;
|
||||
}
|
||||
vol->cluster_size_bits = ffs(vol->cluster_size) - 1;
|
||||
@@ -4387,6 +4391,7 @@
|
||||
u8 *sd;
|
||||
FILE_ATTR_FLAGS extend_flags;
|
||||
VOLUME_FLAGS volume_flags = const_cpu_to_le16(0);
|
||||
+ int sectors_per_cluster;
|
||||
int nr_sysfiles;
|
||||
int buf_sds_first_size;
|
||||
char *buf_sds;
|
||||
@@ -4639,8 +4644,11 @@
|
||||
* already inserted, so no need to worry about these things.
|
||||
*/
|
||||
bs->bpb.bytes_per_sector = cpu_to_le16(opts.sector_size);
|
||||
- bs->bpb.sectors_per_cluster = (u8)(g_vol->cluster_size /
|
||||
- opts.sector_size);
|
||||
+ sectors_per_cluster = g_vol->cluster_size / opts.sector_size;
|
||||
+ if (sectors_per_cluster > 128)
|
||||
+ bs->bpb.sectors_per_cluster = 257 - ffs(sectors_per_cluster);
|
||||
+ else
|
||||
+ bs->bpb.sectors_per_cluster = sectors_per_cluster;
|
||||
bs->bpb.media_type = 0xf8; /* hard disk */
|
||||
bs->bpb.sectors_per_track = cpu_to_le16(opts.sectors_per_track);
|
||||
ntfs_log_debug("sectors per track = %ld (0x%lx)\n",
|
||||
--- ntfsprogs/ntfsclone.c.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ ntfsprogs/ntfsclone.c 2018-05-07 09:11:38.245007100 +0200
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2003-2006 Szabolcs Szakacsits
|
||||
* Copyright (c) 2004-2006 Anton Altaparmakov
|
||||
- * Copyright (c) 2010-2016 Jean-Pierre Andre
|
||||
+ * Copyright (c) 2010-2018 Jean-Pierre Andre
|
||||
* Special image format support copyright (c) 2004 Per Olofsson
|
||||
*
|
||||
* Clone NTFS data and/or metadata to a sparse file, image, device or stdout.
|
||||
@@ -71,6 +71,7 @@
|
||||
*/
|
||||
#define NTFS_DO_NOT_CHECK_ENDIANS
|
||||
|
||||
+#include "param.h"
|
||||
#include "debug.h"
|
||||
#include "types.h"
|
||||
#include "support.h"
|
||||
@@ -270,7 +271,6 @@
|
||||
|
||||
#define LAST_METADATA_INODE 11
|
||||
|
||||
-#define NTFS_MAX_CLUSTER_SIZE 65536
|
||||
#define NTFS_SECTOR_SIZE 512
|
||||
|
||||
#define rounded_up_division(a, b) (((a) + (b - 1)) / (b))
|
||||
@@ -393,7 +393,7 @@
|
||||
"Efficiently clone, image, restore or rescue an NTFS Volume.\n\n"
|
||||
"Copyright (c) 2003-2006 Szabolcs Szakacsits\n"
|
||||
"Copyright (c) 2004-2006 Anton Altaparmakov\n"
|
||||
- "Copyright (c) 2010-2016 Jean-Pierre Andre\n\n");
|
||||
+ "Copyright (c) 2010-2018 Jean-Pierre Andre\n\n");
|
||||
fprintf(stderr, "%s\n%s%s", ntfs_gpl, ntfs_bugs, ntfs_home);
|
||||
exit(0);
|
||||
}
|
||||
@@ -756,7 +756,7 @@
|
||||
|
||||
static void copy_cluster(int rescue, u64 rescue_lcn, u64 lcn)
|
||||
{
|
||||
- char buff[NTFS_MAX_CLUSTER_SIZE]; /* overflow checked at mount time */
|
||||
+ char *buff;
|
||||
/* vol is NULL if opt.restore_image is set */
|
||||
s32 csize = le32_to_cpu(image_hdr.cluster_size);
|
||||
BOOL backup_bootsector;
|
||||
@@ -783,6 +783,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ buff = (char*)ntfs_malloc(csize);
|
||||
+ if (!buff)
|
||||
+ err_exit("Not enough memory");
|
||||
+
|
||||
// need reading when not about to write ?
|
||||
if (read_all(fd, buff, csize) == -1) {
|
||||
|
||||
@@ -858,6 +862,7 @@
|
||||
perr_printf("Write failed");
|
||||
#endif
|
||||
}
|
||||
+ free(buff);
|
||||
}
|
||||
|
||||
static s64 lseek_out(int fd, s64 pos, int mode)
|
||||
@@ -995,7 +1000,11 @@
|
||||
struct progress_bar *progress, u64 *p_counter)
|
||||
{
|
||||
s64 i;
|
||||
- char buff[NTFS_MAX_CLUSTER_SIZE];
|
||||
+ char *buff;
|
||||
+
|
||||
+ buff = (char*)ntfs_malloc(csize);
|
||||
+ if (!buff)
|
||||
+ err_exit("Not enough memory");
|
||||
|
||||
memset(buff, 0, csize);
|
||||
|
||||
@@ -1004,6 +1013,7 @@
|
||||
perr_exit("write_all");
|
||||
progress_update(progress, ++(*p_counter));
|
||||
}
|
||||
+ free(buff);
|
||||
}
|
||||
|
||||
static void restore_image(void)
|
||||
@@ -1492,7 +1502,7 @@
|
||||
|
||||
static void copy_wipe_mft(ntfs_walk_clusters_ctx *image, runlist *rl)
|
||||
{
|
||||
- char buff[NTFS_MAX_CLUSTER_SIZE]; /* overflow checked at mount time */
|
||||
+ char *buff;
|
||||
void *fd;
|
||||
s64 mft_no;
|
||||
u32 mft_record_size;
|
||||
@@ -1522,6 +1532,10 @@
|
||||
clusters_per_set = mft_record_size/csize;
|
||||
records_per_set = 1;
|
||||
}
|
||||
+ buff = (char*)ntfs_malloc(mft_record_size);
|
||||
+ if (!buff)
|
||||
+ err_exit("Not enough memory");
|
||||
+
|
||||
mft_no = 0;
|
||||
ri = rj = 0;
|
||||
wi = wj = 0;
|
||||
@@ -1554,6 +1568,7 @@
|
||||
}
|
||||
}
|
||||
image->current_lcn = current_lcn;
|
||||
+ free(buff);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1566,7 +1581,7 @@
|
||||
|
||||
static void copy_wipe_i30(ntfs_walk_clusters_ctx *image, runlist *rl)
|
||||
{
|
||||
- char buff[NTFS_MAX_CLUSTER_SIZE]; /* overflow checked at mount time */
|
||||
+ char *buff;
|
||||
void *fd;
|
||||
u32 indx_record_size;
|
||||
u32 csize;
|
||||
@@ -1595,6 +1610,10 @@
|
||||
clusters_per_set = indx_record_size/csize;
|
||||
records_per_set = 1;
|
||||
}
|
||||
+ buff = (char*)ntfs_malloc(indx_record_size);
|
||||
+ if (!buff)
|
||||
+ err_exit("Not enough memory");
|
||||
+
|
||||
ri = rj = 0;
|
||||
wi = wj = 0;
|
||||
if (rl[ri].length)
|
||||
@@ -1627,6 +1646,7 @@
|
||||
}
|
||||
}
|
||||
image->current_lcn = current_lcn;
|
||||
+ free(buff);
|
||||
}
|
||||
|
||||
static void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
|
||||
--- ntfsprogs/ntfsresize.c.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ ntfsprogs/ntfsresize.c 2018-05-07 09:11:13.076883400 +0200
|
||||
@@ -59,6 +59,7 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
+#include "param.h"
|
||||
#include "debug.h"
|
||||
#include "types.h"
|
||||
#include "support.h"
|
||||
@@ -243,8 +244,6 @@
|
||||
#define DIRTY_INODE (1)
|
||||
#define DIRTY_ATTRIB (2)
|
||||
|
||||
-#define NTFS_MAX_CLUSTER_SIZE (65536)
|
||||
-
|
||||
static s64 rounded_up_division(s64 numer, s64 denom)
|
||||
{
|
||||
return (numer + (denom - 1)) / denom;
|
||||
@@ -404,7 +403,7 @@
|
||||
printf("Copyright (c) 2002-2005 Anton Altaparmakov\n");
|
||||
printf("Copyright (c) 2002-2003 Richard Russon\n");
|
||||
printf("Copyright (c) 2007 Yura Pakhuchiy\n");
|
||||
- printf("Copyright (c) 2011-2016 Jean-Pierre Andre\n");
|
||||
+ printf("Copyright (c) 2011-2018 Jean-Pierre Andre\n");
|
||||
printf("\n%s\n%s%s", ntfs_gpl, ntfs_bugs, ntfs_home);
|
||||
}
|
||||
|
||||
@@ -1849,9 +1848,13 @@
|
||||
static void copy_clusters(ntfs_resize_t *resize, s64 dest, s64 src, s64 len)
|
||||
{
|
||||
s64 i;
|
||||
- char buff[NTFS_MAX_CLUSTER_SIZE]; /* overflow checked at mount time */
|
||||
+ char *buff;
|
||||
ntfs_volume *vol = resize->vol;
|
||||
|
||||
+ buff = (char*)ntfs_malloc(vol->cluster_size);
|
||||
+ if (!buff)
|
||||
+ perr_exit("ntfs_malloc");
|
||||
+
|
||||
for (i = 0; i < len; i++) {
|
||||
|
||||
lseek_to_cluster(vol, src + i);
|
||||
@@ -1875,6 +1878,7 @@
|
||||
resize->relocations++;
|
||||
progress_update(&resize->progress, resize->relocations);
|
||||
}
|
||||
+ free(buff);
|
||||
}
|
||||
|
||||
static void relocate_clusters(ntfs_resize_t *r, runlist *dest_rl, s64 src_lcn)
|
||||
--- include/ntfs-3g/param.h.ref 2017-03-23 10:42:44.000000000 +0100
|
||||
+++ include/ntfs-3g/param.h 2018-05-07 09:11:13.088302600 +0200
|
||||
@@ -40,6 +40,13 @@
|
||||
};
|
||||
|
||||
/*
|
||||
+ * Parameters for formatting
|
||||
+ */
|
||||
+
|
||||
+ /* Up to Windows 10, the cluster size was limited to 64K */
|
||||
+#define NTFS_MAX_CLUSTER_SIZE 2097152 /* Windows 10 Creators allows 2MB */
|
||||
+
|
||||
+/*
|
||||
* Parameters for compression
|
||||
*/
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (ntfs-3g_ntfsprogs-2015.3.14.tgz) = 9744dee814e89a97050bc8beb76f1a7d8a585e7d7740e8041e393c6912c93e49803f9b41af84e8315b3162e58b19ca8d155d435395cb07ecaa7de9caaf2af441
|
||||
SHA512 (ntfs-3g_ntfsprogs-2017.3.23.tgz) = 3a607f0d7be35204c992d8931de0404fbc52032c13b4240d2c5e6f285c318a28eb2a385d7cf5ac4cd445876aee5baa5753bb636ada0d870d84a9d3fdbce794ef
|
||||
|
Loading…
Reference in New Issue
Block a user