git: 1dcd99610434 - stable/14 - libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 03 Jan 2024 17:50:00 UTC
The branch stable/14 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=1dcd9961043444b1a8a14c4fd36826e454fae0c5
commit 1dcd9961043444b1a8a14c4fd36826e454fae0c5
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-11-15 02:34:01 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-01-03 17:43:47 +0000
libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13
GCC 13 incorrectly thinks a call to free after a failed realloc is a
use after free.
lib/libcasper/services/cap_grp/cap_grp.c: In function 'group_resize':
lib/libcasper/services/cap_grp/cap_grp.c:65:17: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]
65 | free(buf);
| ^~~~~~~~~
lib/libcasper/services/cap_grp/cap_grp.c:63:19: note: call to 'realloc' here
63 | gbuffer = realloc(buf, gbufsize);
| ^~~~~~~~~~~~~~~~~~~~~~
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D42576
(cherry picked from commit b7f7cc25c01aeacaafb86ebcffdeb258b7933b08)
---
lib/libcasper/services/cap_grp/Makefile | 3 +++
lib/libcasper/services/cap_netdb/Makefile | 3 +++
lib/libcasper/services/cap_pwd/Makefile | 3 +++
3 files changed, 9 insertions(+)
diff --git a/lib/libcasper/services/cap_grp/Makefile b/lib/libcasper/services/cap_grp/Makefile
index b46f3bfdaa47..0f722e3979f9 100644
--- a/lib/libcasper/services/cap_grp/Makefile
+++ b/lib/libcasper/services/cap_grp/Makefile
@@ -40,3 +40,6 @@ MLINKS+=cap_grp.3 cap_grp_limit_fields.3
MLINKS+=cap_grp.3 cap_grp_limit_groups.3
.include <bsd.lib.mk>
+
+# GCC 13 complains incorrectly about free after failed realloc: GCC bug #110501
+CFLAGS.cap_grp.c+= ${NO_WUSE_AFTER_FREE}
diff --git a/lib/libcasper/services/cap_netdb/Makefile b/lib/libcasper/services/cap_netdb/Makefile
index 36c57103b414..653aa21c9b32 100644
--- a/lib/libcasper/services/cap_netdb/Makefile
+++ b/lib/libcasper/services/cap_netdb/Makefile
@@ -29,3 +29,6 @@ MLINKS+=cap_netdb.3 libcap_netdb.3
MLINKS+=cap_netdb.3 cap_getprotobyname.3
.include <bsd.lib.mk>
+
+# GCC 13 complains incorrectly about free after failed realloc: GCC bug #110501
+CFLAGS.cap_netdb.c+= ${NO_WUSE_AFTER_FREE}
diff --git a/lib/libcasper/services/cap_pwd/Makefile b/lib/libcasper/services/cap_pwd/Makefile
index be6b4b21070f..4e0e6db6f86d 100644
--- a/lib/libcasper/services/cap_pwd/Makefile
+++ b/lib/libcasper/services/cap_pwd/Makefile
@@ -40,3 +40,6 @@ MLINKS+=cap_pwd.3 cap_pwd_limit_fields.3
MLINKS+=cap_pwd.3 cap_pwd_limit_users.3
.include <bsd.lib.mk>
+
+# GCC 13 complains incorrectly about free after failed realloc: GCC bug #110501
+CFLAGS.cap_pwd.c+= ${NO_WUSE_AFTER_FREE}