[Dnsmasq-discuss] [PATCH] Remove NULL check for intname.

Kevin Darbyshire-Bryant kevin at darbyshire-bryant.me.uk
Thu Oct 5 11:22:10 BST 2017



On 05/10/17 06:20, rosenp at gmail.com wrote:
> On Wed, 2017-10-04 at 20:43 -0700, Kurt H Maier wrote:
>> On Wed, Oct 04, 2017 at 07:23:22PM -0700, Rosen Penev wrote:
>>>   
>>> -  if (intname && strlen(intname) != 0)
>>> +  if (!strlen(intname))
>>>       ifindex = if_nametoindex(intname); /* index == 0 when not
>>> binding to an interface */
>>
>> How much testing have you done of these patches?
>>
> 
> Compile time. Looks fine to me. To add to my commit message,
> strlen(NULL) causes a segmentation fault, meaning intname cannot be
> NULL.

Which is precisely why the 'intname' guard is there.  C evaluation order 
is left to right, if 'intname' is NULL then evaluation stops there.... 
strlen is never called with a NULL intname.

Kevin



More information about the Dnsmasq-discuss mailing list