forked from NVIDIA-AI-Blueprints/vulnerability-analysis
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Title
Enhance search_for_called_function to support macro expansion and indirect function calls
Current implementation covers most common cases, this would add advanced edge cases
Description
The current search_for_called_function method in c_lang_function_parsers.py handles basic function call detection but skips advanced patterns that are common in real-world C codebases. Section 5 of the method is currently marked as "advanced, skip for now" but should be implemented to provide comprehensive function call analysis.
Current Implementation Status
The method currently supports:
- ✅ Direct function calls:
callee_function( - ✅ Struct member calls:
obj->callee_function(orobj.callee_function( - ✅ Function pointer variable calls:
foo_ptr( - ❌ Macro expansion and indirect calls (Section 5 - NOT IMPLEMENTED)
1. Macro Function Call Detection
Problem: Macros that expand to function calls are not detected.
Examples:
#define CALL_FUNC(func, arg) func(arg)
#define SAFE_CALL(func) if(func) func()
#define DEBUG_CALL(func) func()
void example() {
CALL_FUNC(printf, "Hello"); // Should detect: printf
SAFE_CALL(my_callback); // Should detect: my_callback
DEBUG_CALL(debug_print); // Should detect: debug_print
}2. Function Pointer Array Access
Problem: Function calls through arrays are not detected.
Examples:
typedef int (*func_ptr_t)(int, int);
func_ptr_t funcs[] = {add, subtract, multiply};
void example() {
int result = funcs[0](5, 3); // Should detect: add
int result2 = funcs[1](10, 5); // Should detect: subtract
}3. Struct with Function Pointer Arrays
Problem: Function calls through struct member arrays are not detected.
Examples:
typedef struct {
int (*ops[3])(int, int);
int (*handler)(void);
} calculator_t;
void example() {
calculator_t calc = {{add, subtract, multiply}, error_handler};
int result = calc.ops[1](10, 5); // Should detect: subtract
calc.handler(); // Should detect: error_handler
}Metadata
Metadata
Assignees
Labels
No labels