From a5ade112cb3fc0597800a2eabf4a07e9fb7b7db8 Mon Sep 17 00:00:00 2001 From: bptato <60043228+bptato@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:21:56 +0200 Subject: [PATCH] Add missing error handling in getAppFilename (#25017) readlink can return -1, e.g. if procfs isn't mounted in a Linux chroot. (At least that's how I found this.) (cherry picked from commit b6491e7de54f6880b59c46853cf51f8aee8b83e6) --- lib/pure/os.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pure/os.nim b/lib/pure/os.nim index ea8dd1483a..594295ac3d 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -565,6 +565,8 @@ when not weirdTarget and (defined(linux) or defined(solaris) or defined(bsd) or if len > maxSymlinkLen: result = newString(len+1) len = readlink(procPath, result.cstring, len) + if len < 0: # error in readlink + len = 0 setLen(result, len) when not weirdTarget and defined(openbsd):