k9core

Coreutils for *nix operating systems
git clone git://bvnf.space/k9core.git
Log | Files | Refs | LICENSE

commit 8247a0ece418fe3a6ef1a0d60786bce9e735c01a
parent 40a9a703c3a59ed299f1f73328295a83cc309db9
Author: aabacchus <ben@bvnf.space>
Date:   Mon, 13 Sep 2021 16:04:52 +0100

ls: abort if filename given as arg

this is temporary, to avoid segfaults

Diffstat:
Msrc/ls.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/ls.c b/src/ls.c @@ -74,6 +74,11 @@ main(int argc, char *argv[]) strcpy(directory, argv[optind]); /* Very dirty code, i'll fix it * later */ DIR *dir = opendir(directory); + if(dir == NULL) { + /* maybe we were given a file? */ + perror(directory); + return 1; + } struct dirent *ent; if(recursive) { recursive_list_dirs(directory);