Questions tagged [c]

The C programming language, commonly used for low-level programming

C is a low-level programming language. It allows direct pointer manipulation and does not intrinsically verify array bounds, making it rife for security vulnerabilities.

Use this tag for questions about security that are directly related to C, such as security analysis of C code and exploiting badly-written C code. Do not use this tag just because you're writing a program in C, only if C is directly relevant to the question. Questions about programming in C are off-topic here, but can be asked on Stack Overflow.

298 questions
2
votes
1 answer

Unsafe C program accepting malicious string inputs

I have a question regarding to this unsafe C program. int main(int argc, char **argv) { char text[32]; static int some_value = -72; strcpy(text, argv[1]); /* copy the parameter into the array "text" */ printf("This is how you print…
weejing
  • 161
  • 2
  • 7
1
vote
1 answer

Most secure way to read an int32 in C

I was discussing about the subtle issue that you can face when you write in C, so (for fun) I started to create bulletproof code that can read an 32bit integer from stdin. I wrote this…
Simone Aonzo
  • 165
  • 1
  • 1
  • 6
0
votes
0 answers

How to exploit this C program to call a certain function?

The goal is to call the function foo in the following program: struct object { unsigned char buf[36]; void (*fp)(); }; void baz(struct object * obj, unsigned int num) { for (int i = 0; i < num; i++) { unsigned int x; …
wayne
  • 1
  • 1
0
votes
2 answers

Example of a double-free vulnerability in C

I hope this is the correct forum to ask for the question that I have: We are currently discussing double-free vulnerabilities in our software security class, which is why I know the code given below is suppossed to be an example of how a double-free…
user503842
  • 277
  • 1
  • 4
  • 10
-2
votes
1 answer

Exploiting C99 VLAs to cause stack overflow

In my project one of the command-line arguments is loaded into a C99 VLA (variable-length array) as shown in the example code below. My question is: can this be exploited? If yes, I'd like to be shown how and also how to patch it. #include…