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
1 answer

COM method call accidentally corrupts the stack

I have a bit of code which is calling a method from a COM object (IDirect3D9), but every call causes a run-time check failure #0. The failure is caused by ESP not being properly preserved across the call, so some kind of stack issue (as COM methods…
ssube
  • 47,010
  • 7
  • 103
  • 140
0
votes
0 answers

Buffer Overflow with structures - C

I am a beginner with programming and I have no idea how to fix my code. I want every students[i] to have the overall variable preset with the characters "none". Every way I have tried to write my code for this has not worked and I get Buffer…
Kai
  • 1
  • 2
0
votes
1 answer

***stack smashing detected***

When i run my code on windows (CodeBlocks) everything works but when i run in on Linux it says stack smashing detected and doesnt print anything but the board; Here ius the code: #include #include void inimatri(char…
0
votes
0 answers

How to implement stack smashing protection in Blazor

A client is asking that we follow their security standards and implement stack smashing protection (SSP) in the in-house (i.e. intranet) Blazor apps that we are developing for them. (Working with VS 2022, .NET 6.0) I had not heard of that term…
BarnumBailey
  • 391
  • 1
  • 4
  • 13
0
votes
0 answers

What is causing the *** stack smashing detected *** error and how can i resolve it?

i'm writing a function that gets passed an array of length 100, full of random integers between 0 and 25 (to be specific the data type is double, but the numbers themselves are whole numbers), that has already been sorted into increasing order. What…
0
votes
1 answer

My c program to remove lines from a text file works on a small file, but has a stacksmash error with a large file

I am working on a program to filter a list of craigslist results; I want to find a relatively cheap room for rent. The finished program will remove lines that have a price over $600, and create a new file, but for now I am removing every line with a…
Corey
  • 257
  • 1
  • 4
  • 14
0
votes
1 answer

Wrong output with scanf function

so this is supposedly not a difficult question, but I've been getting this problem a few times when running my code in VS code. I am trying to separate the alphabets and numbers from the string, and I have used the method as follows (in my code)…
Wolfking
  • 103
  • 3
0
votes
2 answers

Stack smashing detected

#include using namespace std; int main() { int tablica[9]; string inputromanum; cout << "ROMAN: "; cin >> inputromanum; int maxindeks; bool disablenextcomp = false; int readysolution = 0; maxindeks =…
whitehat
  • 3
  • 5
0
votes
1 answer

solutions for stack overflow using functions in C?

the following code gives me a stack overflow error and I can't seem to find why. #include #include #include #include #include char main_choice(); int main() { //case_b(); // check_if_num1(); …
0
votes
0 answers

C/C++/Python program that allows to construct payloads that allow stack smashing to obtain Remote Code Execution

I want code it is for my assignment I need help I tired to code but I am confused.
0
votes
0 answers

Character array size check for stack smashing

In the code below, I'm attempting to concatenate 2 strings: str1 and str2 using strcat from string.h Since the length of destination string, str1 is 6 bytes on the stack, I expect any store of a length more than 6 shall trigger the stack smashing…
Electrix
  • 510
  • 3
  • 14
0
votes
0 answers

A question about the article 'Smashing The Stack For Fun And Profit'

I am reading Smashing The Stack For Fun And Profit. When the author uses x86 assembly codes to illustrate the execve() behavior, he says: 0x80002bc <__execve>: pushl %ebp 0x80002bd <__execve+1>: movl %esp,%ebp 0x80002bf <__execve+3>: pushl …
Junhui Zhu
  • 93
  • 5
0
votes
1 answer

Stack Smashing detected while implementing mergeSort in C++14

I am implementing standart MergeSort algorithm. I am getting a runtime error 'Stack Smashing Detected'. What is the root cause of such error and how to prevent my code from this error? I saw that the control is coming to merge function , but…
Subhadip
  • 423
  • 8
  • 16
0
votes
0 answers

Find distinct Combinations of Array

I'm trying to find all possible combinations of a given array. I found a solution here. I slightly adapted this approach since I need not only to have combinations with a fixed number of combinatioins but also all possible combinations up to a…
0
votes
0 answers

Stack smashing in file io in c

void issueBook(){ printf("Hii!\n"); //printf("Enter your student ID: "); //int stdID; //scanf("%d", &stdID); printf("Enter the book ID\n"); int bookID; scanf("%d", &bookID); FILE *in_file =…