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 6919073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:56:33+00:00 2026-05-27T09:56:33+00:00

#include <stdio.h> #include <stdlib.h> void badf(int n, char c, char* buffer) { int i;

  • 0
#include <stdio.h>
#include <stdlib.h>
void badf(int n, char c, char* buffer)
{
    int i;
    for (i=0; i<n; i++)
    {
    buffer[i]=c;
    }

}

void f(int n, char c)
{
    char buffer[16];
    badf(n,c,buffer);
}

void message ()
{
printf("Hello\n");

}

int main()
{
f(32,0x08048411);
    return 0;
}

This is the code I got so far (got given the base of it and got to stick to it, thats why there is a badf and f function)

The goal is that the program prints the Hello message by overflowing to the Instruction pointer. Using Data display debugger in Ubuntu, I believe the address of this display is 0x0804811.

When I run the program through and use x/16x $esp the next address in the stack is just 1s (am guessing only the last two digits are being taken from the address above)

What am wondering is how I would make the next address the full address and not just the last two digits.

Also the 32 is calculated from 16 (buffer defined above) + 8 (base pointer) + 8 (Instruction pointer)

Thanks in advance for any help as I know this specific problem.

  • 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-27T09:56:34+00:00Added an answer on May 27, 2026 at 9:56 am

    Do not pass the address via an 8bit integer (char) but use a type wide enough … – that is at least 32bits.

    Modify as follows:

    void badf(int n, unsigned int u, char* buffer)
    ...
    
    void f(int n, unsigned int u)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> #include <stdlib.h> void message(char m) { print(Hello\n); } int main() { message(m);
#include <stdio.h> #include <stdlib.h> int main( void ) { char *ptr1 = Hello World\n;
#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char
#include<stdio.h> #include<sys/types.h> #include<stdlib.h> int turn; int flag[2]; int main(void) { int pid,parent=1; printf(before vfork\n);
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { typedef int (FuncPtr)(); char asmFunc[]
#include <stdio.h> #include <stdlib.h> void copyint(char *i,char** temp); int main() { char* a=00313; char*
The program is: #include <stdio.h> #include <stdlib.h> int main(void) { char *a=abc,*ptr; ptr=a; ptr++;
#include <stdio.h> #include <stdlib.h> int main (void) { double f; printf (What is the
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int i=0; while(i<10) { printf(%d,
This is the code: #include <stdio.h> #include <stdlib.h> void acceptMaze(char maze[ROW][COLOUMN], int nrows, int

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.