X-Git-Url: http://git.jankratochvil.net/?p=ntfsprogs.git;a=blobdiff_plain;f=libntfs%2Fdir.c;h=9abb7921ba8a53f938bf776b1d533649dd5320ff;hp=443322b593350061436ae92220d18cfcb3ca98d9;hb=refs%2Fheads%2Fmaster;hpb=4abffda2cd1cad459fc0a61d79e8cd234e207b17 diff --git a/libntfs/dir.c b/libntfs/dir.c index 443322b..9abb792 100644 --- a/libntfs/dir.c +++ b/libntfs/dir.c @@ -1,7 +1,7 @@ /* * dir.c - Directory handling code. Part of the Linux-NTFS project. * - * Copyright (c) 2002 Anton Altaparmakov + * Copyright (c) 2002-2003 Anton Altaparmakov * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -612,6 +612,11 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, return -1; } + if (!(dir_ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) { + errno = ENOTDIR; + return -1; + } + vol = dir_ni->vol; Dprintf("Entering for inode 0x%Lx, *pos 0x%Lx.\n", @@ -898,7 +903,8 @@ EOD: done: if (bmp_na) ntfs_attr_close(bmp_na); - ntfs_attr_close(ia_na); + if (ia_na) + ntfs_attr_close(ia_na); #ifdef DEBUG if (!rc) Dprintf("EOD, *pos 0x%Lx, returning 0.\n", (long long)*pos); @@ -916,7 +922,8 @@ err_out: ntfs_attr_put_search_ctx(ctx); if (bmp_na) ntfs_attr_close(bmp_na); - ntfs_attr_close(ia_na); + if (ia_na) + ntfs_attr_close(ia_na); errno = eo; return -1; }