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

  • Home
  • SEARCH
  • 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 454063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:14:01+00:00 2026-05-12T22:14:01+00:00

I am a bit confused in the idea of code injection in C. If

  • 0

I am a bit confused in the idea of code injection in C. If somebody could explain it and show how its done I would appreciate it.

So lets say in C you have some Char array of size 512 which is being written to the contents of a socket of length 1024, and that char array now holds some sort of code but only half of what was written.

How is the malicious code executed in a buffer overflow, I think I am confused on the process structure(stack, heap, data, text).

  • 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-05-12T22:14:01+00:00Added an answer on May 12, 2026 at 10:14 pm

    The general trick has to do with how the program’s code and variables are layed out in memory. For example, when a function is called the program (code inserted by the compiler) must store the address of the instruction to return to. So if this is the 32 bit word just before the beginning of the stack, one could do:

     void foo()
     {
        int array[5];
        int var = 0;
        int var2 = 0;
    
        // read in user input
        printf("Enter index and value to write:");
        scanf("%i", var);
        scanf("%i", var2);
    
        // malicious user might set var to -1 and var2 to an address to execute
        // if say the 32-bit value before the stack variables is the instruction to
        // return to
        array[var] = var2
    
        // return now goes to malicious code
     }
    

    (So your job is to construct code so that such a thing is not possible. 🙂 )

    The rules for how a function call is implemented, stack variables allocated, values passed, and return values returned back is called the calling convention. I reccomend reading the attached article for a good indepth coverage of C calling conventionts.

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

Sidebar

Related Questions

I'm a bit confused over the .net redistributables... Our C# code uses some API
I am a bit confused about how to implement EditorForModel. I get the idea
I'm getting a bit confused how delegation works. I believe the idea is to
I've seen this question before, but still a bit confused: how would I create
I've become a bit confused about the idea of rendering a template due to
I'm a bit confused about the whole idea of IO; I want to know
Bit confused here, I have an on-demand instance but do I get charged even
I'm a bit confused about how many controllers I need, and when I can
This is a bit confused question for those who don't now advanced SQL... However.
I'm a bit confused about inheritance under sqlalchemy, to the point where I'm not

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.