diff --git a/CHANGES b/CHANGES index 069476b..7b01d9c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,7 @@ --- $MawkId: CHANGES,v 1.409 2024/12/13 00:44:41 tom Exp $ +-- $MawkId: CHANGES,v 1.411 2024/12/14 01:09:36 tom Exp $ + +20241213 + + disallow reading from a directory like a file (Original-Mawk #83). 20241212 + modify calls on stdtod() to disallow hexadecimal, infinite and diff --git a/MANIFEST b/MANIFEST index bfe0a7f..ccee9a4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,4 @@ -MANIFEST for mawk, version t20241212 +MANIFEST for mawk, version t20241213 -------------------------------------------------------------------------------- MANIFEST this file ACKNOWLEDGMENT acknowledgements diff --git a/config_h.in b/config_h.in index 0f22db2..a64e69a 100644 --- a/config_h.in +++ b/config_h.in @@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991. ********************************************/ /* - * $MawkId: config_h.in,v 1.42 2024/11/17 22:07:11 tom Exp $ + * $MawkId: config_h.in,v 1.43 2024/12/14 01:12:07 tom Exp $ * template for config.h */ @@ -28,6 +28,7 @@ the GNU General Public License, version 2, 1991. #undef HAVE_FCNTL_H #undef HAVE_FORK #undef HAVE_FSEEKO +#undef HAVE_FSTAT #undef HAVE_GETTIMEOFDAY #undef HAVE_INT64_T #undef HAVE_INTTYPES_H diff --git a/configure b/configure index 2ae7083..e7ebd96 100755 --- a/configure +++ b/configure @@ -11163,7 +11163,7 @@ EOF fi -for ac_func in fork matherr mktime pipe strftime tsearch wait +for ac_func in fork fstat matherr mktime pipe strftime tsearch wait do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:11169: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 603b5e5..ed35eb6 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $MawkId: configure.in,v 1.76 2024/11/17 23:54:26 tom Exp $ +dnl $MawkId: configure.in,v 1.77 2024/12/14 00:43:08 tom Exp $ dnl configure.in for mawk dnl ########################################################################### dnl copyright 2008-2023,2024, Thomas E. Dickey @@ -132,7 +132,7 @@ CF_MAWK_FIND_SIZE_T CF_LOCALE CF_CHECK_ENVIRON(environ) -AC_CHECK_FUNCS(fork matherr mktime pipe strftime tsearch wait) +AC_CHECK_FUNCS(fork fstat matherr mktime pipe strftime tsearch wait) CF_FUNC_GETTIME ### Checks for libraries. diff --git a/error.c b/error.c index 8de7d2a..5c8a416 100644 --- a/error.c +++ b/error.c @@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991. ********************************************/ /* - * $MawkId: error.c,v 1.29 2024/12/11 21:57:28 tom Exp $ + * $MawkId: error.c,v 1.30 2024/12/13 23:40:55 tom Exp $ */ #define Visible_CELL @@ -190,7 +190,7 @@ errmsg(int errnum, const char *format, ...) #if OPT_TRACE > 0 va_start(args, format); - Trace("\n?? errmsg \n"); + Trace("\n?? errmsg: "); TraceVA(format, args); Trace("\n"); va_end(args); diff --git a/files.c b/files.c index 304991b..c1fe2d0 100644 --- a/files.c +++ b/files.c @@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991. ********************************************/ /* - * $MawkId: files.c,v 1.37 2024/11/11 20:55:25 tom Exp $ + * $MawkId: files.c,v 1.40 2024/12/14 01:35:10 tom Exp $ */ #define Visible_STRING @@ -41,6 +41,11 @@ the GNU General Public License, version 2, 1991. #define CLOSE_ON_EXEC(fd) ioctl(fd, FIOCLEX, (PTR) 0) #endif +#ifdef HAVE_FSTAT +#include +#include +#endif + /* We store dynamically created files on a linked linear list with move to the front (big surprise) */ @@ -635,6 +640,15 @@ tfopen(const char *name, const char *mode) FILE *retval = fopen(name, mode); if (retval) { +#ifdef HAVE_FSTAT + struct stat sb; + int fd = fileno(retval); + if (fstat(fd, &sb) != -1 && (sb.st_mode & S_IFMT) == S_IFDIR) { + fclose(retval); + retval = NULL; + errno = EISDIR; + } else +#endif /* HAVE_FSTAT */ if (isatty(fileno(retval))) setbuf(retval, (char *) 0); else { diff --git a/fin.c b/fin.c index 59f2178..e13ae6c 100644 --- a/fin.c +++ b/fin.c @@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991. ********************************************/ /* - * $MawkId: fin.c,v 1.57 2024/09/05 17:38:30 tom Exp $ + * $MawkId: fin.c,v 1.60 2024/12/14 01:35:23 tom Exp $ */ #define Visible_CELL @@ -32,6 +32,11 @@ the GNU General Public License, version 2, 1991. #include #endif +#ifdef HAVE_FSTAT +#include +#include +#endif + /* This file handles input files. Opening, closing, buffering and (most important) splitting files into records, FINgets(). @@ -125,8 +130,17 @@ FINopen(char *filename, int main_flag) setmode(0, O_BINARY); #endif result = FINdopen(0, main_flag); - } else if ((fd = open(filename, oflag, 0)) != -1) { - result = FINdopen(fd, main_flag); + } else { + if ((fd = open(filename, oflag, 0)) != -1) { +#ifdef HAVE_FSTAT + struct stat sb; + if (fstat(fd, &sb) != -1 && (sb.st_mode & S_IFMT) == S_IFDIR) { + close(fd); + errno = EISDIR; + } else +#endif /* HAVE_FSTAT */ + result = FINdopen(fd, main_flag); + } } return result; } diff --git a/package/debian/changelog b/package/debian/changelog index 55112da..e6cb56b 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,3 +1,9 @@ +mawk-cur (1.3.4-20241213) unstable; urgency=low + + * maintenance updates + + -- Thomas E. Dickey Fri, 13 Dec 2024 20:01:15 -0500 + mawk-cur (1.3.4-20241212) unstable; urgency=low * maintenance updates diff --git a/package/freebsd/Makefile b/package/freebsd/Makefile index 28abe18..442716c 100644 --- a/package/freebsd/Makefile +++ b/package/freebsd/Makefile @@ -2,7 +2,7 @@ # $FreeBSD: head/lang/mawk/Makefile 516890 2019-11-06 14:17:48Z wen $ PORTNAME= mawk -DISTVERSION= 1.3.4.20241212 +DISTVERSION= 1.3.4.20241213 CATEGORIES= lang MASTER_SITES= https://invisible-island.net/archives/${PORTNAME}/ \ https://invisible-mirror.net/archives/${PORTNAME}/ diff --git a/package/mawk.spec b/package/mawk.spec index 9167d29..f8d5187 100644 --- a/package/mawk.spec +++ b/package/mawk.spec @@ -1,9 +1,9 @@ Summary: mawk - pattern scanning and text processing language %global AppProgram mawk %global AppVersion 1.3.4 -%global AppPatched 20241212 +%global AppPatched 20241213 %global MySite https://invisible-island.net -# $MawkId: mawk.spec,v 1.134 2024/12/13 00:44:41 tom Exp $ +# $MawkId: mawk.spec,v 1.135 2024/12/14 01:01:15 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: %{AppPatched} diff --git a/patchlev.h b/patchlev.h index c7b677c..08014c5 100644 --- a/patchlev.h +++ b/patchlev.h @@ -11,9 +11,9 @@ the GNU General Public License, version 2, 1991. */ /* - * $MawkId: patchlev.h,v 1.161 2024/12/13 00:44:41 tom Exp $ + * $MawkId: patchlev.h,v 1.162 2024/12/14 01:01:15 tom Exp $ */ #define PATCH_BASE 1 #define PATCH_LEVEL 3 #define PATCH_STRING ".4" -#define DATE_STRING "20241212" +#define DATE_STRING "20241213"