NetBSD Problem Report #57355

From www@netbsd.org  Sun Apr 16 08:10:46 2023
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))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7C27E1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 16 Apr 2023 08:10:46 +0000 (UTC)
Message-Id: <20230416081045.162A31A923A@mollari.NetBSD.org>
Date: Sun, 16 Apr 2023 08:10:45 +0000 (UTC)
From: rvp@SDF.ORG
Reply-To: rvp@SDF.ORG
To: gnats-bugs@NetBSD.org
Subject: resize(1) gets its name wrong.
X-Send-Pr-Version: www-1.0

>Number:         57355
>Category:       bin
>Synopsis:       resize(1) gets its name wrong.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gutteridge
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 16 08:15:00 +0000 2023
>Closed-Date:    Tue Apr 25 16:05:42 +0000 2023
>Last-Modified:  Tue Apr 25 16:05:42 +0000 2023
>Originator:     RVP
>Release:        NetBSD-HEAD as of 2023-04-16
>Organization:
>Environment:
NetBSD x202e.localdomain 10.99.3 NetBSD 10.99.3 (MYKERNEL) #0: Sat Apr 15 04:02:16 UTC 2023  bld@x202e.localdomain:/tmp/obj/usr/src/sys/arch/amd64/compile/MYKERNEL amd64
>Description:
basename(3) returns a pointer to an internal static buffer. Therefore,
a copy of this string should be made if you make multiple calls to
basename(3). resize(1) does not, and we get:

```
$ resize blah
Usage: bash [-v] [-u] [-c] [-s [rows cols]]
$ 
```

Here, `bash' as the name is the result of the _second_ call to basename
in the source.
>How-To-Repeat:
As above.
>Fix:
--- src/usr.bin/resize/resize.h.orig	2021-02-28 00:44:58.000000000 +0000
+++ src/usr.bin/resize/resize.h	2023-04-16 07:50:18.163112214 +0000
@@ -60,7 +60,7 @@
 #define TTYSIZE_COLS(ws) (ws).ws_col
 #define SET_TTYSIZE(fd, ws) ioctl((fd), TIOCSWINSZ, &(ws))

-#define x_basename(a) basename(a)
+#define x_basename(a) estrdup(basename(a))
 #define x_strdup(a) estrdup(a)
 #define x_getenv(a) getenv(a)
 #define x_getlogin(u, p) __nothing

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->gutteridge
Responsible-Changed-By: gutteridge@NetBSD.org
Responsible-Changed-When: Thu, 20 Apr 2023 22:19:30 +0000
Responsible-Changed-Why:
I'll handle this.

From: "David H. Gutteridge" <gutteridge@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57355 CVS commit: src/usr.bin/resize
Date: Thu, 20 Apr 2023 22:23:53 +0000

 Module Name:	src
 Committed By:	gutteridge
 Date:		Thu Apr 20 22:23:53 UTC 2023

 Modified Files:
 	src/usr.bin/resize: resize.h

 Log Message:
 resize.c: use estrdup(3) with basename(3)

 basename(3) is invoked more than once on different paths. Retain the
 correct name for the utility itself on error. Addresses PR bin/57355
 from RVP, who provided the patch.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/usr.bin/resize/resize.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->pending-pullups
State-Changed-By: gutteridge@NetBSD.org
State-Changed-When: Fri, 21 Apr 2023 21:22:53 +0000
State-Changed-Why:
Pullup ticket pullup-10 #147.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57355 CVS commit: [netbsd-10] src/usr.bin/resize
Date: Tue, 25 Apr 2023 15:33:22 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Apr 25 15:33:22 UTC 2023

 Modified Files:
 	src/usr.bin/resize [netbsd-10]: resize.h

 Log Message:
 Pull up following revision(s) (requested by gutteridge in ticket #147):

 	usr.bin/resize/resize.h: revision 1.3

 resize.c: use estrdup(3) with basename(3)
 basename(3) is invoked more than once on different paths. Retain the
 correct name for the utility itself on error. Addresses PR bin/57355
 from RVP, who provided the patch.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.6.1 src/usr.bin/resize/resize.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: gutteridge@NetBSD.org
State-Changed-When: Tue, 25 Apr 2023 16:05:42 +0000
State-Changed-Why:
Resolved, thanks for the PR!

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.