Added position check to VFS_ReadDir
[tpg/acess2.git] / Kernel / vfs / dir.c
index b4001dd..b7af755 100644 (file)
@@ -141,13 +141,25 @@ int VFS_ReadDir(int FD, char *Dest)
        tVFS_Handle     *h = VFS_GetHandle(FD);
        char    *tmp;
        
-       if(h)   return -1;
+       ENTER("ph pDest", h, Dest);
        
-       if(h->Node->ReadDir == NULL)    return 0;
+       if(!h || h->Node->ReadDir == NULL) {
+               LEAVE('i', 0);
+               return 0;
+       }
+       
+       if(h->Position >= h->Node->Size) {
+               LEAVE('i', 0);
+               return 0;
+       }
        
        tmp = h->Node->ReadDir(h->Node, h->Position);
+       LOG("tmp = '%s'", tmp);
        
-       if(!tmp)        return 0;
+       if(!tmp) {
+               LEAVE('i', 0);
+               return 0;
+       }
        
        h->Position ++;
        
@@ -155,5 +167,6 @@ int VFS_ReadDir(int FD, char *Dest)
        
        if(IsHeap(tmp)) free(tmp);
        
+       LEAVE('i', 1);
        return 1;
 }

UCC git Repository :: git.ucc.asn.au