qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL v2 2/2] usb: mtp filesharing


From: Eric Blake
Subject: Re: [Qemu-devel] [PULL v2 2/2] usb: mtp filesharing
Date: Thu, 24 Apr 2014 21:07:44 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 04/24/2014 07:21 AM, Stefan Hajnoczi wrote:

>> +static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
>> +{
>> +    struct dirent *entry;
>> +    DIR *dir;
>> +
>> +    o->nchildren = 0;
>> +    dir = opendir(o->path);
>> +    if (!dir) {
>> +        return;
>> +    }
>> +    while ((entry = readdir(dir)) != NULL) {
> 
> Please use the reentrant readdir_r() so we don't have to worry later on
> when removing the QEMU global mutex.

readdir_r() is absolute trash.  There is no safe way to know how large
to size the buffer.  POSIX is considering withdrawing it as useless, on
the grounds that readdir() is already thread-safe insofar as no two
threads share the same DIR*.

http://austingroupbugs.net/view.php?id=696

-- 
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]