Questions tagged [flawfinder]

Flawfinder is a simple software tool that examines C/C++ source code and reports possible security weaknesses (“flaws”) sorted by risk level. It’s very useful for quickly finding and removing at least some potential security problems before a program is widely released to the public.

12 questions
6
votes
1 answer

read() - Check buffer boundaries if used in a loop including recursive loops

I have this code and run it with Flawinder, and i get this output on the read() functions: Check buffer boundaries if used in a loop including recursive loops Can anyone see the problem? #include void func(int fd) { char *buf; size_t…
2
votes
1 answer

Why is flawfinder reporting problems with fopen?

I am using FlawFinder to find potential vulnerabilities in a piece of C code. In the analysis, the tool reports this problem: file.c:54: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening…
Francesco
  • 897
  • 8
  • 22
2
votes
0 answers

I can't solve this Flawfinder Warning (CWE-78, CWE-120)

I can't solve these two warnings found by Flawfinder. Could you answer to me with an example of the correct code? Final results: flawfinder_exercise_old_SAL_syntax.cpp:48: [4] (shell) system: This causes a new program to execute and is difficult…
ZioNick
  • 31
  • 3
1
vote
1 answer

How much can we trust to warnings generated by static analysis tools for vulnerablity detection?

I am running flawfinder on a set of libraries written in C/C++. I have a lot of generated warnings by flawfinder. My question is that, how much I can rely on these generated warnings? For example, consider the following function from numpy library…
1
vote
1 answer

How to improve code around flawfinder memset warning?

In my code, all calls to memset appear as warnings with the flawfinder tool. In the simplest case it could boil down to the equivalent to float f1; float f2; void* p1 = &f1; void* p2 = &f2; memcpy(p1, p2, sizeof(float)); The…
alfC
  • 14,261
  • 4
  • 67
  • 118
1
vote
1 answer

Fix (CWE-120, CWE-20) detected by Flawfinder

I've been asked to analyze some C code with Flawfinder: char * buffer; size_t len; // my_fd is a file descriptor read(my_fd, &len, sizeof(len)); buffer = malloc(len + 1); read(my_fd, buffer, len); buffer[len] = '\0'; I get the following warnings on…
LucaBonadia
  • 91
  • 2
  • 12
1
vote
2 answers

Python: Why flawfinder module is not working in cmd windows?

Python flawfinder module is working in bash but not working in Windows command commandline. Here are the steps I followed: Python installation path - C/Users/xyz/AppData/Local/Programs/Python/Python37-32/python pip install flawfinder When I type…
Naveen Kumar
  • 1,266
  • 1
  • 21
  • 50
0
votes
1 answer

How to use flawfinder with a git patch

I want to use flawfinder for my merge requests, thus analyzing only the code that change. I saw that flawfinder supports patches, so I thought it would be really easy. Thing is : I'm unable to make it work with git patch. Flawfinder does recognize…
RobinG
  • 135
  • 10
0
votes
1 answer

Flawfinder error- internal buffer overflows. How to limit string input size and protect it from overflow?

I have the following code: void parseOptions(int argc, char* argv[]) { std::string mob; int option, index; struct option long_options[] = {{"version", no_argument, 0, 'V'}, {"mobile-interface",…
lior.i
  • 573
  • 1
  • 7
  • 20
0
votes
0 answers

Avoid possible symlinks in C++ when using ofstream

I have this code ofstream file; file.open(filePath, std::ios::app); file << content; file.close(); When I run Flawfinder it says: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force…
Mazen Ak
  • 152
  • 7
0
votes
1 answer

Flawfinder (CWE-119!/CWE-120) for char array C++

I have a char array defined like this char buffer[100]; When I run Flawfinder scan for hits I get the one says: (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues…
Mazen Ak
  • 152
  • 7
0
votes
1 answer

A flaw reported by Flawfinder, but I don't think it makes sense

The question is specific to a pattern that Flawfinder reports: The snippet unsigned char child_report; ... auto readlen = read(pipefd[0], (void *) &child_report, sizeof(child_report)); if(readlen == -1 || readlen !=…
Hongce Zhang
  • 103
  • 6