[PATCH] vircgroupmock.c: Avoid crashing if lstat() not found

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

 



In init_syms() we admit that stat() may not exists (in favor of existing
__lxstat). However, if previously an library checked for existence of
these two symbols and wisely has chosen the existing one, now, that we've
mocked the both symbols, we are confusing the library. Moreover, such
library will get SIGSEGV immediately after wrong decision, since
reallstat is NULL.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/vircgroupmock.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
index adc1718..0b44fda 100644
--- a/tests/vircgroupmock.c
+++ b/tests/vircgroupmock.c
@@ -542,10 +542,16 @@ int lstat(const char *path, struct stat *sb)
             errno = ENOMEM;
             return -1;
         }
-        ret = reallstat(newpath, sb);
+        if (reallstat)
+            ret = reallstat(newpath, sb);
+        else
+            ret = real__lxstat(_STAT_VER, newpath, sb);
         free(newpath);
     } else {
-        ret = reallstat(path, sb);
+        if (reallstat)
+            ret = reallstat(path, sb);
+        else
+            ret = real__lxstat(_STAT_VER, path, sb);
     }
     return ret;
 }
-- 
1.8.1.5

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