From d026ce97b8faaa2f3f196281b96df0a04e30e4f9 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 21 Oct 2021 06:21:34 +0000 Subject: init/shell: fix crash when cat is ran without arguments --- src/init/shell.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/init/shell.c') diff --git a/src/init/shell.c b/src/init/shell.c index 53ad995..33f6da3 100644 --- a/src/init/shell.c +++ b/src/init/shell.c @@ -44,10 +44,13 @@ static int readline(char *buf, size_t max) { } static void cmd_cat(const char *args) { - int fd = _syscall_open(args, strlen(args)); + int fd; static char buf[256]; int len = 256; + if (!args) return; // no argument + + fd = _syscall_open(args, strlen(args)); if (fd < 0) { printf("couldn't open.\n"); return; -- cgit v1.2.3