diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index f5545374ad36b7380cdd6016b59a9f54301b47de..d86f0775b2c426e6c7a4a95e954cb9b9bfe22ad7 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; }