qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 2/9] dump: Add API to manipulate cache_data


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v4 2/9] dump: Add API to manipulate cache_data
Date: Fri, 21 Jun 2013 12:00:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

On 06/19/2013 01:29 PM, Andreas Färber wrote:

>> +int init_cache_data(struct cache_data *cd, const char *filename)
>> +{
>> +    int fd;
>> +    char *tmpname;
>> +
>> +    /* init the tmp file */
>> +    tmpname = getenv("TMPDIR");
>> +    if (!tmpname) {
>> +        tmpname = (char *)P_tmpdir;
> 
> P_tmpdir is marked obsolescent in Open Group spec 7. Maybe Erik can

s/Erik/Eric/ (but don't worry, you're not the first to make that typo)

Hmm, you are correct that tempnam() is marked as an obsolescent
interface (because it has the same security flaws as mktemp(); the
standard introduced mkstemp() to overcome the security hole but did not
add a replacement for tempnam()).  I guess since nothing else in the
standard refers to P_tmpdir, it was also marked obsolecent.  And since
C99 doesn't require either the constant or the (inherently broken)
tempnam(), it may be safer to guard this line by #ifdef P_tmpdir, rather
than assuming that <stdio.h> blindly provides it.

> comment some more? Did you verify it builds with mingw32/64?
> (I stumbled over it because I found the variable name odd and didn't see
> it defined anywhere.)
> 
>> +    }
>> +
>> +    cd->file_name = (char *)g_strdup_printf("%s/%s", tmpname, filename);
>> +
>> +    fd = mkstemp(cd->file_name);

At least your use of P_tmpdir was to generate a saner template, instead
of trying to use the inherently-broken tempnam().

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]