Mercurial > illumos > illumos-gate
changeset 12967:1e73c8f5a88b
4691240 m4 -H0 causes m4 to crash
author | Rich Burridge <rich.burridge@oracle.com> |
---|---|
date | Thu, 29 Jul 2010 08:59:51 -0700 |
parents | 0d2f176e1e5e |
children | ed781b340472 |
files | usr/src/cmd/sgs/m4/common/m4.c usr/src/cmd/sgs/m4/common/m4.h usr/src/cmd/sgs/m4/common/m4ext.c |
diffstat | 3 files changed, 33 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/sgs/m4/common/m4.c Thu Jul 29 12:37:20 2010 +0530 +++ b/usr/src/cmd/sgs/m4/common/m4.c Thu Jul 29 08:59:51 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <signal.h> #include <unistd.h> #include <fcntl.h> @@ -344,6 +341,9 @@ case 'B': chkspace(&arg, xargc, xargv); bufsize = atoi(&arg[2]); + if (bufsize <= 0) { + bufsize = DEF_BUFSIZE; + } break; case 'D': initalloc(); @@ -363,14 +363,23 @@ case 'H': chkspace(&arg, xargc, xargv); hshsize = atoi(&arg[2]); + if (hshsize <= 0) { + hshsize = DEF_HSHSIZE; + } break; case 'S': chkspace(&arg, xargc, xargv); stksize = atoi(&arg[2]); + if (stksize <= 0) { + stksize = DEF_STKSIZE; + } break; case 'T': chkspace(&arg, xargc, xargv); toksize = atoi(&arg[2]); + if (toksize <= 0) { + toksize = DEF_TOKSIZE; + } break; case 'U': initalloc();
--- a/usr/src/cmd/sgs/m4/common/m4.h Thu Jul 29 12:37:20 2010 +0530 +++ b/usr/src/cmd/sgs/m4/common/m4.h Thu Jul 29 08:59:51 2010 -0700 @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -24,11 +23,11 @@ /* - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +#ifndef _M4_H +#define _M4_H #include <ctype.h> #include <stdio.h> @@ -47,6 +46,12 @@ #define OK 0 #define NOT_OK 1 +/* Used in m4.c and m4ext.c */ +#define DEF_HSHSIZE 199 /* default hash table size (prime). */ +#define DEF_BUFSIZE 4096 /* default pushback & arg text buffers size */ +#define DEF_STKSIZE 100 /* default call stack size */ +#define DEF_TOKSIZE 512 /* default token buffer size */ + #define BUILTIN 0x40000000 #define INVALID_CHAR 0x80000000 #define builtin(x) ((x) | BUILTIN) @@ -181,3 +186,5 @@ *op++ = (c); \ else \ error2(gettext("more than %d chars of argument text"), bufsize) + +#endif /* _M4_H */
--- a/usr/src/cmd/sgs/m4/common/m4ext.c Thu Jul 29 12:37:20 2010 +0530 +++ b/usr/src/cmd/sgs/m4/common/m4ext.c Thu Jul 29 08:59:51 2010 -0700 @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -24,20 +23,17 @@ /* - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "m4.h" /* storage params */ -int hshsize = 199; /* hash table size (prime) */ -int bufsize = 4096; /* pushback & arg text buffers */ -int stksize = 100; /* call stack */ -int toksize = 512; /* biggest word ([a-z_][a-z0-9_]*) */ +int hshsize = DEF_HSHSIZE; /* hash table size (prime) */ +int bufsize = DEF_BUFSIZE; /* pushback & arg text buffers */ +int stksize = DEF_STKSIZE; /* call stack */ +int toksize = DEF_TOKSIZE; /* biggest word ([a-z_][a-z0-9_]*) */ /* pushback buffer */