Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
228 commits
Select commit Hold shift + click to select a range
3af23bb
security: harden strcpy hotspots in query/session paths
renecannao Aug 10, 2026
e645ccd
security: cache subnet list lengths before memcpy
renecannao Aug 10, 2026
caf270b
security: replace strlen usage with internal bounded length helper
renecannao Aug 10, 2026
c66f0d3
security: use local tokenizer length helper instead of strlen
renecannao Aug 10, 2026
d5900a5
Cache string lengths in MySQLFFTO digest hashing
renecannao Aug 10, 2026
6009c11
Cache string lengths in PgSQLFFTO digest hashing
renecannao Aug 10, 2026
f35ddcb
Cache cleartext length before zeroing passthrough buffer
renecannao Aug 10, 2026
ba87e06
Cache string lengths in auth-sensitive MySQL protocol helpers
renecannao Aug 10, 2026
927abd9
Cache default schema and cleartext lengths in auth flow cleanup
renecannao Aug 10, 2026
500dab5
Avoid repeated strlen in Admin passthrough auth flush parsing
renecannao Aug 10, 2026
05f106f
Cache string lengths in ProxySQL config query builders
renecannao Aug 10, 2026
3dd6539
Avoid duplicate prefix strlen in admin purge command parsing
renecannao Aug 10, 2026
e6fa77e
Make MySQL FFTO query digest hashing string-safe
renecannao Aug 10, 2026
6f344f2
Make PgSQL FFTO query digest hashing string-safe
renecannao Aug 10, 2026
f14af9f
Guard null cleartext/password pointers in auth flows
renecannao Aug 10, 2026
ddca219
Avoid null pointer lengths and preserve schema fallback behavior
renecannao Aug 10, 2026
a9a589e
Guard passthrough cleartext scrub length before memset
renecannao Aug 10, 2026
ae8d550
Make ProxySQL config escaped-comment SQL builders null-safe
renecannao Aug 10, 2026
22b4a00
Cache repeated strlen inputs in admin command parse and handshake
renecannao Aug 10, 2026
ecbc89c
Replace repeated command-literal strlen checks in admin handler
renecannao Aug 10, 2026
825afec
Cache quoted table name length in Admin_Handler table parser
renecannao Aug 10, 2026
2a69ab8
ProxySQL_Config: guard null escaped SQL literals before strlen/build
renecannao Aug 10, 2026
948e72f
MySQL_Protocol: cache auth password length to avoid repeated strlen
renecannao Aug 10, 2026
3e5ea61
SQLite3_Server: avoid strlen(query) after allocating query strings
renecannao Aug 10, 2026
7cdb83f
proxysql_utils: cache field-name pointer before strlen operations
renecannao Aug 10, 2026
38db9b9
MySQL_Protocol: guard null password before caching_sha2 password leng…
renecannao Aug 10, 2026
2b20be4
Harden ProxySQL_Config query length calculations
renecannao Aug 10, 2026
097c45f
Replace MySQLFFTO digest length calls with string_view sizing
renecannao Aug 10, 2026
cd8e84b
Replace PgSQLFFTO digest length calls with string_view sizing
renecannao Aug 10, 2026
7e3e3e5
Harden global-variable prefix checks by replacing repeated strlen in …
renecannao Aug 10, 2026
c15bccd
Refactor MySQL auth/password paths to cache string lengths once (S5813)
renecannao Aug 10, 2026
2f1daf4
Avoid duplicate strlen calls in MySQL session password/schemaname han…
renecannao Aug 10, 2026
fdd1855
Use string_view for passthrough_cleartext scrub length calculation
renecannao Aug 10, 2026
a722eae
Fix schemaname assignment in MySQL session while preserving cached le…
renecannao Aug 10, 2026
a2f7ac3
Cache integer/string sizes when building ProxySQL config SQL lengths
renecannao Aug 10, 2026
0fa2b39
Fix leftover size lookup in pgsql query rules S5813
renecannao Aug 10, 2026
50f0ec2
Cache cluster query comparison lengths in admin handler
renecannao Aug 10, 2026
e0a6a61
fix: S5813 SQLite3 quoted table name copy uses memcpy with explicit t…
renecannao Aug 10, 2026
9f25143
fix: S5813 normalize realpath copy in main using bounded snprintf
renecannao Aug 10, 2026
ee26a7a
fix: S5813 bound GTID record and UUID message extraction
renecannao Aug 10, 2026
1873849
fix: S5813 sanitize admin handler string parsing copies
renecannao Aug 10, 2026
0fb14dd
fix: S5813 avoid unbounded copy in MySQL query truncation path
renecannao Aug 10, 2026
45b75c7
fix: S5813 replace strcpy-equivalent user/password assignment with bo…
renecannao Aug 10, 2026
32bc872
fix: S5813 bound unix socket path copy for listen_on_unix
renecannao Aug 10, 2026
69e7d15
fix: S5813 make SQLSTATE copy length-safe in error helper
renecannao Aug 10, 2026
a36a77b
fix: S5813 avoid unsafe query copy in PostgreSQL session getter
renecannao Aug 10, 2026
9e11d9b
fix: S5813 bound proxy address copy from PROXY protocol parsing
renecannao Aug 10, 2026
30ae2b3
fix: S5813 make SQLSTATE copy in hostgroup stats length-safe
renecannao Aug 10, 2026
1a6dda1
fix: S5813 avoid redundant strlen on SQLite field names
renecannao Aug 10, 2026
62e99f5
chore: replace repeated strlen in SQLite SHOW/SELECT hot paths
renecannao Aug 10, 2026
0eeb652
SQLite3: cache lengths and quoted table name handling for S5813
renecannao Aug 10, 2026
a1654ac
ProxySQL_Config: cache query template lengths before malloc sizing
renecannao Aug 10, 2026
a3703ab
MySQL_Protocol: cache table-name length in COM_FIELD_LIST query synth…
renecannao Aug 10, 2026
d3000e2
Admin_Handler: harden S5813 hotspots in purge and flush handlers
renecannao Aug 10, 2026
f1d5ebf
Avoid repeated strlen on NULL-checked strings in config SQL builders
renecannao Aug 10, 2026
4834079
Use compile-time length for column statistics compatibility string check
renecannao Aug 10, 2026
4e56bb8
Use sizeof(spiffe://) for SPIFFE URI prefix compare
renecannao Aug 10, 2026
644c0f9
Cache fixed SQL keyword lengths in MySQL session command parsing
renecannao Aug 10, 2026
907901d
Replace dynamic strlen for test SQL templates with fixed-size constants
renecannao Aug 10, 2026
ca36350
security: use bounded token copy in Admin iface parsing
renecannao Aug 10, 2026
236505b
security: avoid null-terminator memcpy in ClickHouse iface copy
renecannao Aug 10, 2026
7eae654
security: make SQLite iface token copy explicit null-terminated
renecannao Aug 10, 2026
4284bfa
security: explicit null termination in TAP SQLite iface tokens
renecannao Aug 10, 2026
5b29b25
security: avoid oversized tokenizer copy by explicit length+terminator
renecannao Aug 10, 2026
dc879a2
security: split fixed-buffer string copies into length + terminator i…
renecannao Aug 10, 2026
c546d5e
security: make subnet list duplication null-terminate explicitly
renecannao Aug 10, 2026
f585009
security: set UTF8 prefix copy with explicit terminator
renecannao Aug 10, 2026
561b382
security: copy GenAI discovery DB path with explicit terminator
renecannao Aug 10, 2026
8a9b28c
security: copy GenAI catalog DB path with explicit terminator
renecannao Aug 10, 2026
aa9d3a4
security: copy GenAI FTS DB path with explicit terminator
renecannao Aug 10, 2026
d59032b
security: add bounded copy checks in MySQL connection hash input build
renecannao Aug 10, 2026
6836223
security: add bounds checks in PostgreSQL connection hash composition
renecannao Aug 10, 2026
33d35b1
security: add bounds checks in prepared-statement hash concat
renecannao Aug 10, 2026
bd99b2d
security: make test username/schema copies explicit lengths
renecannao Aug 10, 2026
bd0f874
security: use bounded test username/schema buffer initialization
renecannao Aug 10, 2026
1116573
security: bound-check byte-hex conversion in PostgreSQL protocol payload
renecannao Aug 10, 2026
d4406ef
security: add capacity checks in PostgreSQL startup parameter encoding
renecannao Aug 10, 2026
2f9712f
security: null-terminate SQLite query buffers after bounded memcpy
renecannao Aug 10, 2026
56b192b
security: avoid unsafe mysql_hdr memcpy in session rewrite
renecannao Aug 10, 2026
1af8790
security: rewrite postgres memory-size unit handling without mutable …
renecannao Aug 10, 2026
7af2a64
security: bound-check checksum string copy in cluster sync state
renecannao Aug 10, 2026
9bbe019
security: guard interface token duplication against allocation failure
renecannao Aug 10, 2026
abdf261
security: use strdup for clickhouse iface tokens
renecannao Aug 10, 2026
c2d1922
security: use strdup for SQLite iface token duplication
renecannao Aug 10, 2026
10988d9
security: use strdup for TAP SQLite iface token copies
renecannao Aug 10, 2026
ac607b3
security: make digest test username/schema seed copies explicit size-…
renecannao Aug 10, 2026
e8526c9
security: make fast-routing test prefix copies explicit and bounded
renecannao Aug 10, 2026
af4d121
qp: make query digest user/schema/address copies safe
renecannao Aug 10, 2026
afefded
mysql_connection: build hash input with std::string
renecannao Aug 10, 2026
ad3548f
debug: prevent unbounded backtrace buffer concatenation
renecannao Aug 10, 2026
8e685f0
proxySQL_cluster: use bounded checksum string copy
renecannao Aug 10, 2026
8f4b145
mysql_prepared_statement: build hash input with std::string
renecannao Aug 10, 2026
6cf54f7
pgsql_connection: use std::string for hash assembly
renecannao Aug 10, 2026
3f243ba
c_tokenizer: bound local buffer token copy with snprintf
renecannao Aug 10, 2026
00fd9e4
pgsql_variable_validate_search_path: build normalized path with std::…
renecannao Aug 10, 2026
a7d83ba
proxy_protocol_info: use std::string for subnet list token buffers
renecannao Aug 10, 2026
172cb73
proxysql_find_charset: build utf8 collation prefix with snprintf
renecannao Aug 10, 2026
f7770f3
discovery_schema: avoid memcpy for db path setup
renecannao Aug 10, 2026
6a4686a
mysql_catalog: remove manual memcpy when opening catalog db
renecannao Aug 10, 2026
8fc0611
mysql_fts: remove manual path memcpy before DB open
renecannao Aug 10, 2026
e5f1263
pgsql_protocol: replace temporary query-type stack buffers with std::…
renecannao Aug 10, 2026
0722d15
pgsql_connection_params_test: remove memcpy hot spots
renecannao Aug 10, 2026
987182b
Fix S5801 unsafe copies in MySQL_Session
renecannao Aug 10, 2026
ab034f2
Fix S5801 unsafe path copy in AI_Features_Manager
renecannao Aug 10, 2026
437f91c
Fix S5801 hotspot in ProxySQL_Config RDS BGD path formatting
renecannao Aug 10, 2026
77691b7
Replace unsafe strnlen in MySQLFFTO query digest path
renecannao Aug 10, 2026
1b633e1
Replace unsafe strnlen in PgSQLFFTO query digest path
renecannao Aug 10, 2026
a2147fe
Replace strnlen in MySQL_Protocol packet field parsing
renecannao Aug 10, 2026
eeb6d60
ProxySQL_Config: replace strlen helper implementation for S5813 cleanup
renecannao Aug 10, 2026
076f459
PgSQLFFTO: replace bounded strnlen parsing with explicit search helper
renecannao Aug 10, 2026
1607bd7
Admin_Handler: cache INFORMATION_SCHEMA prefix lengths for query matc…
renecannao Aug 10, 2026
9705b34
MySQL_Protocol: cache auth plugin and db lengths for strlen safety
renecannao Aug 10, 2026
309d280
MySQL_Session: reuse cached string lengths in S5801 hotspots
renecannao Aug 10, 2026
c6a77a6
MySQL_Query_Processor: replace strncpy with memcpy for min_gtid copy
renecannao Aug 10, 2026
3a35222
ProxySQL global vars: copy checksum using memcpy
renecannao Aug 10, 2026
36c7636
Use string_view lengths in FFTO state-machine test helpers
renecannao Aug 10, 2026
2c17b21
Replace C-string strlen uses in parser SQL unit test inputs
renecannao Aug 10, 2026
9981293
bench_connect: copy conninfo with bounded snprintf
renecannao Aug 10, 2026
a296a77
reg_test_1288: safely copy pgsql max_connections value
renecannao Aug 10, 2026
1007707
aurora: avoid repeated strlen in quoted table parsing
renecannao Aug 10, 2026
c0b458c
pgsql copy test: bound numeric buffer copies
renecannao Aug 10, 2026
14953f9
test_cluster_sync: use bounded host copy fallback for hostname buffer
renecannao Aug 10, 2026
6d59412
stmt error test: bound parameter copy and length assignment
renecannao Aug 10, 2026
f2b8222
cluster sync mysql servers: fallback host copy with snprintf
renecannao Aug 10, 2026
e6c43ee
test: replace unsafe strcat usage in pgsql copy-from test
renecannao Aug 10, 2026
6d623a0
src: bound-format TLS path construction
renecannao Aug 10, 2026
e2d4839
src: replace unbounded sprintf in main path formatting
renecannao Aug 10, 2026
3d3f438
genai: replace unbounded MCP variable copy with bounded snprintf
renecannao Aug 10, 2026
fbf661c
sqlite: replace unsafe sprintf calls with bounded snprintf
renecannao Aug 10, 2026
37e2754
tools: bound eventslog sample formatting buffers
renecannao Aug 10, 2026
a51612a
core: make itostr integer-to-string conversion bounded
renecannao Aug 10, 2026
bd2d7be
tests: bound-format aurora sqlite3 query builders
renecannao Aug 10, 2026
90f9519
tests: bound tap time formatter outputs
renecannao Aug 10, 2026
2defe3a
tests: bound admin SHOW FIELDS query formatting
renecannao Aug 10, 2026
f5c18e0
tests: bound admin SHOW TABLE STATUS query formatting
renecannao Aug 10, 2026
50a54d5
tests: bound create-table statement formatting
renecannao Aug 10, 2026
11aa3bb
tests: bound read-only session SQL formatting
renecannao Aug 10, 2026
c8226a9
tests: bound-select query in set_testing thread worker
renecannao Aug 10, 2026
4b551a0
tests: bound-select query in set_testing-multi worker
renecannao Aug 10, 2026
45a727f
tests: bound-select query in set_testing-240 worker
renecannao Aug 10, 2026
c598092
tests: bound galera 1 timeout query formatting
renecannao Aug 10, 2026
f098e07
tests: bound galera 2 timeout query formatting
renecannao Aug 10, 2026
a4f1b3a
PrepStmt: replace sprintf with snprintf in client2 query formatting
renecannao Aug 10, 2026
6401c8c
PrepStmt: use snprintf for client3 query strings
renecannao Aug 10, 2026
2b72dd6
PrepStmt: replace sprintf with bounded snprintf in client4
renecannao Aug 10, 2026
66d19b6
PrepStmt: switch client5 random-query builders to snprintf
renecannao Aug 10, 2026
50fa138
PrepStmt: guard active client6 SQL formatting with snprintf
renecannao Aug 10, 2026
df2e21f
PrepStmt: replace active sprintf formatting in client7
renecannao Aug 10, 2026
12569f9
PrepStmt: use snprintf for query formatting in client9
renecannao Aug 10, 2026
107a6b3
PrepStmt: make client10 SQL format bounded and length-safe
renecannao Aug 10, 2026
a29b2b4
PrepStmt: finish remaining sprintf replacement in client2
renecannao Aug 10, 2026
8f9382f
PrepStmt: finish remaining sprintf replacement in client4
renecannao Aug 10, 2026
b8ca216
Tap test: replace sprintf in mysql-reg_test_4867 query rules
renecannao Aug 10, 2026
bd39144
Tap test: replace sprintf in pgsql-reg_test_4867 query rules
renecannao Aug 10, 2026
e9f9652
Tap test: bound snprintf in reg_test_3585 metadata checks
renecannao Aug 10, 2026
00a4dc3
Tap test: replace sprintf in reg_test_3603 metadata checks
renecannao Aug 10, 2026
426e494
Tap test: bound dummy-query formatting in reg_test_4399
renecannao Aug 10, 2026
4e4c7b3
Tap test: bound snprintf in pgsql copy-to insert generator
renecannao Aug 10, 2026
38b3008
Merge remote-tracking branch origin/v3.0
renecannao Aug 10, 2026
f61fa5a
test: cover short checksum source handling
renecannao Aug 10, 2026
dd16de0
fix: bound checksum copies by source length
renecannao Aug 10, 2026
1c07f93
fix: preserve MySQL digest length limits
renecannao Aug 10, 2026
08da7fb
fix: preserve PostgreSQL digest length limits
renecannao Aug 10, 2026
f1eb149
fix: use checksum buffer capacity for cluster updates
renecannao Aug 10, 2026
da855f6
fix: bound PostgreSQL command tag formatting
renecannao Aug 10, 2026
0b16151
fix: size configuration queries for all values
renecannao Aug 10, 2026
818ca49
fix: handle SQLite test server allocation failures
renecannao Aug 10, 2026
0173c41
fix: preserve admin interfaces on copy failure
renecannao Aug 10, 2026
f23a625
fix: release test server interface locks on failure
renecannao Aug 10, 2026
19f9292
fix: preserve ClickHouse interfaces on allocation failure
renecannao Aug 10, 2026
feac1d5
fix: handle min GTID allocation failure
renecannao Aug 10, 2026
71fc810
fix: reject oversized Unix socket paths
renecannao Aug 10, 2026
8ffd93c
fix: free demangled debug symbols
renecannao Aug 10, 2026
783006c
fix: reject truncated GTID records and UUIDs
renecannao Aug 10, 2026
c56b189
fix: normalize peer checksum fields before comparison
renecannao Aug 10, 2026
377edfa
api: add capacity to MCP variable reads
renecannao Aug 10, 2026
5528ead
fix: bound MCP variable output formatting
renecannao Aug 10, 2026
1a8b67b
fix: pass MCP output buffer capacities
renecannao Aug 10, 2026
09d7a54
fix: handle TLS path allocation failures
renecannao Aug 10, 2026
5b80cd2
fix: validate client2 statement allocation
renecannao Aug 10, 2026
2f85f53
fix: validate client9 query allocation
renecannao Aug 10, 2026
9c98b1f
fix: validate benchmark thread allocations
renecannao Aug 10, 2026
7ea1331
fix: match client3 query format types
renecannao Aug 10, 2026
8ea6d66
fix: match client4 query format types
renecannao Aug 10, 2026
9f9c6f9
fix: match digest test format types
renecannao Aug 10, 2026
e596031
fix: match MYSQL_TIME format specifiers
renecannao Aug 10, 2026
2682a95
fix: match second metadata time types
renecannao Aug 10, 2026
1ab158e
fix: use unsigned duration formatting
renecannao Aug 10, 2026
3715865
fix: validate PostgreSQL startup message boundaries
renecannao Aug 10, 2026
07b7a66
fix: reject oversized numeric COPY values
renecannao Aug 10, 2026
a5522b4
fix: reject truncated set-testing queries
renecannao Aug 10, 2026
c087731
fix: detect truncated queries in set testing
renecannao Aug 10, 2026
fb0efeb
style: rename PostgreSQL hash delimiter macros
renecannao Aug 10, 2026
eb8cb90
refactor: manage admin field query buffers
renecannao Aug 10, 2026
271ea23
refactor: manage table status query buffers
renecannao Aug 10, 2026
43735c9
refactor: manage Aurora temporary query buffers
renecannao Aug 10, 2026
ceb6589
test: pass capacities to MCP variable reads
renecannao Aug 10, 2026
b5d246b
fix: validate Unix socket paths before unlink
renecannao Aug 10, 2026
fc6b6a3
fix: report truncated MCP variable reads
renecannao Aug 10, 2026
c42edf1
docs: describe bounded MCP variable read failures
renecannao Aug 10, 2026
a05d757
fix: avoid truncating MCP config values
renecannao Aug 10, 2026
f8e8e69
test: cover bounded MCP variable reads
renecannao Aug 10, 2026
b5648b6
fix: reject oversized bootstrap UUIDs
renecannao Aug 10, 2026
6218c05
refactor: make admin interface replacement exception-safe
renecannao Aug 10, 2026
43318e3
refactor: make ClickHouse interface replacement exception-safe
renecannao Aug 10, 2026
53f3474
test: build table status queries without C formatting
renecannao Aug 10, 2026
631a9c6
test: build field-list queries without C formatting
renecannao Aug 10, 2026
12f5e89
test: construct Aurora SQL with std::string
renecannao Aug 10, 2026
4a6744d
refactor: use constexpr PostgreSQL hash delimiters
renecannao Aug 10, 2026
9f6e637
refactor: isolate binary COPY field encoding
renecannao Aug 10, 2026
005781a
fix: avoid freeing tokenizer stack storage
renecannao Aug 10, 2026
b2ae7ec
fix: bound config query formatting
renecannao Aug 10, 2026
31f3dc8
fix: use bounded randomness in Aurora test output
renecannao Aug 10, 2026
cf551a2
fix: replace test replication rand calls
renecannao Aug 10, 2026
d6794ac
fix: bound overlong socket path logs
renecannao Aug 10, 2026
5b8adc5
fix: encode PostgreSQL binary COPY fields
renecannao Aug 10, 2026
77c0af3
fix: bound PostgreSQL user query formatting
renecannao Aug 10, 2026
1c50987
fix: keep Sonar cleanup allocations ownership-safe
renecannao Aug 10, 2026
013762f
fix: make generated SQL formatting bounded
renecannao Aug 10, 2026
cf890e2
fix: reduce parser and string-analysis complexity
renecannao Aug 10, 2026
166705c
fix: clear remaining Sonar parser and test findings
renecannao Aug 10, 2026
79600e2
fix: remove final Sonar configuration and test findings
renecannao Aug 10, 2026
cc0f10a
fix: restore test-mode scope and allocator pairing
renecannao Aug 11, 2026
792e675
fix: avoid malloc in query rules test escaping
renecannao Aug 11, 2026
7d7b365
fix: isolate replication lag table initialization
renecannao Aug 11, 2026
d530809
docs: explain demangler allocator exception
renecannao Aug 11, 2026
307bac2
ci: retrigger full PR validation
renecannao Aug 11, 2026
af250ba
fix(pgsql): restore connection identity hash updates
renecannao Aug 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 67 additions & 11 deletions include/Admin_ifaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,49 @@ class ifaces_desc {

class admin_main_loop_listeners {
private:
struct tokenizer_owner {
tokenizer_t value;

explicit tokenizer_owner(char *list) {
tokenizer(&value, list, ";", TOKENIZER_NO_EMPTIES);
}

~tokenizer_owner() {
free_tokenizer(&value);
}

tokenizer_owner(const tokenizer_owner&) = delete;
tokenizer_owner& operator=(const tokenizer_owner&) = delete;
tokenizer_owner(tokenizer_owner&&) = delete;
tokenizer_owner& operator=(tokenizer_owner&&) = delete;
};

struct interface_array_owner {
char **value;

explicit interface_array_owner(char **value_) : value(value_) {}

~interface_array_owner() {
if (value) {
for (int i = 0; i < MAX_IFACES; ++i) {
l_free(0, value[i]);
}
l_free(0, value);
}
}

interface_array_owner(const interface_array_owner&) = delete;
interface_array_owner& operator=(const interface_array_owner&) = delete;
interface_array_owner(interface_array_owner&&) = delete;
interface_array_owner& operator=(interface_array_owner&&) = delete;

char **release() {
char **released = value;
value = nullptr;
return released;
}
};

int version;
#ifdef PA_PTHREAD_MUTEX
pthread_rwlock_t rwlock;
Expand Down Expand Up @@ -129,19 +172,32 @@ class admin_main_loop_listeners {

bool update_ifaces(char *list, char ***_ifaces) {
wrlock();
int i;
char **ifaces=*_ifaces;
tokenizer_t tok;
tokenizer( &tok, list, ";", TOKENIZER_NO_EMPTIES );
const char* token;
ifaces=reset_ifaces(ifaces);
i=0;
for ( token = tokenize( &tok ) ; token && i < MAX_IFACES ; token = tokenize( &tok ) ) {
ifaces[i]=(char *)malloc(strlen(token)+1);
strcpy(ifaces[i],token);
char **old_ifaces = *_ifaces;
char **new_ifaces = (char **)l_alloc(MAX_IFACES * sizeof(char *));
if (new_ifaces != nullptr) {
memset(new_ifaces, 0, MAX_IFACES * sizeof(char *));
}
interface_array_owner replacement(new_ifaces);
if (replacement.value == nullptr) {
wrunlock();
return false;
}

tokenizer_owner tokens(list);
int i = 0;
for (const char *token = tokenize(&tokens.value);
token && i < MAX_IFACES;
token = tokenize(&tokens.value)) {
replacement.value[i] = strdup(token);
if (replacement.value[i] == nullptr) {
wrunlock();
return false;
}
i++;
}
free_tokenizer( &tok );

interface_array_owner previous(old_ifaces);
*_ifaces = replacement.release();
version++;
wrunlock();
return true;
Expand Down
42 changes: 23 additions & 19 deletions include/MySQL_Query_Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MySQL_Query_Processor : public Query_Processor<MySQL_Query_Processor> {

private:
Command_Counter* commands_counters[MYSQL_COM_QUERY___NONE];
static bool _is_valid_gtid(char* gtid, size_t gtid_len);
static bool _is_valid_gtid(const char* gtid, size_t gtid_len);
static MySQL_Query_Processor_Rule_t* new_query_rule(const MySQL_Query_Processor_Rule_t* mqr);

inline
Expand All @@ -74,25 +74,29 @@ class MySQL_Query_Processor : public Query_Processor<MySQL_Query_Processor> {

inline
void query_parser_first_comment_extended(const char* key, const char* value, MySQL_Query_Processor_Output* qpo) {
if (!strcasecmp(key, "min_gtid")) {
if (mysql_thread___ignore_min_gtid_annotations) {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 5, "Ignoring min_gtid=%s\n", value);
} else {
size_t l = strlen(value);
if (_is_valid_gtid((char*)value, l)) {
char* buf = (char*)malloc(l + 1);
strncpy(buf, value, l);
buf[l] = '\0';

if (qpo->min_gtid) {
free(qpo->min_gtid);
}
qpo->min_gtid = buf;
} else {
proxy_warning("Invalid min_gtid value=%s\n", value);
}
}
if (strcasecmp(key, "min_gtid")) {
return;
}
if (mysql_thread___ignore_min_gtid_annotations) {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 5, "Ignoring min_gtid=%s\n", value);
return;
}
size_t l = strlen(value);
if (!_is_valid_gtid(value, l)) {
proxy_warning("Invalid min_gtid value=%s\n", value);
return;
}
char* buf = (char*)l_alloc(l + 1);
if (buf == nullptr) {
proxy_warning("Unable to allocate memory for min_gtid=%s\n", value);
return;
}
memcpy(buf, value, l);
buf[l] = '\0';
if (qpo->min_gtid) {
l_free(0, qpo->min_gtid);
}
qpo->min_gtid = buf;
}

friend class Query_Processor;
Expand Down
7 changes: 5 additions & 2 deletions include/proxysql_glovars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ class ProxySQL_Checksum_Value {
epoch = 0;
in_shutdown = false;
}
void set_checksum(char *c) {
void set_checksum(const char *c) {
memset(checksum,0,ProxySQL_Checksum_Value_LENGTH);
strncpy(checksum,c,ProxySQL_Checksum_Value_LENGTH);
if (c) {
const size_t length = strnlen(c, ProxySQL_Checksum_Value_LENGTH);
memcpy(checksum, c, length);
}
replace_checksum_zeros(checksum);
}
~ProxySQL_Checksum_Value() {
Expand Down
2 changes: 1 addition & 1 deletion include/proxysql_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define char_malloc (char *)malloc
#define free_null(__c) { if(__c) { free(__c); (__c)=NULL; } }

#define itostr(__s, __i) { (__s)=char_malloc(32); sprintf(__s, "%lld", (__i)); }
#define itostr(__s, __i) { (__s)=char_malloc(32); snprintf((__s), 32, "%lld", (__i)); }

// fast memory copy forward . Use this instead of memcpy for small buffers
#define MEM_COPY_FWD(dst_p, src_p, bytes) \
Expand Down
Loading
Loading