aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libexfat/exfat.h3
-rw-r--r--libexfat/node.c4
-rw-r--r--libexfat/utils.c4
3 files changed, 6 insertions, 5 deletions
diff --git a/libexfat/exfat.h b/libexfat/exfat.h
index 795bf47..78da924 100644
--- a/libexfat/exfat.h
+++ b/libexfat/exfat.h
@@ -184,7 +184,8 @@ le16_t exfat_calc_checksum(const struct exfat_entry_meta1* meta1,
const struct exfat_entry_meta2* meta2, const le16_t* name);
uint32_t exfat_vbr_start_checksum(const void* sector, size_t size);
uint32_t exfat_vbr_add_checksum(const void* sector, size_t size, uint32_t sum);
-le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name);
+le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name,
+ size_t length);
void exfat_humanize_bytes(uint64_t value, struct exfat_human_bytes* hb);
void exfat_print_info(const struct exfat_super_block* sb,
uint32_t free_clusters);
diff --git a/libexfat/node.c b/libexfat/node.c
index 90002eb..94061b4 100644
--- a/libexfat/node.c
+++ b/libexfat/node.c
@@ -957,7 +957,7 @@ static int write_entry(struct exfat* ef, struct exfat_node* dir,
meta2.type = EXFAT_ENTRY_FILE_INFO;
meta2.flags = EXFAT_FLAG_ALWAYS1;
meta2.name_length = name_length;
- meta2.name_hash = exfat_calc_name_hash(ef, node->name);
+ meta2.name_hash = exfat_calc_name_hash(ef, node->name, name_length);
meta2.start_cluster = cpu_to_le32(EXFAT_CLUSTER_FREE);
meta1.checksum = exfat_calc_checksum(&meta1, &meta2, node->name);
@@ -1099,7 +1099,7 @@ static int rename_entry(struct exfat* ef, struct exfat_node* dir,
return -EIO;
}
meta1.continuations = 1 + name_entries;
- meta2.name_hash = exfat_calc_name_hash(ef, name);
+ meta2.name_hash = exfat_calc_name_hash(ef, name, name_length);
meta2.name_length = name_length;
meta1.checksum = exfat_calc_checksum(&meta1, &meta2, name);
diff --git a/libexfat/utils.c b/libexfat/utils.c
index e0523e0..8e7cd3e 100644
--- a/libexfat/utils.c
+++ b/libexfat/utils.c
@@ -122,10 +122,10 @@ uint32_t exfat_vbr_add_checksum(const void* sector, size_t size, uint32_t sum)
return sum;
}
-le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name)
+le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name,
+ size_t length)
{
size_t i;
- size_t length = utf16_length(name);
uint16_t hash = 0;
for (i = 0; i < length; i++)