crypto/bio/bss_dgram.c:427: error: UNINITIALIZED_VALUE
  The value read from addr.ss_family was never initialized.
Showing all 1 steps of the trace


crypto/bio/bss_dgram.c:427:3: 
425.   				perror("setsockopt");
426.   			break;
427. > 		case AF_INET6:
428.   			sockopt_val = IPV6_PMTUDISC_DO;
429.   			if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,

static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
	{
	long ret=1;
	int *ip;
	struct sockaddr *to = NULL;
	bio_dgram_data *data = NULL;
#if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
	long sockopt_val = 0;
	unsigned int sockopt_len = 0;
#endif
#ifdef OPENSSL_SYS_LINUX
	socklen_t addr_len;
	struct sockaddr_storage addr;
#endif
	data = (bio_dgram_data *)b->ptr;
	switch (cmd)
		{
	case BIO_CTRL_RESET:
		num=0;
	case BIO_C_FILE_SEEK:
		ret=0;
		break;
	case BIO_C_FILE_TELL:
	case BIO_CTRL_INFO:
		ret=0;
		break;
	case BIO_C_SET_FD:
		dgram_clear(b);
		b->num= *((int *)ptr);
		b->shutdown=(int)num;
		b->init=1;
		break;
	case BIO_C_GET_FD:
		if (b->init)
			{
			ip=(int *)ptr;
			if (ip != NULL) *ip=b->num;
			ret=b->num;
			}
		else
			ret= -1;
		break;
	case BIO_CTRL_GET_CLOSE:
		ret=b->shutdown;
		break;
	case BIO_CTRL_SET_CLOSE:
		b->shutdown=(int)num;
		break;
	case BIO_CTRL_PENDING:
	case BIO_CTRL_WPENDING:
		ret=0;
		break;
	case BIO_CTRL_DUP:
	case BIO_CTRL_FLUSH:
		ret=1;
		break;
	case BIO_CTRL_DGRAM_CONNECT:
		to = (struct sockaddr *)ptr;
#if 0
		if (connect(b->num, to, sizeof(struct sockaddr)) < 0)
			{ perror("connect"); ret = 0; }
		else
			{
#endif
			memcpy(&(data->peer),to, sizeof(struct sockaddr));
#if 0
			}
#endif
		break;
	case BIO_CTRL_DGRAM_MTU_DISCOVER:
#ifdef OPENSSL_SYS_LINUX
		addr_len = (socklen_t)sizeof(struct sockaddr_storage);
		memset((void *)&addr, 0, sizeof(struct sockaddr_storage));
		if (getsockname(b->num, (void *)&addr, &addr_len) < 0)
			{
			ret = 0;
			break;
			}
		sockopt_len = sizeof(sockopt_val);
		switch (addr.ss_family)
			{
		case AF_INET:
			sockopt_val = IP_PMTUDISC_DO;
			if ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
				&sockopt_val, sizeof(sockopt_val))) < 0)
				perror("setsockopt");
			break;
		case AF_INET6:
			sockopt_val = IPV6_PMTUDISC_DO;
			if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
				&sockopt_val, sizeof(sockopt_val))) < 0)
				perror("setsockopt");
			break;
		default:
			ret = -1;
			break;
			}
		ret = -1;
#else
		break;
#endif
	case BIO_CTRL_DGRAM_QUERY_MTU:
#ifdef OPENSSL_SYS_LINUX
		addr_len = (socklen_t)sizeof(struct sockaddr_storage);
		memset((void *)&addr, 0, sizeof(struct sockaddr_storage));
		if (getsockname(b->num, (void *)&addr, &addr_len) < 0)
			{
			ret = 0;
			break;
			}
		sockopt_len = sizeof(sockopt_val);
		switch (addr.ss_family)
			{
		case AF_INET:
			if ((ret = getsockopt(b->num, IPPROTO_IP, IP_MTU, (void *)&sockopt_val,
				&sockopt_len)) < 0 || sockopt_val < 0)
				{
				ret = 0;
				}
			else
				{
				data->mtu = sockopt_val - 8 - 20;
				ret = data->mtu;
				}
			break;
		case AF_INET6:
			if ((ret = getsockopt(b->num, IPPROTO_IPV6, IPV6_MTU, (void *)&sockopt_val,
				&sockopt_len)) < 0 || sockopt_val < 0)
				{
				ret = 0;
				}
			else
				{
				data->mtu = sockopt_val - 8 - 40;
				ret = data->mtu;
				}
			break;
		default:
			ret = 0;
			break;
			}
#else
		ret = 0;
#endif
		break;
	case BIO_CTRL_DGRAM_GET_MTU:
		return data->mtu;
		break;
	case BIO_CTRL_DGRAM_SET_MTU:
		data->mtu = num;
		ret = num;
		break;
	case BIO_CTRL_DGRAM_SET_CONNECTED:
		to = (struct sockaddr *)ptr;
		if ( to != NULL)
			{
			data->connected = 1;
			memcpy(&(data->peer),to, sizeof(struct sockaddr));
			}
		else
			{
			data->connected = 0;
			memset(&(data->peer), 0x00, sizeof(struct sockaddr));
			}
		break;
    case BIO_CTRL_DGRAM_SET_PEER:
        to = (struct sockaddr *) ptr;
        memcpy(&(data->peer), to, sizeof(struct sockaddr));
        break;
	case BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT:
		memcpy(&(data->next_timeout), ptr, sizeof(struct timeval));
		break;
#if defined(SO_RCVTIMEO)
	case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT:
#ifdef OPENSSL_SYS_WINDOWS
		{
		struct timeval *tv = (struct timeval *)ptr;
		int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000;
		if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
			(void*)&timeout, sizeof(timeout)) < 0)
			{ perror("setsockopt"); ret = -1; }
		}
#else
		if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr,
			sizeof(struct timeval)) < 0)
			{ perror("setsockopt");	ret = -1; }
#endif
		break;
	case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
#ifdef OPENSSL_SYS_WINDOWS
		{
		int timeout, sz = sizeof(timeout);
		struct timeval *tv = (struct timeval *)ptr;
		if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
			(void*)&timeout, &sz) < 0)
			{ perror("getsockopt"); ret = -1; }
		else
			{
			tv->tv_sec = timeout / 1000;
			tv->tv_usec = (timeout % 1000) * 1000;
			ret = sizeof(*tv);
			}
		}
#else
		if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
			ptr, (void *)&ret) < 0)
			{ perror("getsockopt"); ret = -1; }
#endif
		break;
#endif
#if defined(SO_SNDTIMEO)
	case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT:
#ifdef OPENSSL_SYS_WINDOWS
		{
		struct timeval *tv = (struct timeval *)ptr;
		int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000;
		if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
			(void*)&timeout, sizeof(timeout)) < 0)
			{ perror("setsockopt"); ret = -1; }
		}
#else
		if ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr,
			sizeof(struct timeval)) < 0)
			{ perror("setsockopt");	ret = -1; }
#endif
		break;
	case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
#ifdef OPENSSL_SYS_WINDOWS
		{
		int timeout, sz = sizeof(timeout);
		struct timeval *tv = (struct timeval *)ptr;
		if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
			(void*)&timeout, &sz) < 0)
			{ perror("getsockopt"); ret = -1; }
		else
			{
			tv->tv_sec = timeout / 1000;
			tv->tv_usec = (timeout % 1000) * 1000;
			ret = sizeof(*tv);
			}
		}
#else
		if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
			ptr, (void *)&ret) < 0)
			{ perror("getsockopt"); ret = -1; }
#endif
		break;
#endif
	case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
	case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP:
#ifdef OPENSSL_SYS_WINDOWS
		if ( data->_errno == WSAETIMEDOUT)
#else
		if ( data->_errno == EAGAIN)
#endif
			{
			ret = 1;
			data->_errno = 0;
			}
		else
			ret = 0;
		break;
#ifdef EMSGSIZE
	case BIO_CTRL_DGRAM_MTU_EXCEEDED:
		if ( data->_errno == EMSGSIZE)
			{
			ret = 1;
			data->_errno = 0;
			}
		else
			ret = 0;
		break;
#endif
	default:
		ret=0;
		break;
		}
	return(ret);
	}
['static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)\n\t{\n\tlong ret=1;\n\tint *ip;\n\tstruct sockaddr *to = NULL;\n\tbio_dgram_data *data = NULL;\n#if defined(IP_MTU_DISCOVER) || defined(IP_MTU)\n\tlong sockopt_val = 0;\n\tunsigned int sockopt_len = 0;\n#endif\n#ifdef OPENSSL_SYS_LINUX\n\tsocklen_t addr_len;\n\tstruct sockaddr_storage addr;\n#endif\n\tdata = (bio_dgram_data *)b->ptr;\n\tswitch (cmd)\n\t\t{\n\tcase BIO_CTRL_RESET:\n\t\tnum=0;\n\tcase BIO_C_FILE_SEEK:\n\t\tret=0;\n\t\tbreak;\n\tcase BIO_C_FILE_TELL:\n\tcase BIO_CTRL_INFO:\n\t\tret=0;\n\t\tbreak;\n\tcase BIO_C_SET_FD:\n\t\tdgram_clear(b);\n\t\tb->num= *((int *)ptr);\n\t\tb->shutdown=(int)num;\n\t\tb->init=1;\n\t\tbreak;\n\tcase BIO_C_GET_FD:\n\t\tif (b->init)\n\t\t\t{\n\t\t\tip=(int *)ptr;\n\t\t\tif (ip != NULL) *ip=b->num;\n\t\t\tret=b->num;\n\t\t\t}\n\t\telse\n\t\t\tret= -1;\n\t\tbreak;\n\tcase BIO_CTRL_GET_CLOSE:\n\t\tret=b->shutdown;\n\t\tbreak;\n\tcase BIO_CTRL_SET_CLOSE:\n\t\tb->shutdown=(int)num;\n\t\tbreak;\n\tcase BIO_CTRL_PENDING:\n\tcase BIO_CTRL_WPENDING:\n\t\tret=0;\n\t\tbreak;\n\tcase BIO_CTRL_DUP:\n\tcase BIO_CTRL_FLUSH:\n\t\tret=1;\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_CONNECT:\n\t\tto = (struct sockaddr *)ptr;\n#if 0\n\t\tif (connect(b->num, to, sizeof(struct sockaddr)) < 0)\n\t\t\t{ perror("connect"); ret = 0; }\n\t\telse\n\t\t\t{\n#endif\n\t\t\tmemcpy(&(data->peer),to, sizeof(struct sockaddr));\n#if 0\n\t\t\t}\n#endif\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_MTU_DISCOVER:\n#ifdef OPENSSL_SYS_LINUX\n\t\taddr_len = (socklen_t)sizeof(struct sockaddr_storage);\n\t\tmemset((void *)&addr, 0, sizeof(struct sockaddr_storage));\n\t\tif (getsockname(b->num, (void *)&addr, &addr_len) < 0)\n\t\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t\t}\n\t\tsockopt_len = sizeof(sockopt_val);\n\t\tswitch (addr.ss_family)\n\t\t\t{\n\t\tcase AF_INET:\n\t\t\tsockopt_val = IP_PMTUDISC_DO;\n\t\t\tif ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,\n\t\t\t\t&sockopt_val, sizeof(sockopt_val))) < 0)\n\t\t\t\tperror("setsockopt");\n\t\t\tbreak;\n\t\tcase AF_INET6:\n\t\t\tsockopt_val = IPV6_PMTUDISC_DO;\n\t\t\tif ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,\n\t\t\t\t&sockopt_val, sizeof(sockopt_val))) < 0)\n\t\t\t\tperror("setsockopt");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tret = -1;\n\t\t\tbreak;\n\t\t\t}\n\t\tret = -1;\n#else\n\t\tbreak;\n#endif\n\tcase BIO_CTRL_DGRAM_QUERY_MTU:\n#ifdef OPENSSL_SYS_LINUX\n\t\taddr_len = (socklen_t)sizeof(struct sockaddr_storage);\n\t\tmemset((void *)&addr, 0, sizeof(struct sockaddr_storage));\n\t\tif (getsockname(b->num, (void *)&addr, &addr_len) < 0)\n\t\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t\t}\n\t\tsockopt_len = sizeof(sockopt_val);\n\t\tswitch (addr.ss_family)\n\t\t\t{\n\t\tcase AF_INET:\n\t\t\tif ((ret = getsockopt(b->num, IPPROTO_IP, IP_MTU, (void *)&sockopt_val,\n\t\t\t\t&sockopt_len)) < 0 || sockopt_val < 0)\n\t\t\t\t{\n\t\t\t\tret = 0;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tdata->mtu = sockopt_val - 8 - 20;\n\t\t\t\tret = data->mtu;\n\t\t\t\t}\n\t\t\tbreak;\n\t\tcase AF_INET6:\n\t\t\tif ((ret = getsockopt(b->num, IPPROTO_IPV6, IPV6_MTU, (void *)&sockopt_val,\n\t\t\t\t&sockopt_len)) < 0 || sockopt_val < 0)\n\t\t\t\t{\n\t\t\t\tret = 0;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tdata->mtu = sockopt_val - 8 - 40;\n\t\t\t\tret = data->mtu;\n\t\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t\t}\n#else\n\t\tret = 0;\n#endif\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_GET_MTU:\n\t\treturn data->mtu;\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_SET_MTU:\n\t\tdata->mtu = num;\n\t\tret = num;\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_SET_CONNECTED:\n\t\tto = (struct sockaddr *)ptr;\n\t\tif ( to != NULL)\n\t\t\t{\n\t\t\tdata->connected = 1;\n\t\t\tmemcpy(&(data->peer),to, sizeof(struct sockaddr));\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tdata->connected = 0;\n\t\t\tmemset(&(data->peer), 0x00, sizeof(struct sockaddr));\n\t\t\t}\n\t\tbreak;\n    case BIO_CTRL_DGRAM_SET_PEER:\n        to = (struct sockaddr *) ptr;\n        memcpy(&(data->peer), to, sizeof(struct sockaddr));\n        break;\n\tcase BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT:\n\t\tmemcpy(&(data->next_timeout), ptr, sizeof(struct timeval));\n\t\tbreak;\n#if defined(SO_RCVTIMEO)\n\tcase BIO_CTRL_DGRAM_SET_RECV_TIMEOUT:\n#ifdef OPENSSL_SYS_WINDOWS\n\t\t{\n\t\tstruct timeval *tv = (struct timeval *)ptr;\n\t\tint timeout = tv->tv_sec * 1000 + tv->tv_usec/1000;\n\t\tif (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,\n\t\t\t(void*)&timeout, sizeof(timeout)) < 0)\n\t\t\t{ perror("setsockopt"); ret = -1; }\n\t\t}\n#else\n\t\tif ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr,\n\t\t\tsizeof(struct timeval)) < 0)\n\t\t\t{ perror("setsockopt");\tret = -1; }\n#endif\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:\n#ifdef OPENSSL_SYS_WINDOWS\n\t\t{\n\t\tint timeout, sz = sizeof(timeout);\n\t\tstruct timeval *tv = (struct timeval *)ptr;\n\t\tif (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,\n\t\t\t(void*)&timeout, &sz) < 0)\n\t\t\t{ perror("getsockopt"); ret = -1; }\n\t\telse\n\t\t\t{\n\t\t\ttv->tv_sec = timeout / 1000;\n\t\t\ttv->tv_usec = (timeout % 1000) * 1000;\n\t\t\tret = sizeof(*tv);\n\t\t\t}\n\t\t}\n#else\n\t\tif ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,\n\t\t\tptr, (void *)&ret) < 0)\n\t\t\t{ perror("getsockopt"); ret = -1; }\n#endif\n\t\tbreak;\n#endif\n#if defined(SO_SNDTIMEO)\n\tcase BIO_CTRL_DGRAM_SET_SEND_TIMEOUT:\n#ifdef OPENSSL_SYS_WINDOWS\n\t\t{\n\t\tstruct timeval *tv = (struct timeval *)ptr;\n\t\tint timeout = tv->tv_sec * 1000 + tv->tv_usec/1000;\n\t\tif (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,\n\t\t\t(void*)&timeout, sizeof(timeout)) < 0)\n\t\t\t{ perror("setsockopt"); ret = -1; }\n\t\t}\n#else\n\t\tif ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr,\n\t\t\tsizeof(struct timeval)) < 0)\n\t\t\t{ perror("setsockopt");\tret = -1; }\n#endif\n\t\tbreak;\n\tcase BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:\n#ifdef OPENSSL_SYS_WINDOWS\n\t\t{\n\t\tint timeout, sz = sizeof(timeout);\n\t\tstruct timeval *tv = (struct timeval *)ptr;\n\t\tif (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,\n\t\t\t(void*)&timeout, &sz) < 0)\n\t\t\t{ perror("getsockopt"); ret = -1; }\n\t\telse\n\t\t\t{\n\t\t\ttv->tv_sec = timeout / 1000;\n\t\t\ttv->tv_usec = (timeout % 1000) * 1000;\n\t\t\tret = sizeof(*tv);\n\t\t\t}\n\t\t}\n#else\n\t\tif ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,\n\t\t\tptr, (void *)&ret) < 0)\n\t\t\t{ perror("getsockopt"); ret = -1; }\n#endif\n\t\tbreak;\n#endif\n\tcase BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:\n\tcase BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP:\n#ifdef OPENSSL_SYS_WINDOWS\n\t\tif ( data->_errno == WSAETIMEDOUT)\n#else\n\t\tif ( data->_errno == EAGAIN)\n#endif\n\t\t\t{\n\t\t\tret = 1;\n\t\t\tdata->_errno = 0;\n\t\t\t}\n\t\telse\n\t\t\tret = 0;\n\t\tbreak;\n#ifdef EMSGSIZE\n\tcase BIO_CTRL_DGRAM_MTU_EXCEEDED:\n\t\tif ( data->_errno == EMSGSIZE)\n\t\t\t{\n\t\t\tret = 1;\n\t\t\tdata->_errno = 0;\n\t\t\t}\n\t\telse\n\t\t\tret = 0;\n\t\tbreak;\n#endif\n\tdefault:\n\t\tret=0;\n\t\tbreak;\n\t\t}\n\treturn(ret);\n\t}']