[hackers] [sbase] ls: check for the index size before using it in visit() || Quentin Rameau

From: <git_AT_suckless.org>
Date: Thu, 18 Feb 2016 15:18:54 +0100 (CET)

commit ee8701d501325c74bbbd294da4142e3cbfc988fe
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Thu Feb 18 15:16:25 2016 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Thu Feb 18 14:18:49 2016 +0000

    ls: check for the index size before using it in visit()
    
    Thanks to k0ga for noticing it!

diff --git a/ls.c b/ls.c
index e55c7c5..7c97558 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -311,7 +311,7 @@ visit(const struct entry *ent)
         dev = ent->dev;
         ino = S_ISLNK(ent->mode) ? ent->tino : ent->ino;
 
- for (i = 0; tree[i].ino && i < PATH_MAX; ++i) {
+ for (i = 0; i < PATH_MAX && tree[i].ino; ++i) {
                 if (ino == tree[i].ino && dev == tree[i].dev)
                         return -1;
         }
Received on Thu Feb 18 2016 - 15:18:54 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 18 2016 - 15:24:16 CET