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.
This commit is contained in:
Todd C. Miller
2023-01-03 15:22:29 -07:00
parent 311d8e82df
commit 0cb3835111

View File

@@ -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;