From f8940f483940ee28c5333a70f20241790b6aa402 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 18 May 2023 18:01:06 +0200 Subject: [PATCH] astrxfrm: Fix use-after-free bug. * lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded. --- ChangeLog | 5 +++++ lib/astrxfrm.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index dedf78c369..f105e2db8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-05-18 Bruno Haible + + astrxfrm: Fix use-after-free bug. + * lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded. + 2023-05-18 Bruno Haible gnulib-tool: Ignore .orig and .rej files under modules/. diff --git a/lib/astrxfrm.c b/lib/astrxfrm.c index 214ebc38b8..845f0a0711 100644 --- a/lib/astrxfrm.c +++ b/lib/astrxfrm.c @@ -155,10 +155,7 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp) { char *memory = (char *) realloc (result, length); if (memory != NULL) - { - memcpy (memory, result, length); - result = memory; - } + result = memory; } } } -- 2.39.5