Does writing program using global variables is safer?
- by ZoZo123
I was reading about buffer, stack and heap overflows. I read this post as well. my question is like that: if I use only global variables in my code, can I say it prevents all the exploits of overflow?
let's say I have this buffers in code declared in the global scope:
char buf1[10];
char buf2[100];
If I send buf1 as the buffer to recv(int s, char *buf, int len,int flags);
I will overwrite the data segment and may ruin the buf2 content, right?
Would I be able to run a code from it because as I know it is not a code segment and data segment is not executable.
Can we conclude that using Globals is the safest way?