public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 1/6] Add SAFE_REALLOC() helper function to LTP library
@ 2021-05-05  8:18 Martin Doucha
  2021-05-05  8:18 ` [LTP] [PATCH v3 2/6] Add SAFE_RECV() " Martin Doucha
                   ` (5 more replies)
  0 siblings, 6 replies; 26+ messages in thread
From: Martin Doucha @ 2021-05-05  8:18 UTC (permalink / raw)
  To: ltp

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
---

Sorry for resubmitting so soon, I forgot to include the gitignore/runfile
paperwork for the new test. Fixed in patch 6.

Changes since v1: None

 include/tst_safe_macros.h |  5 +++++
 lib/tst_safe_macros.c     | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index b9d9baa1a..d6f32ef4c 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -67,6 +67,11 @@ int safe_dup2(const char *file, const int lineno, int oldfd, int newfd);
 #define SAFE_MALLOC(size) \
 	safe_malloc(__FILE__, __LINE__, NULL, (size))
 
+void *safe_realloc(const char *file, const int lineno, void *ptr, size_t size);
+
+#define SAFE_REALLOC(ptr, size) \
+	safe_realloc(__FILE__, __LINE__, (ptr), (size))
+
 #define SAFE_MKDIR(pathname, mode) \
 	safe_mkdir(__FILE__, __LINE__, NULL, (pathname), (mode))
 
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index 182b690bb..fd5f1704b 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -5,6 +5,7 @@
 
 #define _GNU_SOURCE
 #include <unistd.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <sched.h>
 #include <sys/ptrace.h>
@@ -433,6 +434,20 @@ int safe_dup2(const char *file, const int lineno, int oldfd, int newfd)
 	return rval;
 }
 
+void *safe_realloc(const char *file, const int lineno, void *ptr, size_t size)
+{
+	void *ret;
+
+	ret = realloc(ptr, size);
+
+	if (!ret) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"realloc(%p, %zu) failed", ptr, size);
+	}
+
+	return ret;
+}
+
 sighandler_t safe_signal(const char *file, const int lineno,
 	int signum, sighandler_t handler)
 {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-05-10  9:07 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-05  8:18 [LTP] [PATCH v3 1/6] Add SAFE_REALLOC() helper function to LTP library Martin Doucha
2021-05-05  8:18 ` [LTP] [PATCH v3 2/6] Add SAFE_RECV() " Martin Doucha
2021-05-10  7:55   ` Petr Vorel
2021-05-05  8:18 ` [LTP] [PATCH v3 3/6] Add SAFE_IOCTL() variant for library code Martin Doucha
2021-05-05  9:12   ` Cyril Hrubis
2021-05-10  7:57   ` Petr Vorel
2021-05-05  8:18 ` [LTP] [PATCH v3 4/6] Add rtnetlink helper library Martin Doucha
2021-05-05 10:17   ` Petr Vorel
2021-05-05 10:25     ` Martin Doucha
2021-05-05 11:24       ` Petr Vorel
2021-05-05 11:26   ` Petr Vorel
2021-05-05 12:16     ` Cyril Hrubis
2021-05-05 20:20       ` Petr Vorel
2021-05-05 13:15     ` Martin Doucha
2021-05-05 20:24       ` Petr Vorel
2021-05-05 12:14   ` Cyril Hrubis
2021-05-10  9:07   ` Petr Vorel
2021-05-05  8:18 ` [LTP] [PATCH v3 5/6] Add helper functions for managing network interfaces Martin Doucha
2021-05-05 12:39   ` Cyril Hrubis
2021-05-05  8:18 ` [LTP] [PATCH v3 6/6] Add test for CVE 2020-25705 Martin Doucha
2021-05-05 10:04   ` Petr Vorel
2021-05-05 10:33     ` Martin Doucha
2021-05-05 11:13       ` Petr Vorel
2021-05-05 13:06   ` Cyril Hrubis
2021-05-05 15:54     ` Martin Doucha
2021-05-10  7:42 ` [LTP] [PATCH v3 1/6] Add SAFE_REALLOC() helper function to LTP library Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox