mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2025-01-09 18:03:29 +08:00
Fix a very(!) longstanding bug in ntfs_attr_find() and co.
Also reapply fix to unistr.c name collation.
This commit is contained in:
parent
eb51c61ba4
commit
3a50e66a59
@ -1559,23 +1559,10 @@ static int ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
|
|||||||
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
|
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
|
||||||
{
|
{
|
||||||
ATTR_RECORD *a;
|
ATTR_RECORD *a;
|
||||||
ntfs_volume *vol;
|
ntfs_volume *vol = ctx->ntfs_ino->vol;
|
||||||
ntfschar *upcase;
|
ntfschar *upcase = vol->upcase;
|
||||||
u32 upcase_len;
|
u32 upcase_len = vol->upcase_len;
|
||||||
|
|
||||||
if (!ctx || !ctx->mrec || !ctx->attr) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (ic == IGNORE_CASE) {
|
|
||||||
vol = ctx->ntfs_ino->vol;
|
|
||||||
upcase = vol->upcase;
|
|
||||||
upcase_len = vol->upcase_len;
|
|
||||||
} else {
|
|
||||||
vol = NULL;
|
|
||||||
upcase = NULL;
|
|
||||||
upcase_len = 0;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Iterate over attributes in mft record starting at @ctx->attr, or the
|
* Iterate over attributes in mft record starting at @ctx->attr, or the
|
||||||
* attribute following that, if @ctx->is_first is TRUE.
|
* attribute following that, if @ctx->is_first is TRUE.
|
||||||
@ -2176,9 +2163,12 @@ int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
|
|||||||
const VCN lowest_vcn, const u8 *val, const u32 val_len,
|
const VCN lowest_vcn, const u8 *val, const u32 val_len,
|
||||||
ntfs_attr_search_ctx *ctx)
|
ntfs_attr_search_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
ntfs_volume *vol;
|
||||||
ntfs_inode *base_ni;
|
ntfs_inode *base_ni;
|
||||||
|
|
||||||
if (!ctx || !ctx->mrec || !ctx->attr) {
|
if (!ctx || !ctx->mrec || !ctx->attr || (name && (!ctx->ntfs_ino ||
|
||||||
|
!(vol = ctx->ntfs_ino->vol) || !vol->upcase ||
|
||||||
|
!vol->upcase_len))) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ int ntfs_names_collate(const ntfschar *name1, const u32 name1_len,
|
|||||||
ntfschar c1, c2;
|
ntfschar c1, c2;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!name1 || !name2 || (ic && !upcase && upcase_len)) {
|
if (!name1 || !name2 || (ic && (!upcase || !upcase_len))) {
|
||||||
Dputs("ntfs_names_collate received NULL pointer!");
|
Dputs("ntfs_names_collate received NULL pointer!");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user