Blame SOURCES/libvirt-cim-0.6.3-fb5d2fcf.patch

c55d09
From fb5d2fcfe770d5446a6d8fcdcd405c6645c4dfb0 Mon Sep 17 00:00:00 2001
c55d09
From: John Ferlan <jferlan@redhat.com>
c55d09
Date: Wed, 22 Jan 2014 16:09:04 -0500
c55d09
Subject: [PATCH 46/60] Adjust sscanf format string
c55d09
c55d09
Currently the sscanf() calls use "%as" or "%a[" in order to allocate and
c55d09
return strings for read fields.  It was pointed out to me that this is an
c55d09
older and non-portable method.  Instead the "%ms" or "%m[" should be used.
c55d09
c55d09
Signed-off-by: John Ferlan <jferlan@redhat.com>
c55d09
---
c55d09
 libxkutil/acl_parsing.c                   |  2 +-
c55d09
 libxkutil/device_parsing.c                |  2 +-
c55d09
 libxkutil/misc_util.c                     |  2 +-
c55d09
 src/Virt_ComputerSystemIndication.c       |  2 +-
c55d09
 src/Virt_Device.c                         |  6 +++---
c55d09
 src/Virt_DevicePool.c                     |  8 ++++----
c55d09
 src/Virt_SettingsDefineState.c            |  2 +-
c55d09
 src/Virt_VirtualSystemManagementService.c | 12 ++++++------
c55d09
 8 files changed, 18 insertions(+), 18 deletions(-)
c55d09
c55d09
diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c
c55d09
index 3de6a65..c368b99 100644
c55d09
--- a/libxkutil/acl_parsing.c
c55d09
+++ b/libxkutil/acl_parsing.c
c55d09
@@ -666,7 +666,7 @@ int parse_rule_id(const char *rule_id, char **filter, int *index)
c55d09
 
c55d09
         if ((filter == NULL) || (index == NULL))
c55d09
                 return 0;
c55d09
-        ret = sscanf(rule_id, "%as[^:]:%u", filter, index);
c55d09
+        ret = sscanf(rule_id, "%ms[^:]:%u", filter, index);
c55d09
         if (ret != 2) {
c55d09
                 free(*filter);
c55d09
                 *filter = NULL;
c55d09
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
c55d09
index 4dd9e58..c9ae886 100644
c55d09
--- a/libxkutil/device_parsing.c
c55d09
+++ b/libxkutil/device_parsing.c
c55d09
@@ -1463,7 +1463,7 @@ int parse_fq_devid(const char *devid, char **host, char **device)
c55d09
 {
c55d09
         int ret;
c55d09
 
c55d09
-        ret = sscanf(devid, "%a[^/]/%a[^\n]", host, device);
c55d09
+        ret = sscanf(devid, "%m[^/]/%m[^\n]", host, device);
c55d09
         if (ret != 2) {
c55d09
                 free(*host);
c55d09
                 free(*device);
c55d09
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
c55d09
index 2164dd0..6a54815 100644
c55d09
--- a/libxkutil/misc_util.c
c55d09
+++ b/libxkutil/misc_util.c
c55d09
@@ -671,7 +671,7 @@ int parse_id(const char *id,
c55d09
         char *tmp_pfx = NULL;
c55d09
         char *tmp_name = NULL;
c55d09
 
c55d09
-        ret = sscanf(id, "%a[^:]:%a[^\n]", &tmp_pfx, &tmp_name);
c55d09
+        ret = sscanf(id, "%m[^:]:%m[^\n]", &tmp_pfx, &tmp_name);
c55d09
         if (ret != 2) {
c55d09
                 ret = 0;
c55d09
                 goto out;
c55d09
diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
c55d09
index 20c60bc..32bee97 100644
c55d09
--- a/src/Virt_ComputerSystemIndication.c
c55d09
+++ b/src/Virt_ComputerSystemIndication.c
c55d09
@@ -382,7 +382,7 @@ static char *sys_name_from_xml(char *xml)
c55d09
                 goto out;
c55d09
         }
c55d09
 
c55d09
-        rc = sscanf(tmp, "<name>%a[^<]s</name>", &name);
c55d09
+        rc = sscanf(tmp, "<name>%m[^<]s</name>", &name);
c55d09
         if (rc != 1) {
c55d09
                 name = NULL;
c55d09
         }
c55d09
diff --git a/src/Virt_Device.c b/src/Virt_Device.c
c55d09
index b93e592..12ae6bd 100644
c55d09
--- a/src/Virt_Device.c
c55d09
+++ b/src/Virt_Device.c
c55d09
@@ -675,7 +675,7 @@ static CMPIStatus return_enum_devices(const CMPIObjectPath *reference,
c55d09
 
c55d09
         s = enum_devices(_BROKER,
c55d09
                          reference,
c55d09
-                         NULL, 
c55d09
+                         NULL,
c55d09
                          res_type_from_device_classname(CLASSNAME(reference)),
c55d09
                          &list);
c55d09
         if (s.rc != CMPI_RC_OK)
c55d09
@@ -696,7 +696,7 @@ static int parse_devid(const char *devid, char **dom, char **dev)
c55d09
 {
c55d09
         int ret;
c55d09
 
c55d09
-        ret = sscanf(devid, "%a[^/]/%as", dom, dev);
c55d09
+        ret = sscanf(devid, "%m[^/]/%ms", dom, dev);
c55d09
         if (ret != 2) {
c55d09
                 free(*dom);
c55d09
                 free(*dev);
c55d09
@@ -711,7 +711,7 @@ static int proc_dev_list(uint64_t quantity,
c55d09
 {
c55d09
         int i;
c55d09
 
c55d09
-        *list = (struct virt_device *)calloc(quantity, 
c55d09
+        *list = (struct virt_device *)calloc(quantity,
c55d09
                                              sizeof(struct virt_device));
c55d09
 
c55d09
         for (i = 0; i < quantity; i++) {
c55d09
diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c
c55d09
index d6e51ba..aae7ed4 100644
c55d09
--- a/src/Virt_DevicePool.c
c55d09
+++ b/src/Virt_DevicePool.c
c55d09
@@ -383,11 +383,11 @@ static bool _diskpool_is_member(virConnectPtr conn,
c55d09
 
c55d09
         pool_vol = virStoragePoolLookupByVolume(vol);
c55d09
         if (vol != NULL) {
c55d09
-                pool_name = virStoragePoolGetName(pool_vol);                
c55d09
+                pool_name = virStoragePoolGetName(pool_vol);
c55d09
                 if ((pool_name != NULL) && (STREQC(pool_name, pool->tag)))
c55d09
                         result = true;
c55d09
         }
c55d09
-        
c55d09
+
c55d09
  out:
c55d09
         CU_DEBUG("Image %s in pool %s: %s",
c55d09
                  file,
c55d09
@@ -405,7 +405,7 @@ static bool parse_diskpool_line(struct tmp_disk_pool *pool,
c55d09
 {
c55d09
         int ret;
c55d09
 
c55d09
-        ret = sscanf(line, "%as %as", &pool->tag, &pool->path);
c55d09
+        ret = sscanf(line, "%ms %ms", &pool->tag, &pool->path);
c55d09
         if (ret != 2) {
c55d09
                 free(pool->tag);
c55d09
                 free(pool->path);
c55d09
@@ -1610,7 +1610,7 @@ CMPIStatus get_pool_by_name(const CMPIBroker *broker,
c55d09
                 goto out;
c55d09
         }
c55d09
 
c55d09
-        ret = sscanf(id, "%*[^/]/%a[^\n]", &poolid);
c55d09
+        ret = sscanf(id, "%*[^/]/%m[^\n]", &poolid);
c55d09
         if (ret != 1) {
c55d09
                 cu_statusf(broker, &s,
c55d09
                            CMPI_RC_ERR_NOT_FOUND,
c55d09
diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c
c55d09
index be2ded5..c8cda97 100644
c55d09
--- a/src/Virt_SettingsDefineState.c
c55d09
+++ b/src/Virt_SettingsDefineState.c
c55d09
@@ -298,7 +298,7 @@ static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref,
c55d09
                 goto out;
c55d09
         }
c55d09
 
c55d09
-        ret = sscanf(id, "%a[^:]:%as", &pfx, &name);
c55d09
+        ret = sscanf(id, "%m[^:]:%ms", &pfx, &name);
c55d09
         if (ret != 2) {
c55d09
                 cu_statusf(_BROKER, &s,
c55d09
                            CMPI_RC_ERR_FAILED,
c55d09
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c
c55d09
index 83e5c53..3e7785e 100644
c55d09
--- a/src/Virt_VirtualSystemManagementService.c
c55d09
+++ b/src/Virt_VirtualSystemManagementService.c
c55d09
@@ -1330,7 +1330,7 @@ static int parse_console_address(const char *id,
c55d09
 
c55d09
         CU_DEBUG("Entering parse_console_address, address is %s", id);
c55d09
 
c55d09
-        ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port);
c55d09
+        ret = sscanf(id, "%m[^:]:%ms", &tmp_path, &tmp_port);
c55d09
 
c55d09
         if (ret != 2) {
c55d09
                 ret = 0;
c55d09
@@ -1366,10 +1366,10 @@ static int parse_sdl_address(const char *id,
c55d09
 
c55d09
         CU_DEBUG("Entering parse_sdl_address, address is %s", id);
c55d09
 
c55d09
-        ret = sscanf(id, "%a[^:]:%as", &tmp_xauth, &tmp_display);
c55d09
+        ret = sscanf(id, "%m[^:]:%ms", &tmp_xauth, &tmp_display);
c55d09
 
c55d09
         if (ret <= 0) {
c55d09
-                ret = sscanf(id, ":%as", &tmp_display);
c55d09
+                ret = sscanf(id, ":%ms", &tmp_display);
c55d09
                 if (ret <= 0) {
c55d09
                         if (STREQC(id, ":")) {
c55d09
                                 /* do nothing, it is empty */
c55d09
@@ -1417,7 +1417,7 @@ static int parse_ip_address(const char *id,
c55d09
         CU_DEBUG("Entering parse_ip_address, address is %s", id);
c55d09
         if (strstr(id, "[") != NULL) {
c55d09
                 /* its an ipv6 address */
c55d09
-                ret = sscanf(id, "%a[^]]]:%as",  &tmp_ip, &tmp_port);
c55d09
+                ret = sscanf(id, "%m[^]]]:%ms",  &tmp_ip, &tmp_port);
c55d09
                 if (ret >= 1) {
c55d09
                         tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2);
c55d09
                         if (tmp_ip == NULL) {
c55d09
@@ -1427,7 +1427,7 @@ static int parse_ip_address(const char *id,
c55d09
                         strcat(tmp_ip, "]");
c55d09
                 }
c55d09
         } else {
c55d09
-                ret = sscanf(id, "%a[^:]:%as", &tmp_ip, &tmp_port);
c55d09
+                ret = sscanf(id, "%m[^:]:%ms", &tmp_ip, &tmp_port);
c55d09
         }
c55d09
 
c55d09
         /* ret == 2: address and port, ret == 1: address only */
c55d09
@@ -1464,7 +1464,7 @@ static bool parse_console_url(const char *url,
c55d09
 
c55d09
         CU_DEBUG("Entering parse_console_url:'%s'", url);
c55d09
 
c55d09
-        if (sscanf(url,"%a[^:]://%as", &tmp_protocol, &tmp_address) != 2)
c55d09
+        if (sscanf(url,"%m[^:]://%ms", &tmp_protocol, &tmp_address) != 2)
c55d09
                 goto out;
c55d09
 
c55d09
         if (parse_ip_address(tmp_address, host, port) < 1)
c55d09
-- 
c55d09
2.1.0
c55d09