瀏覽代碼

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 年之前
父節點
當前提交
6f562246e2
共有 1 個文件被更改,包括 2 次插入2 次删除
  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) {