NagiosEnterprises/nrpe

Use of uninitialized local variable in nrpe.c

hariwe opened this issue · 0 comments

Valgrind complains about the use of an uninitialized variable:

==9904== Conditional jump or move depends on uninitialised value(s)
==9904== at 0x409027: validate_request (nrpe.c:2751)
==9904== by 0x406EB3: handle_connection (nrpe.c:1777)
==9904== by 0x40668A: wait_for_connections (nrpe.c:1441)
==9904== by 0x4047FC: run_src (nrpe.c:642)
==9904== by 0x403CF5: main (nrpe.c:224)
==9904== Uninitialised value was created by a stack allocation
==9904== at 0x408FE6: validate_request (nrpe.c:2737)

This is the code in question:

int validate_request(v2_packet * v2pkt, v3_packet * v3pkt)
{
	u_int32_t	packet_crc32;
	u_int32_t	calculated_crc32;
	int32_t		pkt_size, buffer_size;
	char		*buff, *ptr;
	int			rc;
#ifdef ENABLE_COMMAND_ARGUMENTS
	int			x;
#endif

	/* check the crc 32 value */
	if (packet_ver >= NRPE_PACKET_VERSION_3) {

		buffer_size = ntohl(v3pkt->buffer_length);
		if (buffer_size < 0 || buffer_size > INT_MAX - pkt_size) {

As you can see, local variable pkt_size is used in the if-block without being initialized.