From 1cce91d8aed5c3eca2b6f47767c82d9ed3e9e33f Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 8 Apr 2024 09:06:09 -0700
Subject: [PATCH] elf: Check objname before calling fatal_error

_dl_signal_error may be called with objname == NULL.  _dl_exception_create
checks objname == NULL.  But fatal_error doesn't.  Check objname before
calling fatal_error.  This fixes BZ #31596.

Reference:https://sourceware.org/git/?p=glibc.git;a=commit;h=1cce91d8aed5c3eca2b6f47767c82d9ed3e9e33f

Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
---
 elf/dl-error-skeleton.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/elf/dl-error-skeleton.c b/elf/dl-error-skeleton.c
index b699936c..26dfab55 100644
--- a/elf/dl-error-skeleton.c
+++ b/elf/dl-error-skeleton.c
@@ -121,7 +121,11 @@ _dl_signal_error (int errcode, const char *objname, const char *occation,
       __longjmp (lcatch->env[0].__jmpbuf, 1);
     }
   else
+  {
+    if (objname == NULL)
+	    objname = "";
     fatal_error (errcode, objname, occation, errstring);
+  }
 }
 libc_hidden_def (_dl_signal_error)
 
-- 
2.33.0

