busybox/scripts/test_setenv_leak.c
<<
>>
Prefs
   1#include <stdio.h>
   2#include <stdlib.h>
   3#include <unistd.h>
   4int main(int argc, char **argv)
   5{
   6        char buf[256];
   7
   8        int i = argv[1] ? atoi(argv[1]) : 999999;
   9        while (--i > 0) {
  10                sprintf(buf, "%d", i);
  11                setenv("VAR", buf, 1);
  12        }
  13        printf("Check size of [heap] mapping:\n");
  14        freopen("/proc/self/maps", "r", stdin);
  15        while (fgets(buf, sizeof(buf), stdin))
  16                fputs(buf, stdout);
  17        return 0;
  18}
  19