mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2024-11-23 10:04:00 +08:00
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'.
This commit is contained in:
parent
02ce4947df
commit
efa876d31b
@ -531,6 +531,7 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
|
||||
unsigned int u;
|
||||
char s[0x200];
|
||||
int i;
|
||||
ATTR_FLAGS flags;
|
||||
|
||||
printf("-- Beginning dump of attribute record at offset 0x%x. --\n",
|
||||
(unsigned)((u8*)a - (u8*)m));
|
||||
@ -565,7 +566,7 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
|
||||
printf("Name length = %u unicode characters\n", a->name_length);
|
||||
printf("Name offset = %u (0x%x)\n", le16_to_cpu(a->name_offset),
|
||||
le16_to_cpu(a->name_offset));
|
||||
u = a->flags;
|
||||
flags = a->flags;
|
||||
if (a->name_length) {
|
||||
if (ucstos(s, (ntfschar*)((char*)a +
|
||||
le16_to_cpu(a->name_offset)),
|
||||
@ -579,17 +580,17 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
|
||||
}
|
||||
printf("Name = %s\n", s);
|
||||
}
|
||||
printf("Attribute flags = 0x%x: ", le16_to_cpu(u));
|
||||
if (!u)
|
||||
printf("Attribute flags = 0x%x: ", le16_to_cpu(flags));
|
||||
if (!flags)
|
||||
printf("NONE");
|
||||
else {
|
||||
int first = TRUE;
|
||||
if (u & ATTR_COMPRESSION_MASK) {
|
||||
if (u & ATTR_IS_COMPRESSED) {
|
||||
if (flags & ATTR_COMPRESSION_MASK) {
|
||||
if (flags & ATTR_IS_COMPRESSED) {
|
||||
printf("ATTR_IS_COMPRESSED");
|
||||
first = FALSE;
|
||||
}
|
||||
if ((u & ATTR_COMPRESSION_MASK) & ~ATTR_IS_COMPRESSED) {
|
||||
if ((flags & ATTR_COMPRESSION_MASK) & ~ATTR_IS_COMPRESSED) {
|
||||
if (!first)
|
||||
printf(" | ");
|
||||
else
|
||||
@ -597,14 +598,14 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
|
||||
printf("ATTR_UNKNOWN_COMPRESSION");
|
||||
}
|
||||
}
|
||||
if (u & ATTR_IS_ENCRYPTED) {
|
||||
if (flags & ATTR_IS_ENCRYPTED) {
|
||||
if (!first)
|
||||
printf(" | ");
|
||||
else
|
||||
first = FALSE;
|
||||
printf("ATTR_IS_ENCRYPTED");
|
||||
}
|
||||
if (u & ATTR_IS_SPARSE) {
|
||||
if (flags & ATTR_IS_SPARSE) {
|
||||
if (!first)
|
||||
printf(" | ");
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user