All Questions
Tagged with buffer-overflow string
19 questions
0
votes
0answers
41 views
How to prevent strings to read CTF flags in C
I am creating a simple CTF in buffer overflow below is the sample code:
#include <stdio.h>
void secretFunction()
{
printf("this is your flag!\n");
}
void echo()
{
char buffer[20];
...
1
vote
1answer
65 views
Data truncated when strncpy() used for copying string in MFC [duplicate]
In order to fix a buffer overflow Coverity issue, I have used strncpy() to copy a list item. The list item needs to be drag and dropped from one row to another. So the string that needs to be copied ...
0
votes
1answer
51 views
Segmentation Fault in the Following Program for string comparisons
I am getting segmentation fault for the following code. The logic of the program that it should accept the correct password ("abcd") and it should deny access if entered any other password, but I am ...
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 ...
0
votes
1answer
649 views
Prevent buffer overflow when using cin.getline and fgets in conjugation
The problem is that the size of strings is small. So the overflowing bits get assigned to next string.
I recently came to know that we shouldn't use fflush(stdin) for discarding unwanted sequence in ...
-1
votes
1answer
174 views
how can i insert a single char in front of my c string?
So on line 28 i make a c-string called temp. I assign the value of temp[0] to the value of string[index]. Now i want to add string to the end of temp and then make string store the same values as ...
-1
votes
4answers
100 views
Array memory allocation of strings
I have written simple string program using array allocation method. I have allocated character array 10 bytes, but when i give input, program is accepting input string of greater than 10 bytes. I am ...
1
vote
1answer
544 views
sscanf function changes the content of another string
I am having problems reading strings with sscanf. I have dumbed down the code to focus on the problem. Below is a function in the whole code that is supposed to open a file and read something. But ...
6
votes
4answers
609 views
Distinguish between string and byte array?
I have a lot of functions that expect a string as argument, for which I use char*, but all my functions that expect a byte-array, also use char*.
The problem is that I can easily make the mistake of ...
4
votes
2answers
437 views
C buffer overflow
I tried to make a function that replaces all occurrences of str1 in a text t with str2 but I keep getting a "buffer overflow" error message. Can you please tell me what is wrong with my function?
#...
4
votes
6answers
6k views
Does buffer overflow happen in C++ strings?
This is concerning strings in C++. I have not touched C/C++ for a very long time; infact I did programming in those languages only for the first year in my college, about 7 years ago.
In C to hold ...
7
votes
1answer
636 views
Declaring hardcoded std::string causes buffer overflow
I have the following line in my program that causes a run-time warning:
if (!is_directory("C:\\NGFMS_Debug\\Files") && !create_directories("C:\\NGFMS_Debug\\Files"))
The text of the warning ...
3
votes
3answers
7k views
What might be causing this buffer overflow?
Hello I am trying to compile the following code,
#include <stdio.h>
#include <string.h>
int main()
{
int i;
char a[3] = {'1', '2', '3'},b[3] = {'3', '2', '1'};
strcpy(a,b);
for(i=0; i<...
9
votes
5answers
16k views
How can I use strncat without buffer overflow concerns?
I have a buffer, I am doing lot of strncat. I want to make sure I never overflow the buffer size.
char buff[64];
strcpy(buff, "String 1");
strncat(buff, "String 2", sizeof(buff));
strncat(buff, "...
1
vote
1answer
3k views
Using a buffer to convert http request responses to string in Android - Not getting entire response
I'm developing an app that posts to a site and I'm trying to store the entity response as a string. However, the string only seems to contain a small portion of the response, roughly 35 lines or so. I'...
0
votes
5answers
349 views
String overflow in C++? This inecessant beeping is weird
I'm startin development on a junk file generator, but for some reason if I use a large number it will beep infinitely until the file is finished, I'm thinking there is a \a character somewhere in the ...
4
votes
3answers
5k views
Buffer too small when copying a string using wcsncpy_s
This C++ code is kind of lame, but I need to maintain it. I cannot seem to figure out a "buffer too small" problem. I am using Visual Studio 2010. I will come up with minimal code required to ...
3
votes
8answers
2k views
string overflow detection in C
We are using DevPartners boundchecker for detecting memory leak issues. It is doing a wonderful job, though it does not find string overflows like the following
char szTest [1] = "";
for (i = 0; i &...
5
votes
7answers
11k views
strcpy when dest buffer is smaller than src buffer
I am trying to understand the difference/disadvantages of strcpy and strncpy.
Can somebody please help:
void main()
{
char src[] = "this is a long string";
char dest[5];
strcpy(dest,src) ;
printf("...