Hey, I’m new to buffer overflow exploits(just started 3 days ago). I’m trying to run this code and instead of the addition function running “+” run the multiplication function “*” using buffer overflow. I have tried multiple different but non prevailed
#include <stdio.h>
int num1;
int num2;
int res;
static int add(void)
{
res = num1+num2;
printf("\nAnswer: %u", res);
}
static int sub(void)
{
res = num1-num2;
printf("\nAnswer: %u", res);
}
static int mal(void)
{
res = num1*num2;
printf("\nAnswer: %u", res);
}
static int div(void)
{
res= num1/num2;
printf("\nAnswer: %u", res);
}
void do_operator(){
char op[1];
printf("Enter an operator (+, -, *, /):");
scanf("%s", &op);
if(*op == '+')
{
add();
}
else if (*op == '*')
{
mal();
}
else if (*op == '-')
{
sub();
}
else if (*op == '/')
{
div();
}
else
{
printf("\nNo valid input: %s", op);
}
}
int main()
{
printf("\nEnter number-1:");
scanf("%u", &num1);
printf("\nEnter number-2:");
scanf("%u", &num2);
do_operator();
return 0;
}