aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_ups.c
diff options
context:
space:
mode:
authorGravatar PhiBo <phibo@dinotools.org> 2021-11-24 11:23:47 +0100
committerGravatar PhiBo <phibo@dinotools.org> 2021-11-24 11:23:47 +0100
commit09bfb1b482f428b1c11f68b5be7d134ba5e3b457 (patch)
tree51fba2105e268dca60959d3cb404de84fefcb1d5 /plugins/check_ups.c
parentdf835cfde00334de219efc741e2ba7bf5f64f635 (diff)
downloadmonitoring-plugins-09bfb1b482f428b1c11f68b5be7d134ba5e3b457.tar.gz
Fix possible overflow in check_ups (Fixes: #1030)
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r--plugins/check_ups.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index e9e56a51..0de37a20 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -402,7 +402,10 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
/* create the command string to send to the UPS daemon */
/* Add LOGOUT to avoid read failure logs */
- sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname);
+ if (snprintf (send_buffer, sizeof(send_buffer), "GET VAR %s %s\nLOGOUT\n", ups_name, varname) >= sizeof(send_buffer)) {
+ printf("%s\n", _("UPS name to long for buffer"));
+ return ERROR;
+ }
/* send the command to the daemon and get a response back */
if (process_tcp_request