🗽
🗽
🗽
🗽
C/Cpp and OS
Search…
Guide
Templates and methods
Linked List with C
Linked List with C++
Stacks with C
Queues with C
Graphs with C/C++
Trees with C/C++
DS with C
Reverse Linked List
Implement Queue with LL
Find mid of LL without traverse
Delete a Node from LL
Create a Binary search tree
String and Array
Reverse string
implement strcmp in C
Maximum Subarray
CTCI
Ch 01 - Arrays and Strings
Ch 02 - Linked List
Algorithm
Bubble Sort
Insertion Sort
Merge Sort
Count Prime
Basic Concept in C
Understand about pointer
Pre/Post Increment Operator
string and constant charaters
buffer overflow
Short-circuit evaluation
Allocate memory for 2D array dynamically
OS review
For beginner
Reference
Question Collecting:
References
Template on Linux
Powered By
GitBook
buffer overflow
*** stack smashing detected ***
A buffer overflow occurs when the user input exceeds the buffer capacity. https://www.educative.io/edpresso/what-is-the-stack-smashing-detected-error
Find the potential exception
1
void* memcpy(void* pvTo, void* pvFrom, size_t size){
2
3
byte* pbTo = (byte*)pvTo;
4
byte* pbFrom = (byte*)pvFrom;
5
6
7
while(size-- > 0)
8
*pbTo++ = *pbFrom++;
9
10
11
return pvTo;
12
}
Copied!
Code:
1
#include <stdio.h>
2
typedef unsigned char byte;
3
4
void* z_memcpy(void* restrict pvTo, void* pvFrom, size_t size){
5
byte* pbTo = (byte*)pvTo;
6
byte* pbFrom = (byte*)pvFrom;
7
8
9
while(size-- > 0){
10
printf("TO: %c, From: %c \n", *pbTo, *pbFrom);
11
*pbTo++ = *pbFrom++;
12
}
13
return pvTo;
14
}
Copied!
Test code
1
int main() {
2
3
char to[4] = "";
4
char from[] = "abcdefg";
5
6
z_memcpy(to, from, 14);
7
8
return 0;
9
}
Copied!
Basic Concept in C - Previous
string and constant charaters
Next - Basic Concept in C
Short-circuit evaluation
Last modified
5mo ago
Copy link
Contents
*** stack smashing detected ***
Find the potential exception
Code: