[hackers] [sbase] ls: abort a directory if we cannot opendir it || David Phillips
commit 46495ea902071bd0b2397c5cad4d49ec22d491f9
Author: David Phillips <david_AT_sighup.nz>
AuthorDate: Tue Aug 22 16:51:37 2017 +1200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Tue Aug 22 13:33:40 2017 +0200
ls: abort a directory if we cannot opendir it
We should not try and perform operations on an invalid DIR* stream.
Instead, we shall let the error message be printed, and the return
code set (existing behaviour) and abort afterwards.
diff --git a/ls.c b/ls.c
index 5080c8f..b716aba 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -250,6 +250,7 @@ lsdir(const char *path, const struct entry *dir)
if (!(dp = opendir(dir->name))) {
ret = 1;
weprintf("opendir %s%s:", path, dir->name);
+ return;
}
if (chdir(dir->name) < 0)
eprintf("chdir %s:", dir->name);
Received on Tue Aug 22 2017 - 13:40:39 CEST
This archive was generated by hypermail 2.3.0
: Tue Aug 22 2017 - 13:48:53 CEST