[libvirt] [PATCH 17/20] storage: Remove PATH_MAX sized stack allocation from iSCSI backend

Matthias Bolte matthias.bolte at googlemail.com
Sun Apr 3 09:21:30 UTC 2011


---
 src/storage/storage_backend_iscsi.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 6eff5f5..2e2e99e 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -409,12 +409,15 @@ static int
 virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
                               const char *session)
 {
-    char sysfs_path[PATH_MAX];
+    char *sysfs_path;
     int retval = 0;
     uint32_t host;
 
-    snprintf(sysfs_path, PATH_MAX,
-             "/sys/class/iscsi_session/session%s/device", session);
+    if (virAsprintf(&sysfs_path,
+                    "/sys/class/iscsi_session/session%s/device", session) < 0) {
+        virReportOOMError();
+        return -1;
+    }
 
     if (virStorageBackendSCSIGetHostNumber(sysfs_path, &host) < 0) {
         virReportSystemError(errno,
@@ -430,6 +433,8 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
         retval = -1;
     }
 
+    VIR_FREE(sysfs_path);
+
     return retval;
 }
 
-- 
1.7.0.4




More information about the libvir-list mailing list