NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/57355: resize(1) gets its name wrong.



>Number:         57355
>Category:       bin
>Synopsis:       resize(1) gets its name wrong.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 16 08:15:00 +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



Home | Main Index | Thread Index | Old Index