Ver código fonte

check_tcp.c - Validate sent data size

my_send() and send() do not validate the amount sent, but only return -1 or bytes sent. Since we are sending via a single send command, all of the send string should be sent in a single command and should be checked against the sent amount. We could also just check for -1, however that is less accurate as the server would never see the rest of the string and may have unexpected results if the entirety is not sent.

coverity 103712
Spenser Reinhardt 11 anos atrás
pai
commit
6f562246e2
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      plugins/check_tcp.c

+ 2 - 2
plugins/check_tcp.c

@@ -253,8 +253,8 @@ main (int argc, char **argv)
 	}
 #endif /* HAVE_SSL */
 
-	if (server_send != NULL) {		/* Something to send? */
-		my_send(server_send, strlen(server_send));
+	if (server_send != NULL &&  strlen(server_send) > my_send(server_send, strlen(server_send))) {		/* Something to send? and validate return*/
+		die(STATE_UNKNOWN, "%s - %s", _("No data sent to host"), strerror(errno));
 	}
 
 	if (delay > 0) {