Re: [libvirt] [PATCH 07/10] openvz: Use strtok_r instead of sscanf for VPS UUID parsing

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

 



2010/3/31 Eric Blake <eblake@xxxxxxxxxx>:
> On 03/30/2010 10:20 AM, Matthias Bolte wrote:
>> @@ -861,8 +862,10 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
>>              break;
>>          }
>>
>> -        sscanf(line, "%s %s\n", iden, uuidbuf);
>> -        if(STREQ(iden, "#UUID:")) {
>> +        iden = strtok_r(line, " ", &saveptr);
>> +        uuidbuf = strtok_r(NULL, "", &saveptr);
>> +
>> +        if (iden != NULL && uuidbuf != NULL && STREQ(iden, "#UUID:")) {
>
> ACK.
>

Actually, there is a bug in here. I noticed it while I reviewed this
series for the problems you already mentioned.

uuidbuf ends up containing VIR_UUID_STRING_BUFLEN + 1 (for the
trailing \n) chars. But uuidstr has only room for
VIR_UUID_STRING_BUFLEN indicated by len and virStrcpy will fail.

If fixed this in v2 of this series by using "\n" as separator for the
second strtok_r call.

I think I'm going to post v2 later this day.

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]