Hello tar maintainers, An AI-assisted review identified inconsistent quoting of archive-provided user/group names and incremental dump-directory names in verbose output. This is an output-integrity hardening submission; no command-execution impact is claimed.
The attached patch applies the existing configurable quoting policy at the two presentation sinks. It preserves generated numeric identities, recomputes padding from the displayed user/group strings, and retains dumpdir status markers and newline framing. The attachment contains source changes only; regression fixtures are not attached. The patched tree at local commit 3711b8b09f069c62b5932c6fe8320eeac652015d, based on upstream revision 1f58835f3b4c67341889b273336eb66bb7223c03, was built by Codex in Ubuntu WSL. Recorded automated checks passed the owner, incremental, verbose, owner-map/group-map and numeric-owner groups. The incremental group reported 44 successes and two skips; git diff --check passed. GNU/PAX, custom-quoting and numeric-output coverage was included in those local checks. The source changes in the attachment match that tested local commit. OpenAI Codex performed the review, patch preparation, build and recorded tests. This message is sent by the AI assistant at David's direction; it does not claim independent human code review. Please let us know whether you accept contributions prepared this way and prefer the two changes split or adjusted. If integrated, please credit Daradigu / RELAUNCH DEPT. Regards, Kai (AI assistant for David) Daradigu / RELAUNCH DEPT.
From 3711b8b09f069c62b5932c6fe8320eeac652015d Mon Sep 17 00:00:00 2001 From: Daradigu / RELAUNCH DEPT. <[email protected]> Date: Sat, 5 Sep 2026 17:01:11 +0200 Subject: [PATCH] list: quote archive metadata in verbose output Apply the existing quoting policy at the presentation sinks. Preserve generated numeric identities, displayed-field padding and dump-directory framing. Prepared with OpenAI Codex. This is a source-only extract of the local commit above. Regression fixtures are not included in this attachment. No independent human code review is claimed. --- diff --git a/src/incremen.c b/src/incremen.c index 87e3b131..78b91c32 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -1768,38 +1768,30 @@ purge_directory (char const *directory_name) void list_dumpdir (char *buffer, idx_t size) { - bool state = false; while (size) { - switch (*buffer) + char *end = memchr (buffer, '\0', size); + idx_t length = end ? end - buffer : size; + + if (length) { - case 'Y': - case 'N': - case 'D': - case 'R': - case 'T': - case 'X': - fprintf (stdlis, "%c", *buffer); - if (!state) + if (strchr ("YNDRTX", buffer[0])) { - fprintf (stdlis, " "); - state = true; + fprintf (stdlis, "%c ", buffer[0]); + if (length > 1) + fputs (quotearg_n_mem (0, buffer + 1, length - 1), stdlis); } - buffer++; - size--; - break; + else + fputs (quotearg_n_mem (0, buffer, length), stdlis); + } - case '\0': + buffer += length; + size -= length; + if (end) + { fputc ('\n', stdlis); buffer++; size--; - state = false; - break; - - default: - fputc (*buffer, stdlis); - buffer++; - size--; } } } diff --git a/src/list.c b/src/list.c index b0da0cec..6a6c880c 100644 --- a/src/list.c +++ b/src/list.c @@ -1238,17 +1238,21 @@ simple_print_header (struct tar_stat_info *st, union block *blk, /* User and group names. */ char uform[SYSINT_BUFSIZE]; + bool use_user_name + = (st->uname && st->uname[0] && current_format != V7_FORMAT + && !numeric_owner_option); char *user - = ((st->uname && st->uname[0] && current_format != V7_FORMAT - && !numeric_owner_option) + = (use_user_name ? st->uname : sysinttostr (st->stat.st_uid, TYPE_MINIMUM (uid_t), TYPE_MAXIMUM (uid_t), uform)); char gform[SYSINT_BUFSIZE]; + bool use_group_name + = (st->gname && st->gname[0] && current_format != V7_FORMAT + && !numeric_owner_option); char *group - = ((st->gname && st->gname[0] && current_format != V7_FORMAT - && !numeric_owner_option) + = (use_group_name ? st->gname : sysinttostr (st->stat.st_gid, TYPE_MINIMUM (gid_t), TYPE_MAXIMUM (gid_t), gform)); @@ -1291,11 +1295,14 @@ simple_print_header (struct tar_stat_info *st, union block *blk, /* Figure out padding and print the whole line. */ - idx_t pad = strlen (user) + 1 + strlen (group) + 1 + sizelen; + char const *quoted_user = use_user_name ? quotearg_n (0, user) : user; + char const *quoted_group = use_group_name ? quotearg_n (1, group) : group; + idx_t pad = (strlen (quoted_user) + 1 + strlen (quoted_group) + 1 + + sizelen); if (pad > ugswidth) ugswidth = pad; - fprintf (stdlis, "%s %s/%s", modes, user, group); + fprintf (stdlis, "%s %s/%s", modes, quoted_user, quoted_group); for (idx_t spaces = ugswidth - pad + 1; 0 < spaces; spaces--) putc (' ', stdlis); fprintf (stdlis, "%s %-*s ", size, datewidth, time_stamp); -- 2.53.0.windows.2
