Skip to content

Instantly share code, notes, and snippets.

@awreece
Created May 5, 2013 01:04
Show Gist options
  • Save awreece/5519313 to your computer and use it in GitHub Desktop.
Save awreece/5519313 to your computer and use it in GitHub Desktop.
$ cat print_buf.c
#include <stdio.h>
int main(int argc, char** argv, char** envp) {
char buf[100];
printf("Stack at %p\n", buf);
int i;
for (i = 0; envp[i]; i++) {
printf("%p: %s\n", envp[i], envp[i]);
}
}
$ env -i ./a.out howdy_bro
Stack at 0xffffddf8
$ env -i gdb -q ./a.out
Reading symbols from /home/ppp/a.out...(no debugging symbols found)...done.
(gdb) show environment
LINES=24
COLUMNS=84
(gdb) unset environment LINES
(gdb) unset environment COLUMNS
(gdb) r howdy_bro
Starting program: /home/ppp/a.out howdy_bro
Stack at 0xffffddc8
0xffffdfd2: PWD=/home/ppp
0xffffdfe0: SHLVL=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment