Fix a very(!) longstanding bug in ntfs_attr_find() and co.

Also reapply fix to unistr.c name collation.
This commit is contained in:
antona 2005-09-24 20:28:23 +00:00
parent eb51c61ba4
commit 3a50e66a59
2 changed files with 8 additions and 18 deletions

View File

@ -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)
{
ATTR_RECORD *a;
ntfs_volume *vol;
ntfschar *upcase;
u32 upcase_len;
ntfs_volume *vol = ctx->ntfs_ino->vol;
ntfschar *upcase = vol->upcase;
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
* 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,
ntfs_attr_search_ctx *ctx)
{
ntfs_volume *vol;
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;
return -1;
}

View File

@ -115,7 +115,7 @@ int ntfs_names_collate(const ntfschar *name1, const u32 name1_len,
ntfschar c1, c2;
#ifdef DEBUG
if (!name1 || !name2 || (ic && !upcase && upcase_len)) {
if (!name1 || !name2 || (ic && (!upcase || !upcase_len))) {
Dputs("ntfs_names_collate received NULL pointer!");
exit(1);
}