Commit Graph

4941 Commits

Author SHA1 Message Date
Jean-Pierre André
1b8b599408 Checked the number of subauthorities before accessing them
Be more crash resistent when analyzing a badly formed SID.
(contributed by Ulf Zibis)
2016-05-04 09:27:32 +02:00
Jean-Pierre André
d587ff54f9 Fixed segmentation fault on empty $LogFile in ntfsrecover
ntfsrecover -f -v <log file> receives a SIGSEGV because of trying to
read memory outside allocated buffer because of no sanity checks on
restart page header values. This happens on an empty $LogFile because
of no basic checks present. Attached patch adds basic checks similar
to those inside logfile library and allows tool to exit with more
suitable message.
(contributed by Rakesh Pandit)
2016-05-04 09:24:51 +02:00
Jean-Pierre André
1840b52d12 Fixed a missing "break" in ntfssecaudit.c
A missing "break" in a case construct could be troublesome.
(suggested by Ulf Zibis)
2016-05-04 09:19:39 +02:00
Jean-Pierre André
df7f3b9151 Fixed indentation in ntfssecaudit.c (cosmetic)
There was an abusive indentation.
2016-05-04 09:15:43 +02:00
Erik Larsson
f0370bfa9c 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.
2016-04-12 17:02:40 +02:00
Erik Larsson
d9c61dd60e 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.
2016-04-08 05:39:48 +02:00
Jean-Pierre André
ebdff7d4ee Deleted file secaudit.h
The declarations for compiling secaudit on Windows are not used any more
and can be dropped.
2016-04-07 09:36:01 +02:00
Jean-Pierre André
48e1c132c7 Removed declarations for using acls.c outside ntfs-3g
The declarations for using acls.c within secaudit on Windows are not used
any more and can be dropped.
2016-04-07 09:32:26 +02:00
Jean-Pierre André
3d7a28bfa5 Adapted secaudit and usermap (now ntfssecaudit and ntfsusermap) to ntfsprogs
These tools were originally developed for running on Windows and later
ported to libntfs-3g. This patch makes them similar to other ntfsprogs
tools, dropping the native Windows interfaces and using libntfs-3g on
all platforms.

There is no change in usage or supported features, only the command
names have changed.
2016-04-07 09:20:23 +02:00
Jean-Pierre André
0ded128808 Moved secaudit and usermap to directory ntfsprogs
These tools were developped before the ntfsprogs were merged into ntfs-3g,
redesigning them like the ntfsprogs make the code simpler.

Note : at this stage secaudit and usermap cannot be built any more.
2016-04-07 09:07:13 +02:00
Jean-Pierre André
7917a0a6cc Fixed indentation in ntfsclone help text (cosmetic)
The tabs in source code appear differently in actual output.
2016-04-06 11:09:35 +02:00
Jean-Pierre André
18a66b7a9a Fixed a spelling error in ntfsresize manual (cosmetic)
an other -> another
2016-04-06 11:07:30 +02:00
Jean-Pierre André
3cc22ba329 Moved general declarations from ntfsrecover.h to logfile.h
The declarations related to the log file structure are now grouped
in logfile.h, those specific to the recovery process are kept in
ntfsrecover.h
2016-04-06 11:03:31 +02:00
Jean-Pierre André
9693dd2fc1 Added a usn field to RESTART_PAGE_HEADER
Prepare merging ntfsrecover.h into logfile.h by adding a usn field to
RESTART_PAGE_HEADER. As this changes the record size, ignore the new
field in existing code.
2016-04-06 10:58:25 +02:00
Jean-Pierre André
60ba821ece Renamed reserved fields in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by naming reserved fields
the same way.
2016-04-06 10:54:51 +02:00
Jean-Pierre André
234cae2a1b Renamed record_length as log_record_header_length in ntfsrecover.h
Prepare merging ntfsrecover.h into logfile.h by naming the record
header length the same way.
2016-04-06 10:52:18 +02:00
Jean-Pierre André
b977f18c6e Renamed restart_offset as restart_area_offset in ntfsrecover.h
Prepare merging ntfsrecover.h into logfile.h by renaming the restart
offset the same way.
2016-04-06 10:50:31 +02:00
Jean-Pierre André
ad59ecec3f Redefined target_vcn on 64 bits in ntfsrecover.h
In a log record, the target vcn has to be stored on 64 bits
2016-04-06 10:45:30 +02:00
Jean-Pierre André
044f2104f9 Redefined file_offset on 64 bits in ntfsrecover.h
The log file offsets are apparently stored on 64 bits, though the file
size is unlikely to reach 2MB.
2016-04-06 10:40:28 +02:00
Jean-Pierre André
d947ffa834 Unfolded record headers in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by unfolding the record
headers the same way.
2016-04-06 10:38:06 +02:00
Jean-Pierre André
a6f4bae6d5 Typedef'ed new structs in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by declaring new structs
the same was as in logfile.h
2016-04-06 10:34:46 +02:00
Jean-Pierre André
2ab8bb509a Typedef'ed old structs in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by declaring duplicated
structs the same way
2016-04-06 10:32:39 +02:00
Jean-Pierre André
71b03fbd16 Redefined ntfsrecover enums as little-endian values
Rather than cpu-endian values, use little-endian ones in ntfsrecover
for similarity with layout.h
2016-04-06 10:26:46 +02:00
Jean-Pierre André
88451c8069 Made a full check for whether a user extended attribute is allowed
User extended attributes should only be set on files and directories,
not on symlinks, sockets, devices, etc. For safety they are also
forbidden on metadata files, but should be allowed on the root
directory. For files based on reparse points, requests are made
to the plugin to determine the type.
2016-04-06 10:17:27 +02:00
Jean-Pierre André
6cb8913967 Translated directory separators when running ntfscluster on Windows
Use \ as a directory separator when running on Windows.
2016-04-06 10:11:08 +02:00
Jean-Pierre André
31430ae01a Returned an error code for an exclusive access violation on Windows
Translate to Windows error code STATUS_SHARING_VIOLATION to Unix error
code EBUSY.
2016-04-06 10:08:01 +02:00
Jean-Pierre André
e8170f588f Fixed the maximum size of an ACL
Define the maximum size of an ACL as results from the maximum number of
sub-authorities defined in layout.h
2016-04-06 10:02:23 +02:00
Jean-Pierre André
6c768f215d Used a more portable way to force alignment in security.h
Defining an array of zero elements does not force alignment on some CPUs,
insert a filler.
2016-04-06 09:57:59 +02:00
Jean-Pierre André
8a1358fff4 Enabled fallback to read-only mount when volume is hibernated
When a volume is found hibernated (or prepared for fast restarting),
it is force-mounted as read-only.
2016-04-06 09:51:47 +02:00
Jean-Pierre André
887d8f8294 Allowed kernel cacheing by lowntfs-3g when not using Posix ACLs
Kernel cacheing of file attributes is usually not used by ntfs-3g,
because it has defects when dealing with hard linked files and directory
permission checks. Kernel cacheing is however possible when using
lowntfs-3g and not using Posix ACLs.
2016-04-06 09:44:59 +02:00
Jean-Pierre André
fc666cb0b9 Fixed bad test in fuse mount
Apply a fix from the full fuse library
2016-04-06 09:42:16 +02:00
Jean-Pierre André
366c20e8a2 Silenced fixup warnings when allocating a new MFT record
When creating a new MFT record, do not issue a warning if the current
record has bad fixups. These warnings are meaningless, difficult to
interpret and cause unneeded worries.
2016-04-06 09:32:18 +02:00
Jean-Pierre André
b6b100b588 Added clarification about creating a partition to the ntfsclone manual
Try to make clear the option --output feeds data into a partition, but
does not create the partition.
2016-04-06 09:27:07 +02:00
Jean-Pierre André
da33b0328f Used plugins to process reparse points
The new "system compression" files used by Windows 10 make use of reparse
points to record the compression parameters, and a specific named data
stream is used to store the compressed data. With this patch, processing
of reparse points can be done by an external plugin only loaded as needed.
Junctions and symlinks, which are also based on reparse points, are now
processed by "internal plugins".
2016-04-06 09:10:35 +02:00
Jean-Pierre André
8e550e712d Added an option for preserving the full log file in ntfsclone
Usually, only a few pages of the Windows log file are saved in an
ntfsclone image. This is inappropriate for building reference images
for recovering the log, and the --full-logfile option serves that
purpose.
2016-04-06 08:51:36 +02:00
Jean-Pierre André
8fc9c96305 Reworked decisions to undo related to unreadable records
When an INDX or MFT record could not be read while undoing the creation
of this record, there is nothing to do. However if this was undoing the
deletion of the last entry in an index, a new void index block has to be
created.
2016-04-06 08:44:38 +02:00
Jean-Pierre André
6b5e47f094 Version 2016.2.22 2016-02-22 08:28:50 +01:00
Erik Larsson
038a45a8a1 Fix compilation errors on OpenIndiana caused by missing limit macros. 2016-02-16 20:43:00 +01:00
Erik Larsson
9d1360b282 endians.h: Fix bad assumption of valid __BYTE_ORDER__ values.
On the OpenIndiana Hipster distribution, compiling with GCC 4.9 would
fail because __BYTE_ORDER__ was defined but not to any of the values
assumed to be associated with this define (__LITTLE_ENDIAN__ or
__BIG_ENDIAN__). Instead it was defined to either
__ORDER_LITTLE_ENDIAN__ or __ORDER_BIG_ENDIAN__. This caused
compilation to fail.

Fixed by checking that all referenced defines are in fact defined
before using them and adding an additional #elif clause for this newly
discovered condition.
2016-02-16 20:29:56 +01:00
Erik Larsson
9dee659190 ntfsrecover.c: Fix compiler warning about uninitialized 'savebuf' usage.
The previous fix for the warning referred to 'prevbuf' being used
uninitialized and this is also what the compiler says. However
initializing 'prevbuf' doesn't make the warning go away and further
testing revealed that it is really 'savebuf' being possibly used prior
to initialization that is the source of the warning (the incorrect
warning message is probably an optimization-related gcc bug). So replace
previous ineffective fix with explicit initialization of 'savebuf'.
2016-02-16 09:38:12 +01:00
Erik Larsson
62b5c91420 Fix compiler warnings about mismatching printf format / argument type.
For 64-bit (e.g. x86_64) Linux the 64-bit wide types resolve to long,
not long long as is the case in 32-bit (e.g. i386) Linux. So we need an
explicit cast to long long for 64-bit types since the format string must
specify the 'll' modifier in order to print 64-bit values.
2016-02-16 09:30:49 +01:00
Jean-Pierre André
1ae297378c Version 2016.2.15 2016-02-15 16:32:03 +01:00
Jean-Pierre André
4f6fb651c2 Silenced a compiler warning for possibly uninitialized pointer
Some compilers issue a warning when a pointer is initialized in
both alternatives of a condition. Force an extra initialization
to avoid such warnings.
2016-02-15 12:07:28 +01:00
Jean-Pierre André
941ec4762f Silenced a compiler warning for different types
Some compilers issue a warning when the alternatives in a "? :"
expression have different signedness.
2016-02-15 12:02:10 +01:00
Jean-Pierre André
d2197785f4 Avoided pointer cast when checking record types
Some compilers issue warning when casting a pointer to a pointer to
a different type.
When checking a record magic, there is no need to cast pointers.
2016-02-15 11:54:33 +01:00
Jean-Pierre André
f655192f26 Updated the drivers copyrights
Extend the copyright to 2016
2016-02-12 17:24:27 +01:00
Jean-Pierre André
6548d91f73 Closed the volume when a resizing is done
Closing the volume is the way to sync the MFT to disk. When not doing
so, the MFT runlists in $DATA and $Bitmap are not synced if they have
been updated in the second resizing stage relative to runlists which
have grown outside their original MFT record.
2016-02-12 17:13:21 +01:00
Jean-Pierre André
5edb3ec920 Closed the bad sector inode after updating the list
Unlike in most cases, the bad sector inode has to be closed if it
was updated and required MFT extents (when there are a lot of bad
sectors and some of them were outside the truncated partition).
Not doing so causes the inode to not be fully synced to device.
2016-02-12 17:03:53 +01:00
Erik Larsson
a207d4e86a endians.h: Cast the result of const endianness macros to the right type.
This fixes compiler warnings emitted when you compare an le32 value with
e.g. 'const_cpu_to_le32(-1)' on a little-endian system, because
previously the expansion of the macro expression 'const_cpu_to_le32(-1)'
would be '(-1)' on a little-endian system but '(u32)((((u32)(-1) &
0xff000000u) >> 24) | (((u32)(-1) & 0x00ff0000u) >>  8) | (((u32)(-1) &
0x0000ff00u) <<  8) | (((u32)(-1) & 0x000000ffu) << 24))' on a
big-endian system, i.e. the type of the expanded expression would be
'int' (signed) in the little-endian case but 'u32' (unsigned) in the
big-endian case.

With this commit the type of the expanded expression will be 'le32' in
both the little-endian and the big-endian case.
2016-02-11 14:19:41 +01:00
Erik Larsson
f463919310 ntfs-3g_common.h: Fix improper type for 'dmtime' in ntfs_fuse_context_t.
This field is always assigned a signed value, and compared to other
signed values (ntfs_time values are signed little-endian 32-bit
integers).

This fixes two compiler warnings about signed/unsigned comparison.
2016-02-11 14:06:53 +01:00