mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
tests: virfilemock: realpath: Allow non-null second parameter
When other preloaded libraries wrap and / or make calls to `realpath` (e.g. LLVM's AddessSanitizer), the second parameter is no longer guaranteed to be NULL. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c9ced46673
commit
a86682c57e
@ -1740,7 +1740,7 @@ exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
|
|||||||
exclude_file_name_regexp--sc_po_check = ^(docs/|src/rpc/gendispatch\.pl$$|tests/commandtest.c$$)
|
exclude_file_name_regexp--sc_po_check = ^(docs/|src/rpc/gendispatch\.pl$$|tests/commandtest.c$$)
|
||||||
|
|
||||||
exclude_file_name_regexp--sc_prohibit_PATH_MAX = \
|
exclude_file_name_regexp--sc_prohibit_PATH_MAX = \
|
||||||
^build-aux/syntax-check\.mk$$
|
^(build-aux/syntax-check\.mk|tests/virfilemock.c)$$
|
||||||
|
|
||||||
exclude_file_name_regexp--sc_prohibit_access_xok = \
|
exclude_file_name_regexp--sc_prohibit_access_xok = \
|
||||||
^(src/util/virutil\.c)$$
|
^(src/util/virutil\.c)$$
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#if WITH_LINUX_MAGIC_H
|
#if WITH_LINUX_MAGIC_H
|
||||||
# include <linux/magic.h>
|
# include <linux/magic.h>
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "virmock.h"
|
#include "virmock.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
@ -186,15 +185,20 @@ realpath(const char *path, char *resolved)
|
|||||||
|
|
||||||
if (getenv("LIBVIRT_MTAB")) {
|
if (getenv("LIBVIRT_MTAB")) {
|
||||||
const char *p;
|
const char *p;
|
||||||
char *ret;
|
|
||||||
|
|
||||||
assert(resolved == NULL);
|
if ((p = STRSKIP(path, "/some/symlink"))) {
|
||||||
if ((p = STRSKIP(path, "/some/symlink")))
|
if (resolved)
|
||||||
ret = g_strdup_printf("/gluster%s", p);
|
g_snprintf(resolved, PATH_MAX, "/gluster%s", p);
|
||||||
else
|
else
|
||||||
ret = g_strdup(path);
|
resolved = g_strdup_printf("/gluster%s", p);
|
||||||
|
} else {
|
||||||
|
if (resolved)
|
||||||
|
g_strlcpy(resolved, path, PATH_MAX);
|
||||||
|
else
|
||||||
|
resolved = g_strdup(path);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return resolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
return real_realpath(path, resolved);
|
return real_realpath(path, resolved);
|
||||||
|
Loading…
Reference in New Issue
Block a user