Language: C
Label: safe
CWE: CWE-190 \u2014 Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.

Code:
void ep2_map_dst(ep2_t p, const uint8_t *msg, size_t len, const uint8_t *dst,
		size_t dst_len) {
	/* enough space for two field elements plus extra bytes for uniformity */
	const int lpe = (FP_PRIME + ep_param_level() + 7) / 8;
	uint8_t *pseudo_random_bytes = RLC_ALLOCA(uint8_t, 4 * lpe);

	RLC_TRY {
		/* XXX(rsw) See note in ep/relic_ep_map.c about using MD_MAP. */
		/* hash to a pseudorandom string using md_xmd */
		md_xmd(pseudo_random_bytes, 4 * lpe, msg, len, dst, dst_len);
		ep2_map_from_field(p, pseudo_random_bytes, 2 * lpe);
	}
	RLC_CATCH_ANY {
		RLC_THROW(ERR_CAUGHT);
	}
	RLC_FINALLY {
		RLC_FREE(pseudo_random_bytes);
	}
}