From 93ce4f4248999adeb85c6859dc2b5c54d7a8d7b7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 7 Aug 2022 00:04:54 +0200 Subject: user/libc: strchr --- src/user/bootstrap/tar.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/user/bootstrap/tar.c') diff --git a/src/user/bootstrap/tar.c b/src/user/bootstrap/tar.c index 0356987..6bd4179 100644 --- a/src/user/bootstrap/tar.c +++ b/src/user/bootstrap/tar.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -94,12 +95,8 @@ static void tar_read(struct fs_wait_response *res, void *base, size_t base_len) char *suffix = base + off + meta_len; /* check if the path contains any non-trailing slashes */ - char *next = suffix; - // TODO strchr - while (*next && *next != '/') next++; - if (*next == '/') next++; - - if (*next == '\0') { + char *slash = strchr(suffix, '/'); + if (!slash || slash[1] == '\0') { if (dir_append(&db, suffix)) break; } } -- cgit v1.2.3