snapshot of project "mawk", label t20231126

This commit is contained in:
Thomas E. Dickey 2023-11-27 01:03:52 +00:00
parent a946bf06a6
commit b99a95a8df
No known key found for this signature in database
GPG Key ID: CC2AF4472167BE03
13 changed files with 87 additions and 37 deletions

11
CHANGES
View File

@ -1,4 +1,13 @@
-- $MawkId: CHANGES,v 1.366 2023/11/02 23:27:07 tom Exp $
-- $MawkId: CHANGES,v 1.369 2023/11/26 23:51:54 tom Exp $
20231126
+ fix a couple of problems reported by Coverity:
+ modify cell_destroy() to set the string pointer to NULL if zfree()
might have freed it.
+ replace a couple of strcpy's with loop.
+ eliminate a fixed-size array in re_cmpl.c
+ change casts in strftime() and srand() to avoid truncation on 64-bit
machines (report by John Naman).
20231102
+ environment-fixes for building with Solaris 10.

View File

@ -1,4 +1,4 @@
MANIFEST for mawk, version t20231102
MANIFEST for mawk, version t20231126
--------------------------------------------------------------------------------
MANIFEST this file
ACKNOWLEDGMENT acknowledgements

6
aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
dnl $MawkId: aclocal.m4,v 1.108 2023/09/06 22:55:27 tom Exp $
dnl $MawkId: aclocal.m4,v 1.109 2023/11/23 11:40:35 tom Exp $
dnl custom mawk macros for autoconf
dnl
dnl The symbols beginning "CF_MAWK_" were originally written by Mike Brennan,
@ -2496,7 +2496,7 @@ if test "$with_dmalloc" = yes ; then
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_MAN2HTML version: 12 updated: 2021/01/03 18:30:50
dnl CF_WITH_MAN2HTML version: 13 updated: 2023/11/23 06:40:35
dnl ----------------
dnl Check for man2html and groff. Prefer man2html over groff, but use groff
dnl as a fallback. See
@ -2538,7 +2538,7 @@ esac
AC_MSG_CHECKING(for program to convert manpage to html)
AC_ARG_WITH(man2html,
[ --with-man2html=XXX use XXX rather than groff],
[[ --with-man2html[=XXX] use XXX rather than groff]],
[cf_man2html=$withval],
[cf_man2html=$cf_man2html])

View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: bi_funct.c,v 1.123 2023/08/04 08:11:23 Miguel.Pineiro Exp $
* $MawkId: bi_funct.c,v 1.125 2023/11/26 10:00:47 tom Exp $
*/
#include <mawk.h>
@ -478,7 +478,7 @@ bi_strftime(CELL *sp)
if (n_args > 1) {
if (sp[1].type != C_DOUBLE)
cast1_to_d(sp + 1);
rawtime = d_to_i(sp[1].dval);
rawtime = d_to_l(sp[1].dval);
} else {
time(&rawtime);
}
@ -793,7 +793,7 @@ bi_srand(CELL *sp)
}
#ifdef USE_SYSTEM_SRAND
seed = d_to_i(cseed.dval);
seed = d_to_l(cseed.dval);
mawk_srand((unsigned) seed);
#else
/* The old seed is now in *sp ; move the value in cseed to
@ -804,7 +804,7 @@ bi_srand(CELL *sp)
cast1_to_d(&c);
seed = ((c.type == C_DOUBLE)
? (long) (d_to_i(c.dval) & M) % M + 1
? (long) (d_to_l(c.dval) & M) % M + 1
: (long) hash(string(&c)->str) % M + 1);
if (seed == M)
seed = M - 1;

2
configure vendored
View File

@ -711,7 +711,7 @@ Miscellaneous options
--disable-echo do not display "compiling" commands
--enable-warnings test: turn on gcc compiler warnings
--enable-stdnoreturn enable C11 _Noreturn feature for diagnostics
--with-man2html=XXX use XXX rather than groff
--with-man2html[=XXX] use XXX rather than groff
--without-builtin-regex do not use mawk's own regular-expressions engine
--enable-builtin-srand use mawk's own srand/rand functions
--disable-init-srand suppress automatic initialization of random numbers

View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: execute.c,v 1.52 2023/08/15 23:24:18 tom Exp $
* $MawkId: execute.c,v 1.54 2023/11/27 00:48:08 tom Exp $
*/
#include <mawk.h>
@ -108,7 +108,7 @@ execute(INST * cdp, /* code ptr, start execution here */
user defined functions */
{
static INST *restart_label; /* control flow label */
static CELL tc; /*useful temp */
static CELL tc; /* useful temp */
static CELL missing; /* no value (use zero) */
/* some useful temporaries */
@ -219,14 +219,18 @@ execute(INST * cdp, /* code ptr, start execution here */
case L_PUSHI:
/* put the contents of a local var on stack,
cdp->op holds the offset from the frame pointer */
inc_sp();
cellcpy(sp, fp + (cdp++)->op);
if (fp != NULL) {
inc_sp();
cellcpy(sp, fp + (cdp++)->op);
}
break;
case L_PUSHA:
/* put a local address on eval stack */
inc_sp();
sp->ptr = (PTR) (fp + (cdp++)->op);
if (fp != NULL) {
inc_sp();
sp->ptr = (PTR) (fp + (cdp++)->op);
}
break;
case F_PUSHI:
@ -1195,6 +1199,8 @@ execute(INST * cdp, /* code ptr, start execution here */
} else {
set_field0(p, len);
cdp = restart_label;
if (cdp == NULL)
bozo("empty restart-label");
rt_nr++;
rt_fnr++;
}
@ -1218,6 +1224,8 @@ execute(INST * cdp, /* code ptr, start execution here */
} else {
set_field0(p, len);
cdp = restart_label;
if (cdp == NULL)
bozo("empty restart-label");
if (TEST2(NR) != TWO_DOUBLES)
cast2_to_d(NR);

6
mawk.h
View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: mawk.h,v 1.65 2023/08/16 23:32:10 tom Exp $
* $MawkId: mawk.h,v 1.67 2023/11/27 01:03:52 tom Exp $
*/
/* mawk.h */
@ -127,7 +127,11 @@ extern unsigned rt_nr, rt_fnr; /* ditto */
do { \
if ( (cp)->type >= C_STRING && \
(cp)->type <= C_MBSTRN ) { \
unsigned final = string(cp)->ref_cnt; \
free_STRING(string(cp)); \
if (final <= 1) { \
(cp)->ptr = NULL; \
} \
} \
} while (0)
#endif

View File

@ -1,3 +1,9 @@
mawk-cur (1.3.4-20231126) unstable; urgency=low
* maintenance updates
-- Thomas E. Dickey <dickey@invisible-island.net> Sun, 26 Nov 2023 04:58:54 -0500
mawk-cur (1.3.4-20231102) unstable; urgency=low
* maintenance updates

View File

@ -2,7 +2,7 @@
# $FreeBSD: head/lang/mawk/Makefile 516890 2019-11-06 14:17:48Z wen $
PORTNAME= mawk
DISTVERSION= 1.3.4.20231102
DISTVERSION= 1.3.4.20231126
CATEGORIES= lang
MASTER_SITES= https://invisible-island.net/archives/${PORTNAME}/ \
https://invisible-mirror.net/archives/${PORTNAME}/

View File

@ -1,9 +1,9 @@
Summary: mawk - pattern scanning and text processing language
%global AppProgram mawk
%global AppVersion 1.3.4
%global AppPatched 20231102
%global AppPatched 20231126
%global MySite https://invisible-island.net
# $MawkId: mawk.spec,v 1.114 2023/11/02 23:19:05 tom Exp $
# $MawkId: mawk.spec,v 1.115 2023/11/26 09:58:54 tom Exp $
Name: %{AppProgram}
Version: %{AppVersion}
Release: %{AppPatched}

View File

@ -11,9 +11,9 @@ the GNU General Public License, version 2, 1991.
*/
/*
* $MawkId: patchlev.h,v 1.141 2023/11/02 23:19:05 tom Exp $
* $MawkId: patchlev.h,v 1.142 2023/11/26 09:58:54 tom Exp $
*/
#define PATCH_BASE 1
#define PATCH_LEVEL 3
#define PATCH_STRING ".4"
#define DATE_STRING "20231102"
#define DATE_STRING "20231126"

14
print.c
View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: print.c,v 1.46 2023/07/29 23:44:55 tom Exp $
* $MawkId: print.c,v 1.48 2023/11/27 00:33:56 tom Exp $
*/
#include "mawk.h"
@ -31,6 +31,14 @@ the GNU General Public License, version 2, 1991.
#define SpliceFormat(n) if (n) splice = 1
#endif
#define CopySplice(dst,src) \
{ \
size_t pp; \
for (pp = 0; (pp < sizeof(dst) - 1) && (src[pp] != 0); ++pp) \
dst[pp] = src[pp]; \
dst[pp] = 0; \
}
#ifdef SHORT_INTS
#define MY_FMT xbuff /* format in xbuff */
#else
@ -602,7 +610,7 @@ do_printf(FILE *fp,
if (splice) {
/* need to splice in long modifier */
strcpy(xbuff, p);
CopySplice(xbuff, p);
if (l_flag < ELL_LIMIT) {
int k = (int) (q - p);
@ -946,7 +954,7 @@ do_sprintf(
if (splice) {
/* need to splice in long modifier */
strcpy(xbuff, p);
CopySplice(xbuff, p);
if (l_flag < ELL_LIMIT) {
int k = (int) (q - p);

View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: re_cmpl.c,v 1.34 2023/07/20 00:32:26 tom Exp $
* $MawkId: re_cmpl.c,v 1.35 2023/11/26 22:15:12 tom Exp $
*/
/* re_cmpl.c */
@ -156,13 +156,14 @@ re_destroy(PTR m)
*/
/* FIXME -- this function doesn't handle embedded nulls
split_buff[] and MAX_SPLIT are obsolete, but needed by this
function. Putting
them here is temporary until the rewrite to handle nulls.
split_buff is obsolete, but needed by this function.
Putting them here is temporary until the rewrite to handle nulls.
*/
#define MAX_SPLIT 256 /* handle up to 256 &'s as matched text */
static STRING *split_buff[MAX_SPLIT];
#define SPLIT_SIZE 256
static STRING **split_buff;
static size_t split_size;
static CELL *
REPL_compile(STRING * sval)
@ -173,8 +174,22 @@ REPL_compile(STRING * sval)
register char *r;
char *xbuff;
CELL *cp;
size_t limit = sval->len + 1;
q = xbuff = (char *) zmalloc(sval->len + 1);
if (limit > split_size) {
size_t new_size = limit + SPLIT_SIZE;
if (split_buff != NULL) {
size_t old_size = split_size;
split_buff = (STRING **) zrealloc(split_buff,
old_size * sizeof(STRING *),
new_size * sizeof(STRING *));
} else {
split_buff = (STRING **) zmalloc(new_size * sizeof(STRING *));
}
split_size = new_size;
}
q = xbuff = (char *) zmalloc(limit);
while (1) {
switch (*p) {
@ -234,10 +249,6 @@ REPL_compile(STRING * sval)
if (q > xbuff || count == 0)
split_buff[count++] = new_STRING(xbuff);
/* This will never happen */
if (count > MAX_SPLIT)
overflow("replacement pieces", MAX_SPLIT);
cp = ZMALLOC(CELL);
if (count == 1 && split_buff[0]) {
cp->type = C_REPL;
@ -256,7 +267,7 @@ REPL_compile(STRING * sval)
cp->type = C_REPLV;
cp->vcnt = count;
}
zfree(xbuff, sval->len + 1);
zfree(xbuff, limit);
return cp;
}
@ -480,5 +491,9 @@ re_leaks(void)
ZFREE(repl_list);
repl_list = p;
}
if (split_size != 0) {
zfree(split_buff, split_size * sizeof(STRING *));
}
}
#endif