فهرست منبع

Fix buffer_length calculation in nrpe.c

madlohe 6 سال پیش
والد
کامیت
6d2a1cbfc0
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      src/nrpe.c

+ 3 - 3
src/nrpe.c

@@ -1912,9 +1912,9 @@ void handle_connection(int sock)
 
 
 	} else {
 	} else {
 
 
-		pkt_size = (sizeof(v3_packet) - NRPE_V4_PACKET_SIZE_OFFSET) + strlen(send_buff);
+		pkt_size = (sizeof(v3_packet) - NRPE_V4_PACKET_SIZE_OFFSET) + strlen(send_buff) + 1;
 		if (packet_ver == NRPE_PACKET_VERSION_3) {
 		if (packet_ver == NRPE_PACKET_VERSION_3) {
-			pkt_size = (sizeof(v3_packet) - NRPE_V3_PACKET_SIZE_OFFSET) + strlen(send_buff);
+			pkt_size = (sizeof(v3_packet) - NRPE_V3_PACKET_SIZE_OFFSET) + strlen(send_buff) + 1;
 		}
 		}
 		v3_send_packet = calloc(1, pkt_size);
 		v3_send_packet = calloc(1, pkt_size);
 		send_pkt = (char *)v3_send_packet;
 		send_pkt = (char *)v3_send_packet;
@@ -1923,7 +1923,7 @@ void handle_connection(int sock)
 		v3_send_packet->packet_type = htons(RESPONSE_PACKET);
 		v3_send_packet->packet_type = htons(RESPONSE_PACKET);
 		v3_send_packet->result_code = htons(result);
 		v3_send_packet->result_code = htons(result);
 		v3_send_packet->alignment = 0;
 		v3_send_packet->alignment = 0;
-		v3_send_packet->buffer_length = htonl(strlen(send_buff));
+		v3_send_packet->buffer_length = htonl(strlen(send_buff) + 1);
 		strcpy(&v3_send_packet->buffer[0], send_buff);
 		strcpy(&v3_send_packet->buffer[0], send_buff);
 
 
 		/* calculate the crc 32 value of the packet */
 		/* calculate the crc 32 value of the packet */