On 12/29/20 7:39 PM, Paul Eggert wrote:

Unfortunately that patch didn't correctly treat size-calculation overflow like other out-of-memory situations. I installed the attached further patch into Gnulib.

Aaaaand even that patch mishandled errno on size-calculation overflow, so I installed the attached into Gnulib as well. Hope this finally does it.
>From ed5ce2ad20fb12f60fa2bdb95c0c2a7fe7ce1114 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 29 Dec 2020 22:17:46 -0800
Subject: [PATCH] * lib/canonicalize-lgpl.c (realpath_stk): Set errno properly.

---
 lib/canonicalize-lgpl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 01b06322d..49596f835 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -344,7 +344,10 @@ realpath_stk (const char *name, char *resolved,
                 end_idx = end - extra_buf;
               size_t len = strlen (end);
               if (NARROW_ADDRESSES && INT_ADD_OVERFLOW (len, n))
-                goto error_nomem;
+                {
+                  __set_errno (ENOMEM);
+                  goto error_nomem;
+                }
               while (extra_buffer.length <= len + n)
                 {
                   if (!scratch_buffer_grow_preserve (&extra_buffer))
-- 
2.27.0

Reply via email to