new

Try Stack Overflow for Business

Our new business plan for private Q&A; offers single sign-on and advanced features. Get started by May 31 for 2 months free.

Learn more

All Questions

Tagged with
2
votes
1answer
87 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
1answer
82 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
3answers
184 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 ...
0
votes
1answer
94 views

BufferOverflowException while sending data of specific size

I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K ...
1
vote
1answer
102 views

C++ 3D array to 1D causes heap-buffer-overflow

I want to give a minimal example. If the code provided is not enough, please tell me what else you need. It's nothing super secret ;) Consider the following two implementations: Using 3d array: .h ...
-7
votes
2answers
76 views

values of array gets changed automatically after taking string input

#include <iostream> #include <math.h> using namespace std; int main() { long int m,i; cin>>m; float first=0,second=0,disp=0; int arr[m]; char ch[m]; for(i=0;...
0
votes
1answer
41 views

Behavior of char pointer [duplicate]

I am really confused about the following: char *list = malloc(sizeof(char)); list[0] = 'a'; list[1] = 'b'; printf("%s\n", list); My expectation was some kind of undefined behavior, because list has ...
0
votes
2answers
84 views

What explains this behavior of C compiler w.r.t string initialization?

The following code doesn't generate a null terminator /* Case 1 */ #include <stdio.h> void main () { char wbuf[16] = "0123456789abcdef"; printf("%s\n", wbuf); } See the relevant parts ...
-1
votes
4answers
92 views

Buffer over-run prevention for stack based buffers

I'm writing a C library that provides wrapper functions to strcpy, strcat, gets, etc to prevent buffer overflow attacks. Basically what I do is keeping track of the size of all buffers and prevent ...
0
votes
4answers
193 views

How does C treat Buffer overflows?

I understand that in C, there are arrays that can be given a length at declaration. I want to know if those length declarations are simply for other programmers to see and understand the use of, or if ...
2
votes
1answer
114 views

Overflowed buffer data does not get stored contiguously

I have the following code to simulate buffer overflow. Edit: I missed an important step in the code below. As the discussion progressed that the variable c is getting modified. void function (int fd,...
1
vote
2answers
385 views

Multiple fscanf

I have written the following program that is intended to read a string from a file into variable "title": #include <stdio.h> #include <stdlib.h> int main() { int m, b; char *...
1
vote
1answer
14k views

How can I store String value in char array in C?

I have char array to store string values. I wanted to store the value of a string variable into the char array. char Password[30]; char User[2]; int i; for(i=0; i<5; i++) { printf("Enter ...
2
votes
1answer
2k views

Comprehensive and clear NOP sled technique explanation needed

I have browsed the internet a lot and still could not understand the way it works No success with this link either: How does a NOP sled work? Okay, let's say we have a buffer char a[8]; in the ...
3
votes
5answers
8k views

Array overflow (why does this work?)

Okay, so I was teaching my girlfriend some c++, and she wrote a program that I thought wouldn't work, but it did. It accesses one more element in the array then there is (for instance, accessing array[...
1
vote
3answers
350 views

Will Insure++ detect array overflows in a C structure on the heap?

I have been trying to find the best programs to detect buffer overflows in a C program. In particular I am looking to detect overflows of a char array that exists within a C structure on the heap. ...