From 00bf604d7368bd49a12b5bdb21ab7b17b1f56937 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 6 Apr 2024 17:34:40 +0200 Subject: If readlink fails with another error, bail --- main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 9dd0eec..bc1f589 100644 --- a/main.c +++ b/main.c @@ -15,6 +15,8 @@ static int readlink_realpath(const char *filepath, char *buffer) { if(bytes_written == -1 && errno == EINVAL) { /* Not a symlink */ strncpy(symlinked_path, filepath, sizeof(symlinked_path)); + } else if(bytes_written == -1) { + return 0; } else { symlinked_path[bytes_written] = '\0'; } -- cgit v1.2.3