Skip to content

Instantly share code, notes, and snippets.

@b4284
Created July 19, 2017 05:37
Show Gist options
  • Select an option

  • Save b4284/e1f6111a8a23f7d1aad6cd460368d151 to your computer and use it in GitHub Desktop.

Select an option

Save b4284/e1f6111a8a23f7d1aad6cd460368d151 to your computer and use it in GitHub Desktop.
#include <limits.h>
void array_access0(void)
{
int a[10];
int i;
for (i = 0; i < 10; ++i) {
a[i] = 0;
}
}
__attribute__((stack_protect)) void array_access1(void)
{
int a[10];
int i;
for (i = 0; i < 10; ++i) {
a[i] = 0;
}
}
int main(int argc, char **argv) {
void (*aa)(void);
switch (argv[1][0]) {
case '0':
aa = array_access0;
break;
case '1':
aa = array_access1;
break;
}
for (int i = 0; i < INT_MAX / 10; ++i) {
aa();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment