Re: [PATCH] rpcrt4: Fixed incorrect NULL check condition (Coverity)

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [PATCH] rpcrt4: Fixed incorrect NULL check condition (Coverity)

by Rob Shearman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/17 Marcus Meissner <marcus@...>:
> Hi,
>
> Coverity spotted that this could lead to NULL dereference,
> and yes, the && should be ||.

This is not what was intended. The code inside the if block shouldn't
execute if assoc->NetworkOptions is NULL and NetworkOptions isn't and
vice-versa. The comparison should probably be split into a separate
function.

> @@ -97,7 +97,7 @@ RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr,
>         if (!strcmp(Protseq, assoc->Protseq) &&
>             !strcmp(NetworkAddr, assoc->NetworkAddr) &&
>             !strcmp(Endpoint, assoc->Endpoint) &&
> -            ((!assoc->NetworkOptions && !NetworkOptions) || !strcmpW(NetworkOptions, assoc->NetworkOptions)))
> +            (!assoc->NetworkOptions || !NetworkOptions || !strcmpW(NetworkOptions, assoc->NetworkOptions)))

Thanks,
--
Rob Shearman