diff --git a/include/ntfs/attrib.h b/include/ntfs/attrib.h index 1ab2dd4f..bb911338 100644 --- a/include/ntfs/attrib.h +++ b/include/ntfs/attrib.h @@ -337,6 +337,11 @@ extern int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize); extern int ntfs_attr_exist(ntfs_inode *ni, const ATTR_TYPES type, ntfschar *name, u32 name_len); +static __inline__ ntfschar *ntfs_attr_get_name(ATTR_RECORD *attr) +{ + return (ntfschar*)((u8*)attr + le16_to_cpu(attr->name_offset)); +} + // FIXME / TODO: Above here the file is cleaned up. (AIA) /** * get_attribute_value_length - return the length of the value of an attribute diff --git a/ntfsprogs/ntfsinfo.c b/ntfsprogs/ntfsinfo.c index 907bcc9b..497514b8 100644 --- a/ntfsprogs/ntfsinfo.c +++ b/ntfsprogs/ntfsinfo.c @@ -349,22 +349,21 @@ static char *ntfsinfo_time_to_str(const sle64 sle_ntfs_clock) * null if cannot convert to multi-byte string. errno would contain the * error id. no memory allocated in that case */ -static char *ntfs_attr_get_name(ATTR_RECORD *attr) +static char *ntfs_attr_get_name_mbs(ATTR_RECORD *attr) { ntfschar *ucs_attr_name; char *mbs_attr_name = NULL; int mbs_attr_name_size; - /* calculate name position */ - ucs_attr_name = (ntfschar *)((char *)attr + le16_to_cpu(attr->name_offset)); - /* convert unicode to printable format */ - mbs_attr_name_size = ntfs_ucstombs(ucs_attr_name,attr->name_length, - &mbs_attr_name,0); - if (mbs_attr_name_size>0) { + /* Get name in unicode. */ + ucs_attr_name = ntfs_attr_get_name(attr); + /* Convert unicode to printable format. */ + mbs_attr_name_size = ntfs_ucstombs(ucs_attr_name, attr->name_length, + &mbs_attr_name, 0); + if (mbs_attr_name_size > 0) return mbs_attr_name; - } else { + else return NULL; - } } @@ -1232,7 +1231,7 @@ static void ntfs_dump_attribute_header(ATTR_RECORD *a, ntfs_volume *vol) if (a->name_length) { char *attribute_name = NULL; - attribute_name = ntfs_attr_get_name(a); + attribute_name = ntfs_attr_get_name_mbs(a); if (attribute_name) { printf("\tAttribute name:\t\t '%s'\n", attribute_name); free(attribute_name);