@@ -5,15 +5,18 @@ package zen_internals
55#include <dlfcn.h>
66#include <stdlib.h>
77
8- typedef int (*detect_sql_injection_func)(const char*, const char*, int);
8+ typedef int (*detect_sql_injection_func)(const char*, size_t, const char*, size_t , int);
99typedef int (*detect_shell_injection_func)(const char*, const char*);
1010
1111int call_detect_shell_injection(detect_shell_injection_func func, const char* command, const char* user_input) {
1212 return func(command, user_input);
1313}
1414
15- int call_detect_sql_injection(detect_sql_injection_func func, const char* query, const char* input, int sql_dialect) {
16- return func(query, input, sql_dialect);
15+ int call_detect_sql_injection(detect_sql_injection_func func,
16+ const char* query, size_t query_len,
17+ const char* input, size_t input_len,
18+ int sql_dialect) {
19+ return func(query, query_len, input, input_len, sql_dialect);
1720}
1821*/
1922import "C"
@@ -75,8 +78,14 @@ func DetectSQLInjection(query string, user_input string, dialect int) int {
7578 defer C .free (unsafe .Pointer (cQuery ))
7679 defer C .free (unsafe .Pointer (cUserInput ))
7780
78- // Call the detect_sql_injection function
79- result := int (C .call_detect_sql_injection (detectSqlInjection , cQuery , cUserInput , C .int (dialect )))
81+ queryLen := C .size_t (len (query ))
82+ userInputLen := C .size_t (len (user_input ))
83+
84+ result := int (C .call_detect_sql_injection (detectSqlInjection ,
85+ cQuery , queryLen ,
86+ cUserInput , userInputLen ,
87+ C .int (dialect )))
88+
8089 log .Debugf ("DetectSqlInjection(%s, %s, %d) -> %d" , query , user_input , dialect , result )
8190 return result
8291}
0 commit comments