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(a)redhat.com>
---
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