[PATCH] locking: avoid dereferencing a NULL pointer

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

 



From: Alex Jia <ajia@xxxxxxxxxx>

* src/locking/lock_driver_sanlock.c: in fact, virStrcpy calls
  virStrncpy(dest, src, strlen(src), destbytes) then return result,
  if 'path' is NULL, it means 'src' is also NULL, strlen(NULL) will
  dereference a NULL pointer, which probably causes a segmentation fault.

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 src/locking/lock_driver_sanlock.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 2d72510..8c6d873 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -158,7 +158,7 @@ static int virLockManagerSanlockSetupLockspace(void)
     memcpy(ls.name, VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE, SANLK_NAME_LEN);
     ls.host_id = 0; /* Doesn't matter for initialization */
     ls.flags = 0;
-    if (!virStrcpy(ls.host_id_disk.path, path, SANLK_PATH_LEN)) {
+    if (!path || !virStrcpy(ls.host_id_disk.path, path, SANLK_PATH_LEN)) {
         virLockError(VIR_ERR_INTERNAL_ERROR,
                      _("Lockspace path '%s' exceeded %d characters"),
                      path, SANLK_PATH_LEN);
-- 
1.7.1

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