All Questions
Tagged with buffer-overflow arrays
28 questions
0
votes
0
answers
65
views
Splitting data in an ArraySegment<byte> to different Bytes[]
I'm trying to make a C# program that allows 2 computers to send files between each other, the client is the sender, the server is the receiver. The problem now is that I'm using ArraySegment which ...
0
votes
1
answer
78
views
The value of 'K' the position to insert changes to 0 after shifting value in array
In an array insertion program using C, while shifting the values from one position in the array to another the value of 'k' becomes zero.
I use windows 10, code blocks and also tried it directly with ...
2
votes
1
answer
240
views
Confusion of memory in buffer overflow while using strncpy()? [duplicate]
Scope: I have been trying to learn how does buffer overflow occur when using the strncpy function in C and I found this really unusual behavior.
I have two character array as arr1 and arr2. I am ...
0
votes
1
answer
163
views
Buffer Overflow Attack with Int
char c[10];
int value = 1;
Why the value changes to 0 until I enter 12 chars? Why is 12 not 10 or 11? (I know the terminator and how it pushed to the next memory space)
0
votes
0
answers
57
views
Receiving heap-buffer-overflow for the following code snippet
Below is the code:
/* Note: The returned array must be malloced, assume caller calls free() */
int* twoSum (int* numbers, int numbersSize, int target, int* returnSize)
{
int i, j;
j = ...
0
votes
0
answers
38
views
Stack buffer overflow but my program is working. Why?
I've got a problem with my program.
This program takes as an input users IDs ( e.g + 10 ) and the shows how many visits had this ID made and as output it shows the number of the visit. Or the program ...
-1
votes
2
answers
203
views
Why no error in concatenating & copying strings bigger than array size?
char string[5] = "stringBiggerThan5"; // shows error. Okay.
strcpy(string, "big string"); // overflow. seg fault. Perfect!
But, adding a string to a char[], which is bigger ...
0
votes
2
answers
445
views
char array initialization using cin.get()
I am trying something different with cin.get() like given below:
char chArray[30]="character array with size "; //current string size is 25 character with null character
cout<< chArray << ...
0
votes
0
answers
300
views
Leetcode problem works in my IDE, but RuntimeError occurs if i submit it to leetcode
i am new to C and was trying some leetcode problems.
I worked it out in my IDE (VS Code), and it seems to work with every testcase.
It even works if i run it in leetcodes terminal, but it suddenly ...
0
votes
2
answers
36
views
Variable address varies weather we diplay it or not?
Can anyone explain this?
Consider this program. We write modify dest[10] intentionally in order to see j value modified.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ...
2
votes
1
answer
133
views
Are integers always placed before character array in memory by the gcc compiler?
I am trying a simple buffer overflow in C from HTAOE book . This is the code :
#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[]){
int val0=10;
char ...
1
vote
1
answer
846
views
How to avoid buffer overflow with C struct array of strings
I'm running into buffer overflows when reading a file in C and copying character arrays. There are three potentially offending pieces of code and I can't figure out where I'm going wrong.
The first ...
2
votes
1
answer
635
views
Overwriting data via array vulnerabilities
I am trying to demonstrate a buffer overflow via an array index (when there isn't any bounds checking). What I am trying to do is change my bool authenticated = false to true by passing in a bad ...
0
votes
1
answer
344
views
buffer overflow while writing to char array
Could anyone help me out here?
I don't really know why this code doesn't work properly.
Just want to split a string in two. However, somehow strange thing happen that it writes 6 char instead of 3 ...
2
votes
3
answers
2k
views
How to avoid pressing enter twice when using getchar() to clear input buffer?
I have this program:
#include <stdio.h>
#define SIZE 19
int main(){
char string[SIZE];
while (string[0] != 'A'){
printf("\nEnter a new string.\n");
fgets(string,SIZE,stdin);
int storage ...