Subject: bin/12098: m4 MAXSTR too small for sendmail-8.12.0.
To: None <gnats-bugs@gnats.netbsd.org>
From: Lars-Johan Liman <liman@sunet.se>
List: netbsd-bugs
Date: 02/01/2001 06:59:20
>Number:         12098
>Category:       bin
>Synopsis:       m4 string size too small.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 01 07:02:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Lars-Johan Liman
>Release:        1.5E (September 19, 2000?)
>Organization:
#----------------------------------------------------------------------
# Lars-Johan Liman		! E-mail: liman@autonomica.se
# Senior Systems Specialist     ! HTTP  : //www.autonomica.se/
# Autonomica AB, Stockholm 	! Voice : +46 8 - 615 85 72
#----------------------------------------------------------------------
>Environment:
	
System: NetBSD naptop.autonomica.se 1.5E NetBSD 1.5E (FLAPTOP) #0: Wed Sep 20 22:22:54 MEST 2000 liman@flaptop.pilsnet.sunet.se:/usr/src/sys/arch/i386/compile/FLAPTOP i386

m4:
/*      $NetBSD: main.c,v 1.23 1999/08/16 02:49:20 enami Exp $  */
/*      $NetBSD: mdef.h,v 1.8 1997/12/02 22:34:04 cgd Exp $     */

>Description:
	Sendmail as of 8.12.0 uses rather extreme definitions in its
	m4 scripts. The length of them can exceed the current NetBSD
	maximum of 512 bytes. Sendmail installation process tests that
	the m4 fulfills its requirements. This test fails for 512 byte
	m4.
>How-To-Repeat:
	Execute the following test (stolen and modified from the
	sendmail distribution - please handle politically correct).

#!/bin/sh

# Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
#       All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
#       $Id: find_m4.sh,v 8.13 2001/01/23 01:47:45 gshapiro Exp $
#

# Test m4


test="ifdef(\`pushdef', \`',
\`errprint(\`You need a newer version of M4, at least as new as System V or GNU')
include(NoSuchFile)')
define(\`BadNumber', \`10')
ifdef(\`BadNumber', \`',
\`errprint(\`This version of m4 is broken: trailing zero problem')
include(NoSuchFile)')
define(\`LongList', \` assert.c debug.c exc.c heap.c match.c rpool.c strdup.c strerror.c strl.c clrerr.c fclose.c feof.c ferror.c fflush.c fget.c fpos.c findfp.c flags.c fopen.c fprintf.c fpurge.c fput.c fread.c fscanf.c fseek.c fvwrite.c fwalk.c fwrite.c get.c makebuf.c put.c refill.c rewind.c rget.c setvbuf.c smstdio.c snprintf.c sscanf.c stdio.c strio.c syslogio.c ungetc.c vasprintf.c vfprintf.c vfscanf.c vprintf.c vsnprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c stringf.c xtrap.c strto.c test.c path.c strcasecmp.c signal.c clock.c config.c shm.c ')
define(\`SameList', \`substr(LongList, 0, index(LongList, \`.'))\`'substr(LongList, index(LongList, \`.'))')
ifelse(len(LongList), len(SameList), \`',
\`errprint(\`This version of m4 is broken: length problem')
include(NoSuchFile)')"

(echo "$test" | ./m4) 2>&1 | grep -v NoSuchFile

exit 0

>Fix:

	The following patch seems to do the trick:

*** /usr/src/usr.bin/m4/mdef.h	Tue Dec  2 23:34:04 1997
--- mdef.h	Thu Feb  1 15:31:04 2001
***************
*** 98,107 ****
  #define EOS             (char) 0
  #define MAXINP          10              /* maximum include files   */
  #define MAXOUT          10              /* maximum # of diversions */
! #define MAXSTR          512             /* maximum size of string  */
! #define BUFSIZE         4096            /* size of pushback buffer */
! #define STACKMAX        1024            /* size of call stack      */
! #define STRSPMAX        4096            /* size of string space    */
  #define MAXTOK          MAXSTR          /* maximum chars in a tokn */
  #define HASHSIZE        199             /* maximum size of hashtab */
  #define MAXCCHARS	5		/* max size of comment/quote delim */
--- 98,107 ----
  #define EOS             (char) 0
  #define MAXINP          10              /* maximum include files   */
  #define MAXOUT          10              /* maximum # of diversions */
! #define MAXSTR          4096             /* maximum size of string  */
! #define BUFSIZE         8192            /* size of pushback buffer */
! #define STACKMAX        2048            /* size of call stack      */
! #define STRSPMAX        8192            /* size of string space    */
  #define MAXTOK          MAXSTR          /* maximum chars in a tokn */
  #define HASHSIZE        199             /* maximum size of hashtab */
  #define MAXCCHARS	5		/* max size of comment/quote delim */

>Release-Note:
>Audit-Trail:
>Unformatted: