NetBSD Problem Report #60520

From www@netbsd.org  Thu Jul 30 19:23:53 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "YR2" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5AE401A923B
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 30 Jul 2026 19:23:53 +0000 (UTC)
Message-Id: <20260730192351.7C4AB1A923C@mollari.NetBSD.org>
Date: Thu, 30 Jul 2026 19:23:51 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: pax: -0 option applies only to input, not to output
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>

>Number:         60520
>Category:       bin
>Synopsis:       pax: -0 option applies only to input, not to output
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 30 19:25:00 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, 9, ...
>Organization:
The PaxBSD Extension, Inc0
>Environment:
>Description:

	Our pax(1) has an option `-0' to read files on input with a NUL
	separator instead of LF separator:

     -0    Use the nul character instead of \n as the file separator when
           reading files from standard input.

	https://man.netbsd.org/NetBSD-11.x-BRANCH/pax.1

	However, it doesn't apply to files written on output.

	This option for the POSIX committe-invented pax(1) interface is
	an extension to POSIX:

	https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/pax.html

	Strikes me as weird to carve out bespoke extensions to the
	POSIX pax(1) interface, but what `-0' does at least strikes me
	as sensible -- except for the part where it only applies to
	input, not to output.

>How-To-Repeat:

$ (cd / && pax -w ./bin/cat ./bin/sh | pax -0 | hexdump -C)
00000000  2e 2f 62 69 6e 2f 63 61  74 0a 2e 2f 62 69 6e 2f  |./bin/cat../bin/|
00000010  73 68 0a                                          |sh.|
00000013

	Notice the `0a' bytes; I would expect `pax -0' to use `00'
	instead.

>Fix:

	Yes, please!

	1. Use "%s", sep instead of "\n" here:

    117 	/*
    118 	 * if not verbose, just print the file name
    119 	 */
    120 	if (!vflag) {
 => 121 		(void)fprintf(fp, "%s\n", arcn->name);
    122 		(void)fflush(fp);
    123 		return;
    124 	}

https://nxr.netbsd.org/xref/src/bin/pax/gen_subs.c?r=1.38#117

	2. Consider doing something sensible for the long `-v' output
	   too.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.