[monitoring-plugins] check_ssh: Put variable in the correct scope

Lorenz Kästle git at monitoring-plugins.org
Fri Aug 1 14:50:12 CEST 2025


 Module: monitoring-plugins
 Branch: master
 Commit: a69dff15222ad43c56f0142e20d97ee51c2e6697
 Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
   Date: Fri Aug  1 14:35:13 2025 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=a69dff15

check_ssh: Put variable in the correct scope

---

 plugins/check_ssh.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index af7089a7..b4a98cdf 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -255,12 +255,11 @@ int ssh_connect(mp_check *overall, char *haddr, int hport, char *desired_remote_
 			byte_offset = 0;
 
 			char *index = NULL;
-			size_t len = 0;
 			while ((index = strchr(output + byte_offset, '\n')) != NULL) {
 				/*Partition the buffer so that this line is a separate string,
 				 * by replacing the newline with NUL*/
 				output[(index - output)] = '\0';
-				len = strlen(output + byte_offset);
+				size_t len = strlen(output + byte_offset);
 
 				if ((len >= 4) && (strncmp(output + byte_offset, "SSH-", 4) == 0)) {
 					/*if the string starts with SSH-, this _should_ be a valid version control string*/



More information about the Commits mailing list