summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-06-30 15:31:31 -0400
committerJakob Kaivo <jkk@ung.org>2020-06-30 15:31:31 -0400
commitf2a8df6171b3eae8c949c892e8a35d7acd51084c (patch)
tree5db460a79a28c85691f9ffb4a9f0cc1f65af0be3 /test
parent62961fe31686bb1b4c071e128047a49f321492e9 (diff)
add a test program that can be wrapped with LD_PRELOAD
Diffstat (limited to 'test')
-rw-r--r--test/wrapper.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/wrapper.c b/test/wrapper.c
new file mode 100644
index 0000000..a260894
--- /dev/null
+++ b/test/wrapper.c
@@ -0,0 +1,22 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(void)
+{
+ const char buf[] = "THIS IS A CONSTANT STRING";
+
+ char *ptr = realloc(NULL, sizeof(buf));
+ memcpy(ptr, buf, sizeof(buf));
+ printf("%p: %s\n", ptr, ptr);
+
+ ptr = realloc(ptr, sizeof(buf) * 2);
+ memcpy(ptr + sizeof(buf) - 1, buf, sizeof(buf));
+ printf("%p: %s\n", ptr, ptr);
+
+ ptr = realloc(ptr, sizeof(buf) * sysconf(_SC_PAGESIZE));
+ memcpy(ptr + (2 * sizeof(buf)) - 2, buf, sizeof(buf));
+ printf("%p: %s\n", ptr, ptr);
+}