Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:21:02+00:00 2026-06-01T12:21:02+00:00

I was reading about buffer, stack and heap overflows. I read this post as

  • 0

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);

  1. I will overwrite the data segment and may ruin the buf2 content, right?
  2. 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:21:03+00:00Added an answer on June 1, 2026 at 12:21 pm

    It doesn’t matter where your data is. If you try hard enough, you can write outside it. Whether or no any stack buffer overrun might be used to overwrite a return address and cause code in the buffer to be executed, that is architecture dependent. IMHO, data in the stack segment should not be executable and and attempt to execute it should result in a memory-management interrupt.

    Using ‘globals’ instead of stack variables is anyway not a sane solution for anything except trivial apps.

    I only ever load data into dynamicaly-allocated buffers inside buffer classes, so stack buffer overruns have never been a problem in my apps, (and besides, I just don’t overrun buffers!).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading about Django, I saw this: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin - the fancy simple to use admin
I have a question about buffer overflaw, in this program : #include <stdio.h> #include
I've been reading recently about cache-oblivious data structures like auxiliary buffer heaps. These data
Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome
Reading about Delphi's Exit statement (see here for instance), I cannot ignore that writing
When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that
I was reading about the flags used in gcc, and read a reccommendation to
Disclaimer: please do not bother reading this long post unless you are an embedded
The cplusplus.com example for reading text files shows that a line can be read
EDIT: Upon re-reading my original question I realized very quickly that it was very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.