diff mbox series

P*rtability of dash to legacy systems, such as AT&T Unix PC : 03-name-max

Message ID 60f962f7-1834-45da-bee9-c245c6797f9e@knaff.lu (mailing list archive)
State Under Review
Delegated to: Herbert Xu
Headers show
Series P*rtability of dash to legacy systems, such as AT&T Unix PC : 03-name-max | expand

Commit Message

Alain Knaff Nov. 17, 2024, 9:32 a.m. UTC
Hi,

The third part of the patch set supplies a definition of NAME_MAX
where one is lacking.

This is the case not only on UnixPC, but also on the Solaris platforms.

When supplying NAME_MAX, we may err towards values which are too
large, because NAME_MAX is used to ensure that a buffer used to hold
filenames while globbing is large enough. Hence I use PATH_MAX.

After having applied the 3 patches so far, the program should compile
on Solaris 11.

Regards,

Alain

Comments

Herbert Xu Nov. 17, 2024, 9:34 a.m. UTC | #1
On Sun, Nov 17, 2024 at 10:32:38AM +0100, Alain Knaff wrote:
> Hi,
> 
> The third part of the patch set supplies a definition of NAME_MAX
> where one is lacking.

Please don't put that prefix in the Subject (P*rtability of
dash to legacy systems, such as AT&T Unix PC :).  There is a length
limit to what patchwork will take from the Subject line and using
this prefix of yours will cause all but the first patch to go in
as a comment.

Cheers,
Steffen Nurpmeso Nov. 18, 2024, 6:28 p.m. UTC | #2
Hello,

for your possible interest..

Alain Knaff wrote in
 <60f962f7-1834-45da-bee9-c245c6797f9e@knaff.lu>:
 |The third part of the patch set supplies a definition of NAME_MAX
 |where one is lacking.
 ...
 |+#ifndef NAME_MAX
 |+/* NAME_MAX is only used in expand.c to make sure that we have a
 |+   buffer big enough to append the next local file part into during
 |+   globbing. So, in case of doubt, we need NAME_MAX to be bigger
 |+   rather than smaller, in order to prevent buffer overflow */
 |+# define NAME_MAX PATH_MAX
 |+#endif

i have for reasons i have forgotten otherwise

/* POSIX 2008/Cor 1-2013 defines for
 * - _POSIX_PATH_MAX a minimum of 256
 * - _XOPEN_PATH_MAX a minimum of 1024
 * NFS RFC 1094 from March 1989 defines a MAXPATHLEN of 1024, so we really
 * should avoid anything smaller than that! */
#ifndef PATH_MAX
# ifdef MAXPATHLEN
#  define PATH_MAX MAXPATHLEN
# else
#  define PATH_MAX 1024
# endif
#endif
#if PATH_MAX + 0 < 1024
# undef PATH_MAX
# define PATH_MAX 1024
#endif

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
|
|And in Fall, feel "The Dropbear Bard"s ball(s).
|
|The banded bear
|without a care,
|Banged on himself fore'er and e'er
|
|Farewell, dear collar bear
diff mbox series

Patch

diff -X ../exclude.txt -urN dash-0.5.12+02-stat64/src/system.h dash-0.5.12+03-name-max/src/system.h
--- dash-0.5.12+02-stat64/src/system.h	2020-06-03 02:23:24.000000000 +0000
+++ dash-0.5.12+03-name-max/src/system.h	2024-11-10 14:52:28.805681954 +0000
@@ -116,3 +116,11 @@ 
  * code
  */
 #define uninitialized_var(x) x = x
+
+#ifndef NAME_MAX
+/* NAME_MAX is only used in expand.c to make sure that we have a
+   buffer big enough to append the next local file part into during
+   globbing. So, in case of doubt, we need NAME_MAX to be bigger
+   rather than smaller, in order to prevent buffer overflow */
+# define NAME_MAX PATH_MAX
+#endif