Re: [libvirt] [PATCH] Make openvzGetVPSUUID take a len.

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

 



Daniel P. Berrange wrote:
> On Fri, Aug 07, 2009 at 11:06:20AM +0200, Chris Lalancette wrote:
>> Minor fix to openvzGetVPSUUID to make it take a length parameter.
>> This ensures that it doesn't make assumptions about the length
>> of the UUID buffer, and paves the way for removal of strncpy in
>> the future.
>>
>> Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
>> ---
>>  src/openvz_conf.c |   10 +++++-----
>>  1 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/openvz_conf.c b/src/openvz_conf.c
>> index 6e9af67..a172fe3 100644
>> --- a/src/openvz_conf.c
>> +++ b/src/openvz_conf.c
>> @@ -54,7 +54,7 @@
>>  #define VIR_FROM_THIS VIR_FROM_OPENVZ
>>  
>>  static char *openvzLocateConfDir(void);
>> -static int openvzGetVPSUUID(int vpsid, char *uuidstr);
>> +static int openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len);
>>  static int openvzLocateConfFile(int vpsid, char *conffile, int maxlen, const char *ext);
>>  static int openvzAssignUUIDs(void);
>>  
>> @@ -469,7 +469,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
>>          if (virAsprintf(&dom->def->name, "%i", veid) < 0)
>>              goto no_memory;
>>  
>> -        openvzGetVPSUUID(veid, uuidstr);
>> +        openvzGetVPSUUID(veid, uuidstr, sizeof(uuidstr));
>>          ret = virUUIDParse(uuidstr, dom->def->uuid);
>>  
>>          if (ret == -1) {
>> @@ -805,7 +805,7 @@ openvz_readline(int fd, char *ptr, int maxlen)
>>  }
>>  
>>  static int
>> -openvzGetVPSUUID(int vpsid, char *uuidstr)
>> +openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
>>  {
>>      char conf_file[PATH_MAX];
>>      char line[1024];
>> @@ -832,7 +832,7 @@ openvzGetVPSUUID(int vpsid, char *uuidstr)
>>  
>>          sscanf(line, "%s %s\n", iden, uuidbuf);
>>          if(STREQ(iden, "#UUID:")) {
>> -            strncpy(uuidstr, uuidbuf, VIR_UUID_STRING_BUFLEN);
>> +            strncpy(uuidstr, uuidbuf, len);
>>              break;
>>          }
>>      }
>> @@ -856,7 +856,7 @@ openvzSetDefinedUUID(int vpsid, unsigned char *uuid)
>>      if (openvzLocateConfFile(vpsid, conf_file, PATH_MAX, "conf")<0)
>>         return -1;
>>  
>> -    if (openvzGetVPSUUID(vpsid, uuidstr))
>> +    if (openvzGetVPSUUID(vpsid, uuidstr, sizeof(uuidstr)))
>>          return -1;
>>  
>>      if (uuidstr[0] == 0) {
> 
> ACK
> 
> Daniel

Committed.

-- 
Chris Lalancette

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