summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-rules.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index b410216396..58c5c81574 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2541,7 +2541,7 @@ static int udev_rule_apply_token_to_event(
break;
}
case TK_A_DEVLINK: {
- char buf[UDEV_PATH_SIZE], *p;
+ char buf[UDEV_PATH_SIZE];
bool truncated;
size_t count;
@@ -2573,19 +2573,22 @@ static int udev_rule_apply_token_to_event(
"Replaced %zu character(s) from result of SYMLINK=\"%s\"",
count, token->value);
- p = skip_leading_chars(buf, NULL);
- while (!isempty(p)) {
- char path[UDEV_PATH_SIZE], *next;
+ for (const char *p = buf;;) {
+ _cleanup_free_ char *word = NULL, *path = NULL;
- next = strchr(p, ' ');
- if (next) {
- *next++ = '\0';
- next = skip_leading_chars(next, NULL);
+ r = extract_first_word(&p, &word, NULL, EXTRACT_RETAIN_ESCAPE);
+ if (r == -ENOMEM)
+ return log_oom();
+ if (r < 0) {
+ log_warning_errno(r, "Failed to extract first path in SYMLINK=, ignoring: %m");
+ break;
}
+ if (r == 0)
+ break;
- strscpyl_full(path, sizeof(path), &truncated, "/dev/", p, NULL);
- if (truncated)
- continue;
+ path = path_join("/dev/", word);
+ if (!path)
+ return log_oom();
if (token->op == OP_REMOVE) {
device_remove_devlink(dev, path);
@@ -2597,8 +2600,6 @@ static int udev_rule_apply_token_to_event(
log_event_debug(dev, token, "Added SYMLINK '%s'", path);
}
-
- p = next;
}
break;
}