Language: C
Label: safe
CWE: CWE-787 \u2014 Out-of-bounds Write
The product writes data past the end, or before the beginning, of the intended buffer.

Code:
int dns_HTTPS_add_alpn(struct dns_rr_nested *svcparam, const char *alpn, int alpn_len)
{
	if (_dns_left_len(&svcparam->context) < 2 + 2 + alpn_len) {
		return -1;
	}

	unsigned short value = DNS_HTTPS_T_ALPN;
	dns_add_rr_nested_memcpy(svcparam, &value, 2);

	value = alpn_len;
	dns_add_rr_nested_memcpy(svcparam, &value, 2);
	dns_add_rr_nested_memcpy(svcparam, alpn, alpn_len);

	return 0;
}