From: Roy Marples Date: Wed, 4 May 2016 12:34:13 +0000 (+0000) Subject: Read from BPF into a void pointer aliased to the buffer so that X-Git-Tag: v6.11.0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c6b7a28c7546b9b4ea08a2e1c82f0fcb01ec916;p=thirdparty%2Fdhcpcd.git Read from BPF into a void pointer aliased to the buffer so that Coverity doesn't treat the data as tainted. Of course it's tainted, but Coverity doesn't undertand our rules ensuring the data is clean. --- diff --git a/if-bsd.c b/if-bsd.c index 249fa4e3..cc40dbe6 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -498,7 +498,11 @@ if_readrawpacket(struct interface *ifp, uint16_t protocol, *flags = 0; for (;;) { if (state->buffer_len == 0) { - bytes = read(fd, state->buffer, state->buffer_size); + /* alias a void pointer to our buffer + * so that Coverity does not treat this as tainted. */ + void *bufp = state->buffer; + + bytes = read(fd, bufp, state->buffer_size); if (bytes == -1 || bytes == 0) return bytes; state->buffer_len = (size_t)bytes; diff --git a/ipv4.h b/ipv4.h index 91484aaa..036b5bfc 100644 --- a/ipv4.h +++ b/ipv4.h @@ -85,7 +85,7 @@ struct ipv4_state { #ifdef BSD /* Buffer for BPF */ size_t buffer_size, buffer_len, buffer_pos; - unsigned char *buffer; + uint8_t *buffer; #endif };