From: Lennart Poettering Date: Wed, 28 Nov 2018 18:02:47 +0000 (+0100) Subject: mount: strdup() device paths we collect X-Git-Tag: v240~112^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b6418dc94eb0c4a3a1eb71e9a8444979d5c20d02;p=thirdparty%2Fsystemd.git mount: strdup() device paths we collect We never know what the changes triggered by mount_set_state() do to the unit. Let's be safe and copy the device path into our set, so that we are safe against that. --- diff --git a/src/core/mount.c b/src/core/mount.c index 477c2cbafae..9f7b490401a 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1782,7 +1782,7 @@ fail: } static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) { - _cleanup_set_free_ Set *around = NULL, *gone = NULL; + _cleanup_set_free_free_ Set *around = NULL, *gone = NULL; Manager *m = userdata; const char *what; Iterator i; @@ -1843,7 +1843,7 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, /* Remember that this device might just have disappeared */ if (set_ensure_allocated(&gone, &path_hash_ops) < 0 || - set_put(gone, mount->parameters_proc_self_mountinfo.what) < 0) + set_put_strdup(gone, mount->parameters_proc_self_mountinfo.what) < 0) log_oom(); /* we don't care too much about OOM here... */ } @@ -1896,9 +1896,10 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, if (mount_is_mounted(mount) && mount->from_proc_self_mountinfo && mount->parameters_proc_self_mountinfo.what) { + /* Track devices currently used */ if (set_ensure_allocated(&around, &path_hash_ops) < 0 || - set_put(around, mount->parameters_proc_self_mountinfo.what) < 0) + set_put_strdup(around, mount->parameters_proc_self_mountinfo.what) < 0) log_oom(); }