Fix Coverity Scan 1251560

pull/2740/head
Roger A. Light 3 years ago
parent dcbbf71cb2
commit 85f53b22dd

@ -1620,6 +1620,10 @@ static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url)
in_ipv6_address = true;
start = i+1;
}else if(str[i] == ']'){
if(host){
err_printf(cfg, "Error: Duplicate IPv6 address.\n");
goto cleanup;
}
in_ipv6_address = false;
len = i-start;

@ -406,13 +406,14 @@ int socks5__read(struct mosquitto *mosq)
packet__cleanup(&mosq->in_packet);
return MOSQ_ERR_PROTOCOL;
}
/* coverity[tainted_data] - we know the value of
* mosq->in_packet.packet_lenth is within a bound. At the start of
* this if statement, it was 5. The next set of if statements add
* either (4+2-1)=5 to its value, or (16+2-1)=17 to its value, or
* the contents of a uint8_t, which can be a maximum of 255. So the
* range is 10 to 260 bytes. Coverity most likely doesn't realise
* this because the += promotes to the size of packet_length. */
/* We know the value of mosq->in_packet.packet_lenth is within a
* bound. At the start of this if statement, it was 5. The next set
* of if statements add either (4+2-1)=5 to its value, or
* (16+2-1)=17 to its value, or the contents of a uint8_t, which
* can be a maximum of 255. So the range is 10 to 260 bytes.
* Coverity most likely doesn't realise this because the +=
* promotes to the size of packet_length. */
/* coverity[tainted_data] */
payload = mosquitto__realloc(mosq->in_packet.payload, mosq->in_packet.packet_length);
if(payload){
mosq->in_packet.payload = payload;

Loading…
Cancel
Save