Coverity points out that if the string is longer than INT_MAX, the int
will overflow and the cast to uint8_t will discard bits.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <josutton@catalyst.net.nz>
enum ndr_err_code ndr_push_dnsp_string(struct ndr_push *ndr, ndr_flags_type ndr_flags, const char *string)
{
- int total_len;
+ size_t total_len;
total_len = strlen(string);
if (total_len > 255) {
return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
- "dns_name of length %d larger than 255", total_len);
+ "dns_name of length %zu larger than 255",
+ total_len);
}
NDR_CHECK(ndr_push_uint8(ndr, ndr_flags, (uint8_t)total_len));
NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)string, total_len));