From: Mauricio Faria de Oliveira <mfo@canonical.com>
Date: Mon, 15 Aug 2022 17:35:08 +0800
Subject: path_max_zero_st_size

---
 src/unix/fs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/unix/fs.c b/src/unix/fs.c
index 362c36c..88699bd 100644
--- a/src/unix/fs.c
+++ b/src/unix/fs.c
@@ -730,6 +730,17 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
     maxlen = uv__fs_pathmax_size(req->path);
 #endif
 
+  /* Some symlinks in /proc report st_size == 0 */
+  if (maxlen == 0) {
+#if defined(_POSIX_PATH_MAX)
+    maxlen = _POSIX_PATH_MAX;
+#elif defined(PATH_MAX)
+    maxlen = PATH_MAX;
+#else
+    maxlen = 4096; /* fallback */
+#endif
+  }
+
   buf = uv__malloc(maxlen);
 
   if (buf == NULL) {
