OSDN Git Service

android-x86/external-ntfs-3g.git
8 years agoAvoided pointer cast when checking record types
Jean-Pierre André [Mon, 15 Feb 2016 10:54:33 +0000 (11:54 +0100)]
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.

8 years agoUpdated the drivers copyrights
Jean-Pierre André [Fri, 12 Feb 2016 16:24:27 +0000 (17:24 +0100)]
Updated the drivers copyrights

Extend the copyright to 2016

8 years agoClosed the volume when a resizing is done
Jean-Pierre André [Fri, 12 Feb 2016 16:13:21 +0000 (17:13 +0100)]
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.

8 years agoClosed the bad sector inode after updating the list
Jean-Pierre André [Fri, 12 Feb 2016 16:03:53 +0000 (17:03 +0100)]
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.

8 years agoendians.h: Cast the result of const endianness macros to the right type.
Erik Larsson [Thu, 11 Feb 2016 13:19:41 +0000 (14:19 +0100)]
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.

8 years agontfs-3g_common.h: Fix improper type for 'dmtime' in ntfs_fuse_context_t.
Erik Larsson [Thu, 11 Feb 2016 13:06:53 +0000 (14:06 +0100)]
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.

8 years agomft.c: Fix compiler warning about mismatching format/argument type.
Erik Larsson [Thu, 11 Feb 2016 12:52:59 +0000 (13:52 +0100)]
mft.c: Fix compiler warning about mismatching format/argument type.

The expression is promoted to 'int' implicitly so we explicitly cast it
to 'u8'.

8 years agoefs.c: Fix incorrect type of local variables 'newsize' and 'oldsize'.
Erik Larsson [Mon, 8 Feb 2016 17:42:53 +0000 (18:42 +0100)]
efs.c: Fix incorrect type of local variables 'newsize' and 'oldsize'.

These variable are only ever assigned to/from s64 values, so their type
should be s64, not u64. This fixes a compiler warning about
signed/unsigned comparison.

8 years agontfslabel.c: Fix incorrect label buffer being NULL-terminated.
Erik Larsson [Mon, 8 Feb 2016 17:32:24 +0000 (18:32 +0100)]
ntfslabel.c: Fix incorrect label buffer being NULL-terminated.

The UTF-16LE label buffer containing the result of mbs2ucs is the one
that should be NULL-terminated when the label is longer than permitted.
Not the input buffer, which is a function parameter assumed to be
NULL-terminated anyway.

8 years agoChange type of all LSN struct members in ntfsrecover.h to leLSN.
Erik Larsson [Fri, 29 Jan 2016 11:36:06 +0000 (12:36 +0100)]
Change type of all LSN struct members in ntfsrecover.h to leLSN.

This is done to match the type of the LSN struct members in layout.h.
The effect of this change is that while these members were declared with
the le64 type previously, leLSN resolves to sle64. I.e. what was
previously unsigned fields are now signed.

Following this change we also need to switch over a few macros from
unsigned to signed versions in the code that uses these struct
definitions.

8 years agoplaylog.c: Use const macro for byteswapping const expression.
Erik Larsson [Fri, 29 Jan 2016 09:49:52 +0000 (10:49 +0100)]
playlog.c: Use const macro for byteswapping const expression.

8 years agoplaylog.c: Fix improper byteswapping macros used for sle64 members.
Erik Larsson [Fri, 29 Jan 2016 09:49:25 +0000 (10:49 +0100)]
playlog.c: Fix improper byteswapping macros used for sle64 members.

8 years agoMerge endianness fixes.
Erik Larsson [Thu, 28 Jan 2016 08:22:42 +0000 (09:22 +0100)]
Merge endianness fixes.

Conflicts:
libntfs-3g/attrib.c

8 years agontfscmp.c: Fix missing byteswap of little-endian attribute type value.
Erik Larsson [Thu, 28 Jan 2016 08:11:55 +0000 (09:11 +0100)]
ntfscmp.c: Fix missing byteswap of little-endian attribute type value.

8 years agontfsmove.c: Fix multiple cases of raw usage of little-endian fields.
Erik Larsson [Wed, 27 Jan 2016 14:28:55 +0000 (15:28 +0100)]
ntfsmove.c: Fix multiple cases of raw usage of little-endian fields.

There were multiple cases of little-endian fields being used as
CPU-endian without byte swapping. This would result in incorrect
behaviour on big-endian systems.

8 years agontfsdump_logfile.c: Fix use of wrong byteswapping macro for le16 field.
Erik Larsson [Wed, 27 Jan 2016 14:26:51 +0000 (15:26 +0100)]
ntfsdump_logfile.c: Fix use of wrong byteswapping macro for le16 field.

8 years agontfsdump_logfile.c: Fix incorrectly parenthesized expression.
Erik Larsson [Wed, 27 Jan 2016 14:24:52 +0000 (15:24 +0100)]
ntfsdump_logfile.c: Fix incorrectly parenthesized expression.

On big-endian systems the result of the '!=' operation would be
endian-swapped rather than the first argument (which must have been the
intended action).

8 years agontfsck.c: Fix comparing le32 values as u32.
Erik Larsson [Wed, 27 Jan 2016 14:23:13 +0000 (15:23 +0100)]
ntfsck.c: Fix comparing le32 values as u32.

This is harmless except when we do strict endianness checking, in which
case this results in a compile error. Fixed by converting values to
CPU endianness before comparing them.

8 years agontfsck.c: Fix comparison between little-endian and native-endian data.
Erik Larsson [Wed, 27 Jan 2016 14:21:05 +0000 (15:21 +0100)]
ntfsck.c: Fix comparison between little-endian and native-endian data.

This comparison would yield the wrong result on big-endian systems.

8 years agontfstruncate.c: Fix mixed endianness usage of variable 'i'.
Erik Larsson [Tue, 26 Jan 2016 09:28:38 +0000 (10:28 +0100)]
ntfstruncate.c: Fix mixed endianness usage of variable 'i'.

In 'dump_resident_attr_val', 'i' was sometimes used as a native-endian
'int'-precision string length value and sometimes used as a little-
endian 16-bit flags value. This type of mixed usage is bad practice and
results in a hard error when strict endianness checking is used.

Fixed by introducing new variable 'flags' to hold the little-endian 16-
bit flags value.

8 years agontfstruncate.c: Fix incorrect type for CPU-endian value in 'ucstos'.
Erik Larsson [Tue, 26 Jan 2016 09:19:44 +0000 (10:19 +0100)]
ntfstruncate.c: Fix incorrect type for CPU-endian value in 'ucstos'.

8 years agontfstruncate.c: Fix conflicting endianness for variable 'attr_type'.
Erik Larsson [Tue, 26 Jan 2016 09:18:51 +0000 (10:18 +0100)]
ntfstruncate.c: Fix conflicting endianness for variable 'attr_type'.

If the attribute type is specified by the user, 'attr_type' was assigned
a CPU-endian value, however if the attribute type was not specified it
would be assigned the attribute type AT_DATA, which is a little-endian
value. The rest of the code seems to assume that 'attr_type' is
CPU-endian, so this is clearly a bug.

Resolved by fixing the endianness of the variable at little-endian,
converting the input value to little-endian when specified.

8 years agontfstruncate.c: Fix mixed endianness usage of variable 'u'.
Erik Larsson [Tue, 26 Jan 2016 09:03:36 +0000 (10:03 +0100)]
ntfstruncate.c: Fix mixed endianness usage of variable 'u'.

In 'dump_attr_record' the variable 'u' was first used to store a
CPU-endian 32-bit value, and then to store a 16-bit little-endian value.
This is bad practice and results in a hard error when strict endian type
checking is used.

Fixed by storing the 16-bit little-endian flags value in a new variable
'flags'.

8 years agontfs-3g.c: Fix raw usage of inode time fields without byteswapping.
Erik Larsson [Tue, 26 Jan 2016 06:55:45 +0000 (07:55 +0100)]
ntfs-3g.c: Fix raw usage of inode time fields without byteswapping.

8 years agovolume.c: Fix passing bad pointer type to ntfs_is_[baad|mft]_recordp.
Erik Larsson [Mon, 25 Jan 2016 10:31:12 +0000 (11:31 +0100)]
volume.c: Fix passing bad pointer type to ntfs_is_[baad|mft]_recordp.

8 years agomst.c: Fix mixed native/little-endian usage of variable 'usn'.
Erik Larsson [Mon, 25 Jan 2016 10:30:13 +0000 (11:30 +0100)]
mst.c: Fix mixed native/little-endian usage of variable 'usn'.

8 years agoreparse.c: Fix big-endian bug when converting file name to lowercase.
Erik Larsson [Mon, 4 Jan 2016 09:19:05 +0000 (10:19 +0100)]
reparse.c: Fix big-endian bug when converting file name to lowercase.

When looking up the lowercase equivalent of a Unicode character in
ntfs_fix_file_name, no byte swapping was performed on the ntfschar used
as index into the 'locase' array. This would lead to very strange
results on big-endian systems.

8 years agoFix inverted usage of endian conversion macros.
Erik Larsson [Mon, 4 Jan 2016 09:08:15 +0000 (10:08 +0100)]
Fix inverted usage of endian conversion macros.

This is mostly a semantic issue since the end result would be the same.

8 years agoFix incorrect usage of native/little-endian types, signed types, etc.
Erik Larsson [Mon, 21 Dec 2015 22:55:31 +0000 (23:55 +0100)]
Fix incorrect usage of native/little-endian types, signed types, etc.

This is harmless with regard to code generation but if we turn on strict
type checking these type mismatches will result in errors.

8 years agoFix endianness issues in log and terminal output.
Erik Larsson [Mon, 21 Dec 2015 22:31:09 +0000 (23:31 +0100)]
Fix endianness issues in log and terminal output.

This commit addresses issues where little-endian variables are emitted
raw to a log or output stream which is to be interpreted by the user.

Outputting data in non-native endianness can cause confusion for anybody
attempting to debug issues with a file system.

8 years agoFix code to use const_cpu_to_X/const_X_to_cpu macros for constants.
Erik Larsson [Mon, 21 Dec 2015 22:21:00 +0000 (23:21 +0100)]
Fix code to use const_cpu_to_X/const_X_to_cpu macros for constants.

This enables the compiler to optimize this code in cases where compiler
support for endianness swapping is not present.

8 years agoendians.h: Add const endian conversion macros for s{l,b}e{16,32,64}.
Erik Larsson [Mon, 21 Dec 2015 22:05:36 +0000 (23:05 +0100)]
endians.h: Add const endian conversion macros for s{l,b}e{16,32,64}.

8 years agoFixed accessing next log buffer only when it exists
Jean-Pierre André [Tue, 1 Dec 2015 10:12:53 +0000 (11:12 +0100)]
Fixed accessing next log buffer only when it exists

Do not locate the next log buffer until it is known to exist.

8 years agoFixed reporting action states when restart page appears outdated
Jean-Pierre André [Tue, 1 Dec 2015 10:10:48 +0000 (11:10 +0100)]
Fixed reporting action states when restart page appears outdated

If start buffer is more recent than restart, we update committed LSN
with last record LSN of block (last_end_lsn) while applying action but
forget about it while printing records with -f for investigation
purpose.

Note that while applying actions we use start_buffer to calculate
latest page out of block 2 and block 3 and then from latest take
committed LSN. For -f we don't need buffers so we just compare
directly with committed LSN from restart.

(contributed by Rakesh Pandit)

8 years agoRejected invalid null reparse tag
Jean-Pierre André [Tue, 1 Dec 2015 10:06:11 +0000 (11:06 +0100)]
Rejected invalid null reparse tag

The null reparse tag is considered invalid by Windows, so do the same.

8 years agoFixed returning the trimming count to fstrim(8)
Jean-Pierre André [Tue, 1 Dec 2015 10:00:24 +0000 (11:00 +0100)]
Fixed returning the trimming count to fstrim(8)

When used with the option -v, fstrim(8) reported the maximum trimming count
because the correct value was not returned to the ioctl call.

8 years agoDefined reparse tag for system compression
Jean-Pierre André [Tue, 1 Dec 2015 09:56:01 +0000 (10:56 +0100)]
Defined reparse tag for system compression

The new compression formats used by Windows 10 uses reparse data, and
a new reparse tag which it is useful to define even though these formats
is not yet supported by ntfs-3g.

8 years agoFixed special case of decompressing a runlist
Jean-Pierre André [Fri, 20 Nov 2015 15:17:48 +0000 (16:17 +0100)]
Fixed special case of decompressing a runlist

When the unreadable directory has an ATTRIBUTE_LIST attribute and an
INDEX_ALLOCATION attribute occupying split over several extents, the first
of which defines a single cluster, the first INDEX_ALLOCATION extent has
lowest_vcn=0 and highest_vcn=0, and the second one has lowest_vcn=1.

This unusual case, which can be created by the combination of a small
volume and near-full MFT records, triggers some special-case behavior in
ntfs_mapping_pairs_decompress_i(). That behavior is incorrect if the
attribute's first extent only contains a single cluster, since in that case
highest_vcn=0 as well.

This configuration has been tested on Windows and it *is* able to
successfully read the directory.  This supports the hypothesis that the
volume is valid and NTFS-3g has a bug on the read side.

This bug could, in theory, occur with any non-resident attribute, not just
INDEX_ALLOCATION attributes.

(Contributed by Eric Biggers)

8 years agoFixed headers of log play functions in playlog
Jean-Pierre André [Fri, 20 Nov 2015 15:14:16 +0000 (16:14 +0100)]
Fixed headers of log play functions in playlog

The functions were made static with a textual description.

8 years agoFixed missing error return in playlog
Jean-Pierre André [Fri, 20 Nov 2015 15:11:15 +0000 (16:11 +0100)]
Fixed missing error return in playlog

No error was returned from reading a protected record which is part of
an unreadable raw cluster.

8 years agoFixed truncating an extended bad cluster list in ntfsresize
Jean-Pierre André [Fri, 20 Nov 2015 15:04:47 +0000 (16:04 +0100)]
Fixed truncating an extended bad cluster list in ntfsresize

This fixes the case where the original bad cluster list requires extents.
The list is processed globally, no relocation is done, and the list is
truncated, possibly fitting into fewer extents.

8 years agoRemoved obsolete code from playlog
Jean-Pierre André [Thu, 12 Nov 2015 14:46:33 +0000 (15:46 +0100)]
Removed obsolete code from playlog

The code for dealing with new MFT records had been made more general

8 years agoSubdivided the replay functions in playlog
Jean-Pierre André [Thu, 12 Nov 2015 14:44:47 +0000 (15:44 +0100)]
Subdivided the replay functions in playlog

Partially unnested play_redos() and play_undos()

8 years agoFixed a memory leak in ntfsrecover
Jean-Pierre André [Thu, 12 Nov 2015 14:41:44 +0000 (15:41 +0100)]
Fixed a memory leak in ntfsrecover

A buffer was left leaking memory in reset_logfile()

8 years agoSilenced a compiler warning (cosmetic)
Jean-Pierre André [Thu, 12 Nov 2015 14:39:20 +0000 (15:39 +0100)]
Silenced a compiler warning (cosmetic)

An argument to ntfs_index_remove() is now unused

8 years agoDefined the last logfile block as preceding block 4 in ntfsrecover
Jean-Pierre André [Thu, 12 Nov 2015 14:31:24 +0000 (15:31 +0100)]
Defined the last logfile block as preceding block 4 in ntfsrecover

When block 2 or block 3 points backward to block 4, it is not clear
whether the log file only consists of block 2 or block 3 or the log
file has just wrapped around. The latter is now assumed.

8 years agoAlleviated constraints relative to reparse points
Jean-Pierre André [Mon, 9 Nov 2015 15:22:16 +0000 (16:22 +0100)]
Alleviated constraints relative to reparse points

Some constraints put on reparse points of unknown type (e.g. they cannot
be deleted) are not acceptable to archivers. This patch removes some
constraints.

8 years agoDecoded the full list of bad clusters in ntfsclone and ntfsresize
Jean-Pierre André [Mon, 9 Nov 2015 15:16:39 +0000 (16:16 +0100)]
Decoded the full list of bad clusters in ntfsclone and ntfsresize

When the bad cluster list required extent, ntfsclone and ntfsresize
did not process the extents, leading to unexpected read errors and
unmatching bitmaps. This fix enables the full list to be taken into
account.

8 years agoFixed reparse data check for non-Microsoft tags
Jean-Pierre André [Mon, 9 Nov 2015 15:14:31 +0000 (16:14 +0100)]
Fixed reparse data check for non-Microsoft tags

Windows requires non-Microsoft reparse points (identified by having bit
31 of the reparse tag clear) to have a 16-byte GUID following the regular
reparse point header.  This GUID is not, and cannot, be included in the
"reparse data length" field.

(Contributed by Eric Biggers)

8 years agoFixed getting space for making an index non resident
Jean-Pierre André [Mon, 9 Nov 2015 15:09:52 +0000 (16:09 +0100)]
Fixed getting space for making an index non resident

Under some rare condition there is no space in an MFT entry to make
an index non-resident, and the index root has to be moved to an extent.
This fix cares for the situation when the attribute list was inserted
beforehand.

8 years agoWrote as much data as possible in compressed attribute pwrite
Jean-Pierre André [Mon, 9 Nov 2015 15:00:31 +0000 (16:00 +0100)]
Wrote as much data as possible in compressed attribute pwrite

When writing to compressed data, the function ntfs_attr_pwrite()
cannot cross a compression block border. This is a problem for archivers
which rely on libntfs-3g, so the function is now wrapped in another one
which restarts the writing as needed.

8 years agoSilenced a compiler warning in ntfswipe (cosmetic)
Jean-Pierre André [Mon, 9 Nov 2015 14:58:00 +0000 (15:58 +0100)]
Silenced a compiler warning in ntfswipe (cosmetic)

Avoid a signed-to-unsigned compare warning

8 years agoFixed relocating the MFT runlists in ntfsresize
Jean-Pierre André [Mon, 9 Nov 2015 14:44:33 +0000 (15:44 +0100)]
Fixed relocating the MFT runlists in ntfsresize

The MFT has two runlists which may be partially stored in extents.
When these runlists have to be relocated, the relocations must be done
after the old runlists are not needed any more to read the data of
standard files, but before the MFT may be needed to extend the runlists
of standard files. Before doing so the MFT runlists have to be refreshed
from device in order to collect the updates which cannot be done in
memory during the first stage.

8 years agoImplemented recovery of updates committed by Windows
Jean-Pierre André [Mon, 9 Nov 2015 12:18:58 +0000 (13:18 +0100)]
Implemented recovery of updates committed by Windows

ntfsrecover applies to the metadata the updates which were requested on
Windows but could not be completed because they were interrupted by
some event such as a power failure, a hardware crash, a software crash
or the device being unplugged. Doing so, the file system is restored
to the latest consistent state.

No update to libntfs-3g is required by this implementation.

8 years agoUse appropriate little-endian/big-endian types in struct definitions.
Erik Larsson [Sat, 3 Oct 2015 10:58:08 +0000 (12:58 +0200)]
Use appropriate little-endian/big-endian types in struct definitions.

On-disk struct definitions used native types (u16/u32/u64/s16/s32/s64),
which doesn't say anything about the intended interpretation of the
data. The intention of having little-endian-specific types and
big-endian-specific types must have been to clarify interpretation of
data and intentions in the code. Therefore it seems reasonable to use
these types in struct definitions to clarify what data represention is
used to encode field data.

Because some struct members in layout.h are big-endian, this change also
means moving the duplicated definitions for big-endian byteswapping
macros and big-endian types found in acls.h and security.h to the
appropriate locations in endians.h and types.h respectively in order to
make them available for the struct definitions in layout.h.

8 years agoProtected against opendir reinitialization in lownfs-3g
Jean-Pierre André [Wed, 30 Sep 2015 07:35:17 +0000 (09:35 +0200)]
Protected against opendir reinitialization in lownfs-3g

Under some condition (probably interference with another process), the
directory list gets reinitialized by releasedir() and opendir() at the
beginning of a partial buffer. So in readdir() skip to the requested
offset. This is a step towards implementing seekdir().

8 years agontfsprogs Builds on Windows use macroes to translate printing formats,
Jean-Pierre André [Wed, 30 Sep 2015 07:08:35 +0000 (09:08 +0200)]
ntfsprogs Builds on Windows use macroes to translate printing formats,
and these macroes redefined "buf" in a way which causes trouble when
"buf" has another meaning. Use "_b" instead.

8 years agoDisplayed reparse point information in ntfsinfo
Jean-Pierre André [Wed, 30 Sep 2015 07:05:47 +0000 (09:05 +0200)]
Displayed reparse point information in ntfsinfo

Added displaying of reparse point data and decode known formats.

8 years agoImproved the check for a valid $MFTMirr
Jean-Pierre André [Wed, 30 Sep 2015 07:02:15 +0000 (09:02 +0200)]
Improved the check for a valid $MFTMirr

The test for a valid $MFTMirr could segfault on a badly damaged partition.
Add safety checks.

8 years agoFixed a wrong test report in ntfsfix
Jean-Pierre André [Wed, 30 Sep 2015 06:54:27 +0000 (08:54 +0200)]
Fixed a wrong test report in ntfsfix

When used with the "no-action" option, the test for self-located MFT
still reported the partition to have been repaired. Adapt the report to
only tell repairing is possible.

8 years agoFixed a bad sanity check in ntfsfix
Jean-Pierre André [Wed, 30 Sep 2015 06:51:20 +0000 (08:51 +0200)]
Fixed a bad sanity check in ntfsfix

Fix misordered checks to avoid potential segfaults on badly damaged partitions.

8 years agoMade secaudit to load the library based on its generic name
Jean-Pierre André [Wed, 30 Sep 2015 06:44:56 +0000 (08:44 +0200)]
Made secaudit to load the library based on its generic name

When compiled autonomously without the automatically generated dynamic
link stubs, use a generic library name instead of a version dependent one.
(obsolete compile mode rarely used).

8 years agoMade use of fuse module cache on OpenIndiana
Jean-Pierre André [Wed, 30 Sep 2015 06:36:37 +0000 (08:36 +0200)]
Made use of fuse module cache on OpenIndiana

The fuse cache does not handle properly hard-linked files, so ntfs-3g
traditionally disables it by using a null time-out. With an upgrade of
the fuse kernel module on OpenIndiana, cacheing of non hard-linked files
is now possible, so use it.

8 years agoMentioned the starting sector when it overflows in mkntfs
Jean-Pierre André [Wed, 30 Sep 2015 06:25:25 +0000 (08:25 +0200)]
Mentioned the starting sector when it overflows in mkntfs

In an NTFS boot sector, the first sector of the partition is limited to
32 bits and it may overflow on large disks. This field is only used for
booting on the partition and it is ignored by ntfs-3g, but the warning
in mkntfs mislead users, so improve it.

8 years agoUsed incremental offsets when reading a directory in lowntfs-3g
Jean-Pierre André [Wed, 30 Sep 2015 06:18:13 +0000 (08:18 +0200)]
Used incremental offsets when reading a directory in lowntfs-3g

Using incremental offsets avoids misinterpreting readdir() as rewinddir().
It also makes possible to implement seekdir() [not done yet]

9 years agoFixed the range of valid subauthority counts in a SID
Jean-Pierre André [Tue, 14 Jul 2015 06:37:01 +0000 (08:37 +0200)]
Fixed the range of valid subauthority counts in a SID

ntfs_valid_sid() required that the subauthority count be between 1 and 8
inclusively.  However, Windows permits more than 8 subauthorities as well
as 0 subauthorities:

  - The install.wim file for the latest Windows 10 build contains a file
    whose DACL contains a SID with 10 subauthorities.
    ntfs_set_ntfs_acl() was failing on this file.

  - The IsValidSid() function on Windows returns true for subauthority
    less than or equal to 15, including 0.

There was actually already a another SID validation function that had the
Windows-compatible behavior, so I merged the two together.

Contributed by Eric Biggers

9 years agounistr.c: Cleanup of OS X Unicode normalization code.
Erik Larsson [Tue, 23 Jun 2015 04:43:17 +0000 (06:43 +0200)]
unistr.c: Cleanup of OS X Unicode normalization code.

Normalize coding conventions to fit in with the rest of NTFS-3G,
including line breaks at column 80.

9 years agoSkip installing manpages for mount helpers when they aren't available.
Erik Larsson [Tue, 23 Jun 2015 04:27:33 +0000 (06:27 +0200)]
Skip installing manpages for mount helpers when they aren't available.

9 years agoMake installing mkntfs /sbin symlinks dependent on ENABLE_MOUNT_HELPER.
Erik Larsson [Tue, 23 Jun 2015 04:26:52 +0000 (06:26 +0200)]
Make installing mkntfs /sbin symlinks dependent on ENABLE_MOUNT_HELPER.

We shouldn't install anything into /sbin unless ENABLE_MOUNT_HELPER is
on, which is only true for Linux (these are Linux-specific symlinks).

9 years agoPorted clearing the environment when starting mount or umount
Jean-Pierre André [Mon, 1 Jun 2015 10:48:43 +0000 (12:48 +0200)]
Ported clearing the environment when starting mount or umount

When starting mount or umount, the environment was not cleared and
could be used for privilege escalation (CVE-2015-3202).
This is a port of the fix to full fuse by using execle(3) instead
of execl(3)

9 years agoImplemented rewindind a directory in lowntfs-3g
Jean-Pierre André [Fri, 17 Apr 2015 09:38:33 +0000 (11:38 +0200)]
Implemented rewindind a directory in lowntfs-3g

Rewinding a directory is done by freeing the current list of files and
rebuilding it. Only seeking to the beginning of the list is implemented.

9 years agoZeroed uninitialized bytes before writing compressed data
Jean-Pierre André [Fri, 17 Apr 2015 09:31:47 +0000 (11:31 +0200)]
Zeroed uninitialized bytes before writing compressed data

Compressed records may be written as full clusters even though cluster
tails are meaningless. This is to avoid the lower levels doing a read-
modify-write cycle. Be sure to zero the meaningless bytes to avoid
leaking information.

Contributed by Eric Biggers

9 years agoPacked/unpacked st_rdev transported as 32-bits on OpenIndiana 64-bits
Jean-Pierre André [Fri, 17 Apr 2015 09:22:49 +0000 (11:22 +0200)]
Packed/unpacked st_rdev transported as 32-bits on OpenIndiana 64-bits

On OpenIndiana 64-bits, st_rdev has major and minor as 32-bits wide each,
but the fuse protocol (common to 32-bit and 64-bit) has an st_rdev field
limited to 32-bit. For now, pack major and minor the same way as in the
32-bit variant (14 and 18 bits).

9 years agoSimplified NTFS ACLs when group same as owner and same permission as all
Jean-Pierre André [Fri, 17 Apr 2015 09:17:51 +0000 (11:17 +0200)]
Simplified NTFS ACLs when group same as owner and same permission as all

When the owner and the group of a file have the same SID, and permissions
for the group is the same as permissions for other, no ACE is needed for
the group.

9 years agoFixed setting SIG_DFL on fuse session exit
Jean-Pierre André [Fri, 17 Apr 2015 09:14:36 +0000 (11:14 +0200)]
Fixed setting SIG_DFL on fuse session exit

This is a backport of a fix applied to the (external) fuse library

9 years agoUpgraded the upper-case table as defined by Windows 7
Jean-Pierre André [Fri, 17 Apr 2015 09:03:58 +0000 (11:03 +0200)]
Upgraded the upper-case table as defined by Windows 7

Newer versions of Windows use more recent definitions of upper-case
table defined by the Unicode consortium. Now using the same table as
Windows 7, windows 8 and Windows 10. This only has an effect on file
systems newly created by mkntfs.

9 years agoFixed the DESX encryption/decryption in ntfsdecrypt
Jean-Pierre André [Fri, 17 Apr 2015 09:00:00 +0000 (11:00 +0200)]
Fixed the DESX encryption/decryption in ntfsdecrypt

The DESX encryption/decryption algorithm was different from the Windows one.

9 years agoRemoved a temporary debug comment (cosmetic)
Jean-Pierre André [Fri, 17 Apr 2015 08:56:34 +0000 (10:56 +0200)]
Removed a temporary debug comment (cosmetic)

The comment was a left over from some debugging action.

9 years agoAdded a sanity check to ntfswipe
Jean-Pierre André [Fri, 17 Apr 2015 08:49:23 +0000 (10:49 +0200)]
Added a sanity check to ntfswipe

Unused entries in the MFT may have a bad length leading to fetch fixups
from unallocated memory. Check the condition, but do not wipe, leave it
to chkdsk to decide what should be fixed.

9 years agoDefended against reusing data from an invalid MFT record
Jean-Pierre André [Fri, 17 Apr 2015 08:41:04 +0000 (10:41 +0200)]
Defended against reusing data from an invalid MFT record

An unused MFT record may show a bad length, leading to fetch fixups from
unallocated memory when allocating the record to a new file. So check
the length before applying the fixups. Such records have been found after
the MFT has been reallocated by a defragmenter, and they are not cleaned
by chkdsk.

9 years agoUpdated the read-only flag even when the security attribute was cached
Jean-Pierre André [Fri, 17 Apr 2015 08:35:26 +0000 (10:35 +0200)]
Updated the read-only flag even when the security attribute was cached

When chmod'ing a file, no new ACL has to be created if the one needed
is already present in the cache. However the read-only flag may have
to be updated, so that it is kept as the opposite of S_IWUSR.

9 years agoRemoved the double try to unmount partition in ntfsfix
Jean-Pierre André [Fri, 17 Apr 2015 08:27:24 +0000 (10:27 +0200)]
Removed the double try to unmount partition in ntfsfix

When the unmounting of the partition fails after running ntfsfix, a
second try was attempted. This cannot be done and leads to more errors
because some essential records have been freed, so better quit without
making a second try.

9 years agoFixed displaying "UserMapping" as a file name
Jean-Pierre André [Fri, 17 Apr 2015 08:21:02 +0000 (10:21 +0200)]
Fixed displaying "UserMapping" as a file name

Fix the capitalization of the user mapping file name to be filled with
the output of secaudit with option -u.

9 years agoRephrased a misleading report message in ntfswipe
Jean-Pierre André [Fri, 17 Apr 2015 07:42:19 +0000 (09:42 +0200)]
Rephrased a misleading report message in ntfswipe

When using the "--no-action" option, ntfswipe should display a count
of would-be wiped bytes without suggesting any has been wiped.

9 years agoAvoided logging meaningless fixup errors in ntfswipe
Jean-Pierre André [Fri, 17 Apr 2015 07:37:11 +0000 (09:37 +0200)]
Avoided logging meaningless fixup errors in ntfswipe

As ntfswipe examines all MFT entries, it may find uninitialized ones.
They should not be considered as erroneous ones even if the fixups
are wrong.

9 years agoAvoided mentioning deleted inodes in non-verbose output of ntfswipe
Jean-Pierre André [Fri, 17 Apr 2015 07:33:04 +0000 (09:33 +0200)]
Avoided mentioning deleted inodes in non-verbose output of ntfswipe

In non-verbose ntfswipe, avoid displaying deleted inodes as erroneous
ones.

9 years agoAdded clarifications about several options to the ntfswipe manual
Jean-Pierre André [Fri, 17 Apr 2015 07:26:59 +0000 (09:26 +0200)]
Added clarifications about several options to the ntfswipe manual

Clarified the usage of fast wiping, info and verbose options.

9 years agoFixed getting sector size from a partition image (Windows variant)
Jean-Pierre André [Fri, 17 Apr 2015 07:21:58 +0000 (09:21 +0200)]
Fixed getting sector size from a partition image (Windows variant)

On Windows, when processing a partition image, get the sector size
from the boot sector instead of the containing partition.

9 years agoSupported the directory separator on Windows in ntfsprogs (cosmetic)
Jean-Pierre André [Fri, 17 Apr 2015 07:15:25 +0000 (09:15 +0200)]
Supported the directory separator on Windows in ntfsprogs (cosmetic)

On Windows, when an ntfsprogs utility requests a path translation,
translate the '\'s to '/'s so that only '/' have to be interpreted
in libntfs.

9 years agoRephrased the warning for trimming not supported (cosmetic)
Jean-Pierre André [Fri, 17 Apr 2015 07:06:22 +0000 (09:06 +0200)]
Rephrased the warning for trimming not supported (cosmetic)

The initial text looked like an error message

9 years agoAvoided truncation in a debug message in secaudit
Jean-Pierre André [Fri, 17 Apr 2015 07:03:08 +0000 (09:03 +0200)]
Avoided truncation in a debug message in secaudit

When compiled for Windows 64-bit, pointers have to be displayed as
"long long" instead of "long" which is 32-bit

9 years agoVersion 2015.3.14.
Erik Larsson [Sat, 14 Mar 2015 11:49:43 +0000 (12:49 +0100)]
Version 2015.3.14.

9 years agoEnable ioctl in ntfs-3g unconditionally when building with fuse-lite.
Erik Larsson [Sat, 14 Mar 2015 10:11:43 +0000 (11:11 +0100)]
Enable ioctl in ntfs-3g unconditionally when building with fuse-lite.

fuse-lite announces a FUSE_VERSION which may not always match the exact
capabilities of the library. Hence we add a special case for 'ioctl',
which we know exists in fuse-lite regardless of the version number
published.

9 years agoFix improper #ifdef conditions around FUSE_CAP_IOCTL_DIR.
Erik Larsson [Sat, 14 Mar 2015 05:53:31 +0000 (06:53 +0100)]
Fix improper #ifdef conditions around FUSE_CAP_IOCTL_DIR.

The capability actually appeared in FUSE 2.9, not 2.8. However in order
to maintain similarity to earlier #ifdef:s, we simpy check if
FUSE_CAP_IOCTL_DIR is defined rather than checking the FUSE version.

9 years agoVersion 2015.3.13.
Erik Larsson [Fri, 13 Mar 2015 14:04:43 +0000 (15:04 +0100)]
Version 2015.3.13.

9 years agousermap.c: Fix uninitialized variable warning in main.
Erik Larsson [Fri, 13 Mar 2015 08:06:17 +0000 (09:06 +0100)]
usermap.c: Fix uninitialized variable warning in main.

If platform was non-Win32 and open_security_api() failed, the variable
'ok' would end up being uninitialized.

9 years agolowntfs-3g.c: Fix uninitialized variable warning in ntfs_fuse_getxattr.
Erik Larsson [Fri, 13 Mar 2015 08:02:38 +0000 (09:02 +0100)]
lowntfs-3g.c: Fix uninitialized variable warning in ntfs_fuse_getxattr.

The variable 'res' was never initialized if the #ifdef condition
'!KERNELPERMS | (POSIXACLS & !KERNELACLS)' evaluated to true and there
was an error allocating memory for 'value'.

9 years agontfsclone.c: Compile fix for OS X.
Erik Larsson [Fri, 13 Mar 2015 07:59:20 +0000 (08:59 +0100)]
ntfsclone.c: Compile fix for OS X.

OS X keeps the statfs declarations in sys/mount.h.

9 years agoCompile fix for FUSE versions earlier than 2.8.0.
Erik Larsson [Fri, 13 Mar 2015 07:57:38 +0000 (08:57 +0100)]
Compile fix for FUSE versions earlier than 2.8.0.

9 years agoSet release version 2015.3.5
Jean-Pierre André [Thu, 5 Mar 2015 17:47:06 +0000 (18:47 +0100)]
Set release version 2015.3.5