summaryrefslogtreecommitdiffstats
path: root/src/ntfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ntfs.c')
-rw-r--r--src/ntfs.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ntfs.c b/src/ntfs.c
index ee47e0a..933ab02 100644
--- a/src/ntfs.c
+++ b/src/ntfs.c
@@ -184,7 +184,7 @@ int test_NTFS(const disk_t *disk_car, const struct ntfs_boot_sector*ntfs_header,
return 0;
}
-const ntfs_attribheader *ntfs_getattributeheaders(const ntfs_recordheader* record)
+static const ntfs_attribheader *ntfs_getattributeheaders(const ntfs_recordheader* record)
{
const char* location = (const char*)record;
if(le32(record->magic)!=NTFS_Magic ||
@@ -225,10 +225,12 @@ const ntfs_attribheader* ntfs_findattribute(const ntfs_recordheader* record, uin
return ntfs_searchattribute(attrib, attrType, end, 0);
}
-const ntfs_attribheader* ntfs_nextattribute(const ntfs_attribheader* attrib, uint32_t attrType, const char* end)
+#if 0
+static const ntfs_attribheader* ntfs_nextattribute(const ntfs_attribheader* attrib, uint32_t attrType, const char* end)
{
return ntfs_searchattribute(attrib, attrType, end, 1);
}
+#endif
const char* ntfs_getattributedata(const ntfs_attribresident* attrib, const char* end)
{
@@ -303,6 +305,7 @@ static void ntfs_get_volume_name(disk_t *disk_car, partition_t *partition, const
unsigned char *buffer;
uint64_t mft_pos;
unsigned int mft_record_size;
+ partition->fsname[0]='\0';
if(ntfs_header->clusters_per_mft_record>0)
mft_record_size=ntfs_header->clusters_per_mft_record * ntfs_header->sectors_per_cluster * ntfs_sector_size(ntfs_header);
else
@@ -332,13 +335,19 @@ static void ntfs_get_volume_name(disk_t *disk_car, partition_t *partition, const
const ntfs_attribresident *attrib=(const ntfs_attribresident *)ntfs_findattribute((const ntfs_recordheader*)buffer, 0x60, (char*)buffer+mft_record_size);
if(attrib && attrib->header.bNonResident==0) /* attribute is resident */
{
- char *dest=partition->fsname;
+ char *dest;
const char *name_it;
unsigned int volume_name_length=le32(attrib->cbAttribData);
volume_name_length/=2; /* Unicode */
if(volume_name_length>sizeof(partition->fsname)-1)
volume_name_length=sizeof(partition->fsname)-1;
- for(name_it=ntfs_getattributedata(attrib, (char*)(buffer+mft_record_size));
+ name_it=ntfs_getattributedata(attrib, (char*)(buffer+mft_record_size));
+ if(name_it==NULL)
+ {
+ free(buffer);
+ return;
+ }
+ for(dest=partition->fsname;
volume_name_length>0 && *name_it!='\0' && name_it[1]=='\0';
name_it+=2,volume_name_length--)
*dest++=*name_it;