summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDenys Vlasenko2017-07-22 02:25:47 +0200
committerDenys Vlasenko2017-07-22 02:25:47 +0200
commitbbf17bbf326c7157ca237b9659472ddf7626e68d (patch)
tree95450d50a1931a6b13f941cdf3deb036506148df /scripts
parentef0366eb4f02bb0cda359b977fdbdfa7c145f76f (diff)
downloadbusybox-bbf17bbf326c7157ca237b9659472ddf7626e68d.zip
busybox-bbf17bbf326c7157ca237b9659472ddf7626e68d.tar.gz
crond: do not assume setenv() does not leak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/test_setenv_leak.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/test_setenv_leak.c b/scripts/test_setenv_leak.c
new file mode 100644
index 0000000..e51722c
--- /dev/null
+++ b/scripts/test_setenv_leak.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+int main(int argc, char **argv)
+{
+ char buf[256];
+
+ int i = argv[1] ? atoi(argv[1]) : 999999;
+ while (--i > 0) {
+ sprintf(buf, "%d", i);
+ setenv("VAR", buf, 1);
+ }
+ printf("Check size of [heap] mapping:\n");
+ freopen("/proc/self/maps", "r", stdin);
+ while (fgets(buf, sizeof(buf), stdin))
+ fputs(buf, stdout);
+ return 0;
+}