[SSSD] [PATCH] Don't pass user input as a printf format string argument

Stef Walter stefw at redhat.com
Wed Jan 8 20:02:52 UTC 2014


On 08.01.2014 17:59, Simo Sorce wrote:
> On Wed, 2014-01-08 at 11:21 +0100, Stef Walter wrote:
>> On 07.01.2014 22:21, Simo Sorce wrote:
>>> Sorry I forgot another, I think you should either set errno on errors,
>>> or return an errno_t instead of -1. Just returning -1 for all errors is
>>> a poor interface.
>>
>> It's the same interface as the functions being replaced: snprintf and
>> asprintf. We return the full format length, or -1 on failure. snprintf
>> and friends don't set errno. See man printf(3).
>>
>> But I guess now that we're diverging from the interface provided by
>> snprintf and friends, I don't mind setting errno to EINVAL/ENOMEM if it
>> makes you happy.
> 
> Well I generally prefer to know if the format was wrong or ENOMEM
> happened, but I see you removed the alloc version ... I guess in this
> case I am not too picky, only format errors can happen now.

I figured that neither neither realmd or sssd was using the asprintf
variant (both used other allocation schemes) I might as well remove it.

Cheers,

Stef




More information about the sssd-devel mailing list