From 0cb383511136907c419f8a7b51bf39409b2354ad Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 3 Jan 2023 15:22:29 -0700 Subject: [PATCH] sudo_open_parent_dir: adjust loop terminating condition Checking for ep < pathend should be a bit clearer than ep != '\0' and has the advantage of working when pathend doesn't point to a NUL byte. No intended change in behavior. --- lib/util/mkdir_parents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/mkdir_parents.c b/lib/util/mkdir_parents.c index ba46b3968..61867a31d 100644 --- a/lib/util/mkdir_parents.c +++ b/lib/util/mkdir_parents.c @@ -106,7 +106,7 @@ sudo_open_parent_dir_v1(const char *path, uid_t uid, gid_t gid, mode_t mode, /* Iterate over path components, skipping the last one. */ pathend = cp + strlen(cp); - for (cp = sudo_strsplit(cp, pathend, "/", &ep); cp != NULL && *ep != '\0'; + for (cp = sudo_strsplit(cp, pathend, "/", &ep); cp != NULL && ep < pathend; cp = sudo_strsplit(NULL, pathend, "/", &ep)) { size_t len = (size_t)(ep - cp); int dfd;