svn commit: r309014 - head/sys/net80211

Ian Lepore ian at freebsd.org
Tue Nov 22 19:23:45 UTC 2016


On Tue, 2016-11-22 at 17:36 +0000, Adrian Chadd wrote:
> Author: adrian
> Date: Tue Nov 22 17:36:16 2016
> New Revision: 309014
> URL: https://svnweb.freebsd.org/changeset/base/309014
> 
> Log:
>   [net80211] high oops on the high seas, or "god damnit compilers,
> it's 2016 and you're supposed to save me from this."
>   

It's the redundant parens that did you in.  If it had been written

  if (rxs != NULL & (rxs->c_pktflags & IEEE80211_RX_F_IV_STRIP))

you would have been warned.  I'm not quite sure how the compiler world
standardized on "the presence of redundant parens means trust me I know
what I'm doing," but that seems to be where we've landed in 2016.

-- Ian

>   TODO:
>   
>   * drink real coffee before committing in the morning, or there's a
> high
>     risk of more obviously self-evident commits being turned into
> attempts
>     at humour.
>   
>   Reported by:	cem, Coverity CID 1366219
> 
> Modified:
>   head/sys/net80211/ieee80211_crypto_ccmp.c
> 
> Modified: head/sys/net80211/ieee80211_crypto_ccmp.c
> =====================================================================
> =========
> --- head/sys/net80211/ieee80211_crypto_ccmp.c	Tue Nov 22
> 17:14:09 2016	(r309013)
> +++ head/sys/net80211/ieee80211_crypto_ccmp.c	Tue Nov 22
> 17:36:16 2016	(r309014)
> @@ -241,7 +241,7 @@ ccmp_decap(struct ieee80211_key *k, stru
>  
>  	rxs = ieee80211_get_rx_params_ptr(m);
>  
> -	if ((rxs != NULL) & (rxs->c_pktflags &
> IEEE80211_RX_F_IV_STRIP))
> +	if ((rxs != NULL) && (rxs->c_pktflags &
> IEEE80211_RX_F_IV_STRIP))
>  		goto finish;
>  
>  	/*
> @@ -286,7 +286,7 @@ finish:
>  	/*
>  	 * Copy up 802.11 header and strip crypto bits.
>  	 */
> -	if (! ((rxs != NULL) & (rxs->c_pktflags &
> IEEE80211_RX_F_IV_STRIP))) {
> +	if (! ((rxs != NULL) && (rxs->c_pktflags &
> IEEE80211_RX_F_IV_STRIP))) {
>  		ovbcopy(mtod(m, void *), mtod(m, uint8_t *) +
> ccmp.ic_header,
>  		    hdrlen);
>  		m_adj(m, ccmp.ic_header);
> @@ -295,13 +295,13 @@ finish:
>  	/*
>  	 * XXX TODO: see if MMIC_STRIP also covers CCMP MIC trailer.
>  	 */
> -	if (! ((rxs != NULL) & (rxs->c_pktflags &
> IEEE80211_RX_F_MMIC_STRIP)))
> +	if (! ((rxs != NULL) && (rxs->c_pktflags &
> IEEE80211_RX_F_MMIC_STRIP)))
>  		m_adj(m, -ccmp.ic_trailer);
>  
>  	/*
>  	 * Ok to update rsc now.
>  	 */
> -	if (! ((rxs != NULL) & (rxs->c_pktflags &
> IEEE80211_RX_F_IV_STRIP))) {
> +	if (! ((rxs != NULL) && (rxs->c_pktflags &
> IEEE80211_RX_F_IV_STRIP))) {
>  		k->wk_keyrsc[tid] = pn;
>  	}
>  
> 


More information about the svn-src-head mailing list