[SSSD] [PATCH] Variable in sdap_sudo_rules_refresh_send could be used, uninitialised.

Michal Židek mzidek at redhat.com
Wed Oct 3 08:36:35 UTC 2012


On 09/26/2012 07:30 PM, Stephen Gallagher wrote:
> On Wed 26 Sep 2012 01:20:25 PM EDT, Michal Židek wrote:
>> Another one liner. If no rules were passed to
>> sdap_sudo_rules_refresh_send (if rules[0] was NULL) and no error
>> occurred, then variable ret was used uninitialized. This is not very
>> likely to happen, but it is safer to have it initialized.
>>
>> Maybe we should consider adding initialization of all "ret" variables
>> to our coding guidelines to avoid these "unlikely but possible" errors
>> in new code.
>>
>
> Nack. We usually leave ret intentionally uninitialized because we always
> want to set it explicitly under normal operation. This is because an
> uninitialized use is detectable by the compiler or static analysis
> tools. If we pre-initialized it, we could just end up with unexpected
> behavior (falling into the default case).
>
> Please make all assignments to 'ret' be intentional rather than default.

Hmm.. I forgot to send new version of this patch. The ret variable is 
now set to EOK when program reaches the end without any error, so it is 
not used with garbage value in the clean-up.

Thanks
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Variable-in-sdap_sudo_rules_refresh_send-could-be-us.patch
Type: text/x-patch
Size: 740 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/sssd-devel/attachments/20121003/1bba6f72/attachment.bin>


More information about the sssd-devel mailing list