mirror of
https://github.com/Cacti/spine.git
synced 2026-12-04 14:22:26 +09:00
fix(runtime): [1.2.x] backport worker stacks SNMP locking and input boundaries (#662)
Backport the applicable runtime bugs from develop #644, #646 and #660. Raise small platform worker stacks while preserving larger defaults and rejecting overflowing buffer configurations. Serialize SNMP session construction, cleanup and every SNMPv3 request process-wide while v1 and v2c requests stay parallel. Net-SNMP's README.thread says SNMPv3 support was never checked for multi-threading correctness. One unresponsive v3 agent now delays other v3 polls by up to timeout x (retries + 1); narrowing the lock needs the asynchronous API and is a develop-only follow-up. Reject unavailable PHP reader slots and invalid host/thread CLI numbers before indexing or sizing state. Consume overlong config lines once, parse final lines without a newline, and keep config values out of warnings. Merge after #661. This keeps the flat maintenance sources and existing runtime interfaces; no new dependencies or CI gates. Release notes will be collected in the final maintenance PR. Validation: native build and version smoke test pass through mise. ASan/UBSan contracts exercise worker-stack defaults and errors, active-session SNMP locking, and physical config-line boundaries. A probe linked to the maintenance production objects passes five script-output boundaries and three unavailable PHP slot cases. Seven invalid numeric CLI invocations fail before config/database access. The critical flawfinder gate passes. No live database or device was contacted. --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This commit is contained in:
1 parent
78f6670597
commit
df528b0fd2
4 files changed
+195
-33
No files matched your search
@@ -131,6 +131,20 @@ static void php_set_state(int php_process, int state) {
|
||||
thread_mutex_unlock(LOCK_PHP);
|
||||
}
|
||||
|
||||
/* Returns an undefined ("U") result for a slot that cannot be addressed, or
|
||||
* NULL when php_process names a usable script server slot. */
|
||||
static char *php_unavailable_slot(int php_process) {
|
||||
char *unavailable;
|
||||
|
||||
if (php_processes != NULL && set.php_servers >= 0 && set.php_servers <= MAX_PHP_SERVERS &&
|
||||
php_process >= 0 && php_process < set.php_servers) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STRDUP_OR_DIE(unavailable, "U", "PHP unavailable slot");
|
||||
return unavailable;
|
||||
}
|
||||
|
||||
/*! \fn char *php_cmd(const char *php_command, int php_process)
|
||||
* \brief calls the script server and executes a script command
|
||||
* \param php_command the formatted php script server command
|
||||
@@ -151,6 +165,11 @@ char *php_cmd(const char *php_command, int php_process) {
|
||||
int write_fd;
|
||||
int retries = 0;
|
||||
|
||||
|
||||
if ((result_string = php_unavailable_slot(php_process)) != NULL) {
|
||||
return result_string;
|
||||
}
|
||||
|
||||
assert(php_command != 0);
|
||||
|
||||
/* pad command with CR-LF */
|
||||
@@ -308,6 +327,10 @@ static char *php_readpipe_until(int php_process, char *command, double deadline)
|
||||
char *cp;
|
||||
char *bptr;
|
||||
|
||||
if ((result_string = php_unavailable_slot(php_process)) != NULL) {
|
||||
return result_string;
|
||||
}
|
||||
|
||||
if (!(result_string = (char *)malloc(RESULTS_BUFFER))) {
|
||||
die("ERROR: Fatal malloc error: php.c php_readpipe!");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user