mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
qemuDomainCreateDevice: Don't loop endlessly
When working with symlinks it is fairly easy to get into a loop. Don't. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
54ed672214
commit
4ac847f93b
@ -6999,9 +6999,10 @@ qemuDomainGetPreservedMounts(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainCreateDevice(const char *device,
|
qemuDomainCreateDeviceRecursive(const char *device,
|
||||||
const char *path,
|
const char *path,
|
||||||
bool allow_noent)
|
bool allow_noent,
|
||||||
|
unsigned int ttl)
|
||||||
{
|
{
|
||||||
char *devicePath = NULL;
|
char *devicePath = NULL;
|
||||||
char *target = NULL;
|
char *target = NULL;
|
||||||
@ -7013,6 +7014,13 @@ qemuDomainCreateDevice(const char *device,
|
|||||||
char *tcon = NULL;
|
char *tcon = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!ttl) {
|
||||||
|
virReportSystemError(ELOOP,
|
||||||
|
_("Too many levels of symbolic links: %s"),
|
||||||
|
device);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (lstat(device, &sb) < 0) {
|
if (lstat(device, &sb) < 0) {
|
||||||
if (errno == ENOENT && allow_noent) {
|
if (errno == ENOENT && allow_noent) {
|
||||||
/* Ignore non-existent device. */
|
/* Ignore non-existent device. */
|
||||||
@ -7102,7 +7110,8 @@ qemuDomainCreateDevice(const char *device,
|
|||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainCreateDevice(target, path, allow_noent) < 0)
|
if (qemuDomainCreateDeviceRecursive(target, path,
|
||||||
|
allow_noent, ttl - 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
if (create &&
|
if (create &&
|
||||||
@ -7173,6 +7182,17 @@ qemuDomainCreateDevice(const char *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainCreateDevice(const char *device,
|
||||||
|
const char *path,
|
||||||
|
bool allow_noent)
|
||||||
|
{
|
||||||
|
long symloop_max = sysconf(_SC_SYMLOOP_MAX);
|
||||||
|
|
||||||
|
return qemuDomainCreateDeviceRecursive(device, path,
|
||||||
|
allow_noent, symloop_max);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainPopulateDevices(virQEMUDriverPtr driver,
|
qemuDomainPopulateDevices(virQEMUDriverPtr driver,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user