From cd708ef4ea01b6e95929c9bbcb5668ce441f555d Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Sun, 3 Apr 2011 11:21:30 +0200 Subject: [PATCH] storage: Remove PATH_MAX sized stack allocation from iSCSI backend --- src/storage/storage_backend_iscsi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index f5545374ad..d86f0775b2 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -408,12 +408,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, @@ -429,6 +432,8 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool, retval = -1; } + VIR_FREE(sysfs_path); + return retval; }