From: datauwu Date: Tue, 21 Jul 2026 09:43:15 +0000 (+0800) Subject: xar: use strrchr to find parent directories X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b76db24481fa5dd967569473cb51d0d694fbcfeb;p=thirdparty%2Flibarchive.git xar: use strrchr to find parent directories Replace the manual pathname scan with strrchr when locating the parent directory. --- diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index c3e444f7e..60aca3b23 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -2249,15 +2249,8 @@ file_gen_utility_names(struct archive_write *a, struct file *file) archive_strncpy(&(file->symlink), pp, len2); cleanup_backslash(file->symlink.s, file->symlink.length); } - /* - * - Count up directory elements. - * - Find out the position which points the last position of - * path separator('/'). - */ - slash = NULL; - for (; *p != '\0'; p++) - if (*p == '/') - slash = p; + /* Find the last path separator. */ + slash = strrchr(p, '/'); if (slash == NULL) { /* The pathname doesn't have a parent directory. */ file->parentdir.length = len;