mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2024-11-27 03:53:48 +08:00
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.
This commit is contained in:
parent
7e9003b147
commit
ef09702b0c
@ -314,6 +314,7 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
|
||||
const char *todo = "This is still work in progress.";
|
||||
char *buf;
|
||||
int i, j;
|
||||
VOLUME_FLAGS flags;
|
||||
u32 u;
|
||||
|
||||
switch (type) {
|
||||
@ -356,54 +357,54 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
|
||||
#define VOL_INF(x) ((VOLUME_INFORMATION *)(x))
|
||||
printf("NTFS version %i.%i\n", VOL_INF(val)->major_ver,
|
||||
VOL_INF(val)->minor_ver);
|
||||
i = VOL_INF(val)->flags;
|
||||
flags = VOL_INF(val)->flags;
|
||||
#undef VOL_INF
|
||||
printf("Volume flags = 0x%x: ", le16_to_cpu(i));
|
||||
if (!i) {
|
||||
printf("Volume flags = 0x%x: ", le16_to_cpu(flags));
|
||||
if (!flags) {
|
||||
printf("NONE\n");
|
||||
return;
|
||||
}
|
||||
j = 0;
|
||||
if (i & VOLUME_MODIFIED_BY_CHKDSK) {
|
||||
if (flags & VOLUME_MODIFIED_BY_CHKDSK) {
|
||||
j = 1;
|
||||
printf("VOLUME_MODIFIED_BY_CHKDSK");
|
||||
}
|
||||
if (i & VOLUME_REPAIR_OBJECT_ID) {
|
||||
if (flags & VOLUME_REPAIR_OBJECT_ID) {
|
||||
if (j)
|
||||
printf(" | ");
|
||||
else
|
||||
j = 0;
|
||||
printf("VOLUME_REPAIR_OBJECT_ID");
|
||||
}
|
||||
if (i & VOLUME_DELETE_USN_UNDERWAY) {
|
||||
if (flags & VOLUME_DELETE_USN_UNDERWAY) {
|
||||
if (j)
|
||||
printf(" | ");
|
||||
else
|
||||
j = 0;
|
||||
printf("VOLUME_DELETE_USN_UNDERWAY");
|
||||
}
|
||||
if (i & VOLUME_MOUNTED_ON_NT4) {
|
||||
if (flags & VOLUME_MOUNTED_ON_NT4) {
|
||||
if (j)
|
||||
printf(" | ");
|
||||
else
|
||||
j = 0;
|
||||
printf("VOLUME_MOUNTED_ON_NT4");
|
||||
}
|
||||
if (i & VOLUME_UPGRADE_ON_MOUNT) {
|
||||
if (flags & VOLUME_UPGRADE_ON_MOUNT) {
|
||||
if (j)
|
||||
printf(" | ");
|
||||
else
|
||||
j = 0;
|
||||
printf("VOLUME_UPGRADE_ON_MOUNT");
|
||||
}
|
||||
if (i & VOLUME_RESIZE_LOG_FILE) {
|
||||
if (flags & VOLUME_RESIZE_LOG_FILE) {
|
||||
if (j)
|
||||
printf(" | ");
|
||||
else
|
||||
j = 0;
|
||||
printf("VOLUME_RESIZE_LOG_FILE");
|
||||
}
|
||||
if (i & VOLUME_IS_DIRTY) {
|
||||
if (flags & VOLUME_IS_DIRTY) {
|
||||
if (j)
|
||||
printf(" | ");
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user