Questions tagged [stack-smash]

Stack smashing is a buffer overflow vulnerability which is characterized by writing data outside the size of a stack-allocated buffer, causing corruption of a neighboring stack frame and potentially permitting execution of malicious code. Use this tag for questions about `stack smashing detected` and similar runtime errors, code with vulnerable buffers and other security risks related to stack smashing. See also: [buffer-overflow] and [buffer-overrun].

In software, a stack buffer overflow (also known as stack smashing) occurs when a program writes to a memory address on the program's call stack outside of the intended data structure, which is usually a fixed length buffer. Stack buffer overflow bugs are caused when a program writes more data to a buffer located on the stack than what is actually allocated for that buffer. This almost always results in corruption of adjacent data on the stack, and in cases where the overflow was triggered by mistake, will often cause the program to crash or operate incorrectly. Stack buffer overflow is a type of the more general programming malfunction known as buffer overflow (or buffer overrun).

This tag should be used for questions about stack smashing detected and similar runtime errors, code with vulnerable buffers and other security risks related to stack smashing. See also: and .

161 questions
0
votes
2 answers

Assembly version of C code to launch a shell

In buffer overflow assignment, I got a C file (call_shellcode.c) which contains an assembly version of the following C code which executes to open a shell: #include #include int main(){ char *name[2]; name[0] =…
Light Yagami
  • 961
  • 1
  • 9
  • 29
0
votes
1 answer

gcc -fstack-protector does not throw error

Does someone know why the following lines of code throws a *** stack smashing detected *** error #include #include #include int main(int argc, char **argv) { char x[16]; …
ronce96
  • 84
  • 2
  • 9
0
votes
1 answer

stack smashing detected, abort, OpenGl freeglut

So I have the following code for graphics perspective projection: #include #include #include #include #define UpperBD 5 #define PI 3.1415926 #define Num_pts 10 float Xe = 200.0f; float Ye =…
alti21
  • 127
  • 2
  • 11
0
votes
1 answer

Stack Smashing Issue With Pipes, greps, wc in C

EDIT: ** QUESTION HAS BEEN ANSWERED: see comments by PaulMckenzie and Rishikesh Raje The intention of this function is to call grep on parameter file with parameter pattern using pipes, but I am having an issue with stack smashing in my program. It…
Sam Owens
  • 11
  • 2
0
votes
1 answer

Segmentation Fault - finding buffer size

I'm trying to smash the stack and am using the below C code: #include get_inp() { char buf[8]; gets(buf); puts(buf); } main(){ get_inp(); return 0; } I get the Segmentation fault only if I enter a minimum of 16 characters as input. …
0
votes
0 answers

G++ Linux Stack Smash Detection

In a Packet() class, I have this method that will self encapsulate the packet iteslf (i.e. adding the 6 bytes of header in front of it, but of course first allocating the necessary memory) However, it is giving me a * stack smashing detected *: int …
bli
  • 93
  • 6
0
votes
1 answer

Stack smashing in C on function return

I have a small program which converts 12 hour time to 24 hour time. #include #include #include #include #include #include #include int get_tokens(char* buf, char *fields[],…
0
votes
1 answer

execv() system call creating stacking smashing error

Whenever I used the execv() here in my code, it works and has no errors, but still causes stack smashing to crash the program during runtime. Am I doing anything wrong here? Here is the function with the execv(): void execute(char *args[], char…
0
votes
1 answer

C : stack smashing detected but everything is working before return statement

Ok so there are lots of stack smashing detected questions on stackoverflow, I looked at 6-7 of them but couldn't clear my problem. I have a void function in C named encryptor, which takes a char array, and updates that array. void encryptor(char*…
Naman
  • 372
  • 4
  • 20
0
votes
0 answers

Intentional friend class redifinition and -fstack-protector

I have been trying testing if multiple definition of a friend class in different .cpp files would work. To do that I defined a main class inside main_class.hpp file: class main_class { private: int a; int b; int gimme_a() { …
K. Koovalsky
  • 596
  • 4
  • 17
0
votes
1 answer

Stack smashing/Buffer overflow in C

I have this code int Iminente(char tab[3][3], char comp, char jog, char str[3][3]){ int i, j, X = 0, val; char col[4], diag[2][4]; strcpy(diag[0], &tab[0][0]); // Diagonal E-D C-B (= \ ) strcat(diag[0], &tab[1][1]); …
DMaxter
  • 178
  • 5
  • 19
0
votes
2 answers

How to reproduce "Stack smashing detected" in C++ application

I get this error constantly in an embedded Linux application. I am trying to locate the problem and I narrowed it down to the following piece of code. I want to solve this problem, if not I'd appreciate a couple of pointers what might have caused…
mozcelikors
  • 2,582
  • 8
  • 43
  • 77
0
votes
0 answers

about memory address in assembly

I'm now taking the coursera course and I have a question about one of the readings. Link: http://insecure.org/stf/smashstack.html 0x8000490
: pushl %ebp 0x8000491 : movl %esp,%ebp 0x8000493 : subl …
0
votes
0 answers

Stack Smashing Error While Working with CStrings

I am working on a small project and I am absolutely stuck. The purpose of the function I'm working on is to rearrange and change a Cstring based on a few preset rules. Where my issue lies is within the second portion of my swapping algorithm I came…
dirtydan
  • 1
  • 1
0
votes
1 answer

BOF with non exec stack

I'm try to pass the level 2 of this "game" http://smashthestack.org/faq.html (connect via ssh on the blackbox server) that consist of a basic buffer overflow. In the directory /home/level2 (there is a directory for each level with a file that…