[Freeipa-devel] [PATCH] create tmp directory for ipa-kpasswd

Rich Megginson rmeggins at redhat.com
Fri May 2 15:20:53 UTC 2008


Dmitri Pal wrote:
> Simo Sorce wrote:
>> On Fri, 2008-05-02 at 10:34 -0400, Dmitri Pal wrote:
>>  
>>> Simo Sorce wrote:
>>>    
>>>> On Fri, 2008-05-02 at 18:38 +0900, Masato Taruishi wrote:
>>>>        
>>>>> +       tmp_file = (char
>>>>> *)malloc(strlen(cachedir)+strlen(TMP_TEMPLATE)+2);
>>>>>         if (!tmp_file) {
>>>>>                 syslog(LOG_ERR, "Out of memory!");
>>>>>                 ret = KRB5_KPASSWD_HARDERROR;
>>>>>                 goto done;
>>>>>         }
>>>>> +       strcpy( tmp_file, cachedir );
>>>>> +       strcat( tmp_file, "/" );
>>>>> +       strcat( tmp_file, TMP_TEMPLATE );
>>>>>             
>>>> Change all this with:
>>>> asprintf(&tmp_file, "%s/%s", cachedir, TMP_TEMPLATE);
>>>>
>>>> Simo.
>>>>
>>>>         
>>> This is a non standard extension. If we ever plan to have this code 
>>> on the client that will run on other OSes we should not optimize 
>>> like this.
>>> If it is server code I agree.
>>>     
>>
>> Server code.
>>
>> In any case I have replacement function for OSs that do not support
>> asprintf.
>> The reason I prefer asprintf is that allocation size is not manually
>> calculated and it avoid the use of completely unsafe functions like
>> strcpy and strcat (I know the code as proposed is ok, but once people
>> start to patch it bugs will creep in).
>>
>> Simo.
>>
>>   
> Ok
>
If NSPR is available, you can use PR_smprintf() to do the same thing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20080502/84306d22/attachment.bin>


More information about the Freeipa-devel mailing list