diff --git a/cmd/zed/zed_conf.c b/cmd/zed/zed_conf.c index 9e67363f7f45..b66b67b530bd 100644 --- a/cmd/zed/zed_conf.c +++ b/cmd/zed/zed_conf.c @@ -206,16 +206,19 @@ _zed_conf_parse_path(char **resultp, const char *path) if (path[0] == '/') { *resultp = strdup(path); - } else if (!getcwd(buf, sizeof (buf))) { - zed_log_die("Failed to get current working dir: %s", - strerror(errno)); - } else if (strlcat(buf, "/", sizeof (buf)) >= sizeof (buf)) { - zed_log_die("Failed to copy path: %s", strerror(ENAMETOOLONG)); - } else if (strlcat(buf, path, sizeof (buf)) >= sizeof (buf)) { - zed_log_die("Failed to copy path: %s", strerror(ENAMETOOLONG)); } else { + if (!getcwd(buf, sizeof (buf))) + zed_log_die("Failed to get current working dir: %s", + strerror(errno)); + + if (strlcat(buf, "/", sizeof (buf)) >= sizeof (buf) || + strlcat(buf, path, sizeof (buf)) >= sizeof (buf)) + zed_log_die("Failed to copy path: %s", + strerror(ENAMETOOLONG)); + *resultp = strdup(buf); } + if (!*resultp) zed_log_die("Failed to copy path: %s", strerror(ENOMEM)); }