From 205a5db03782a7f74ebaea622901263655996697 Mon Sep 17 00:00:00 2001 From: "cantab.net!aia21" Date: Mon, 19 Jan 2004 09:09:56 +0000 Subject: [PATCH] Fix range checking error spotted by Szaka. (Logical change 1.265) --- libntfs/attrib.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libntfs/attrib.c b/libntfs/attrib.c index e439d1f4..0225ba94 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -2096,12 +2096,15 @@ int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPES type, if (!ad) return -1; /* We found the attribute. - Do the bounds check. */ - if (size >= sle64_to_cpu(ad->min_size) && - size <= sle64_to_cpu(ad->max_size)) - return 0; - /* @size is out of range! */ - errno = ERANGE; - return -1; + if ((sle64_to_cpu(ad->min_size) && size < + sle64_to_cpu(ad->min_size)) || + (sle64_to_cpu(ad->max_size) && size > + sle64_to_cpu(ad->max_size))) { + /* @size is out of range! */ + errno = ERANGE; + return -1; + } + return 0; } /**