From 435d1aeca82f2ae9736511951bbe48d212f30d1e Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 27 Mar 2022 22:11:27 -0400 Subject: use PATH_MAX instead of arbitrary pnlim of 1024 --- menudriver.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'menudriver.c') diff --git a/menudriver.c b/menudriver.c index 51a1ed9..c050d1c 100644 --- a/menudriver.c +++ b/menudriver.c @@ -9,6 +9,7 @@ * Revised to C11 standard and made 64bit compatible, January 2020 * *------------------------------------------------------------------------*/ +#include #include #include #include @@ -16,8 +17,15 @@ #include #include #include -typedef void (*sighandler)(); -#define pnlim 1024 + +#ifndef PATH_MAX +#ifdef _XOPEN_PATH_MAX +#define PATH_MAX _XOPEN_PATH_MAX +#else +#define PATH_MAX _POSIX_PATH_MAX +#endif +#endif + struct stat buf; char *menuviewer; @@ -179,8 +187,8 @@ void menudrive(char *dir) } /* no pathnames - see below */ if (S_ISDIR(buf.st_mode)) { /* directory */ - char hold[pnlim]; - if (!getcwd(hold, pnlim)) { + char hold[PATH_MAX]; + if (!getcwd(hold, sizeof(hold))) { fprintf(stderr, "panic: cwd too long\n"), exit(1); } @@ -333,7 +341,6 @@ void singleton(char *fil) void callshell(char v[]) { static char *shell = NULL; - sighandler oldsig; int pid; if (!shell) { @@ -343,7 +350,7 @@ void callshell(char v[]) } } - oldsig = signal(SIGINT, SIG_IGN); + void (*oldsig)(int) = signal(SIGINT, SIG_IGN); if ((pid = fork())) { /* parent */ if (pid == -1) { perror("UNIX error - cannot create process"); -- cgit v1.2.1