From fc97bef41c5cbd252e79ba8f5f763120f728d1d5 Mon Sep 17 00:00:00 2001 From: drl7x Date: Thu, 17 Jan 2002 06:57:52 +0000 Subject: [PATCH] Fixed buffer overflow in cscanner.l --- Makefile.am | 26 +++++++++++++++++++++---- Makefile.binary.am | 9 ++++++++- Makefile.binary.in | 9 ++++++++- Makefile.in | 40 +++++++++++++++++++++++++++------------ configure | 4 ++-- configure.ac | 3 ++- configure.binary | 4 ++-- configure.binary.ac | 2 +- fixBinaryDist.sh | 7 +++++-- src/Headers/constants.h | 2 +- src/Makefile.am | 13 +++++++++---- src/Makefile.in | 16 +++++++++++----- src/cscanner.l | 17 ++++++++++------- src/flex.head | 2 -- src/flex.reset | 5 ----- test/Makefile | 9 +++++++-- test/null6.lcd | 2 +- test/tests2.5/newlint.lcd | 2 +- 18 files changed, 118 insertions(+), 54 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9112557..f4ea95c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,17 +29,35 @@ AUTOMAKE_OPTIONS = 1.5 foreign binaryfixscript = ./fixBinaryDist.sh SUBDIRS = lib imports test doc src +binaryDir = bin +binaryDirFiles = $(binaryDir)/Makefile.am $(binaryDir)/Makefile.in + binaryBuiltFiles = Makefile.binary.am configure.binary.ac + #include these in case we're trying to build on a systems #without the bleeding edge versions of automake and autoconf binaryDerivedFiles = Makefile.binary.in configure.binary -EXTRA_DIST = $(binaryfixscript) $(binaryBuiltFiles) $(binaryDerivedFiles) preBuilt/Makefile.am preBuilt/Makefile.in +#try to remake these but don't stop if it fails. +configure.binary:configure.binary.ac + -autoconf -oconfigure.binary configure.binary.ac + +Makefile.binary.in:Makefile.binary.am + -automake Makefile.binary + +$(binaryDir)/Makefile.in: $(binaryDir)/Makefile.am + -automake $(binaryDir)/Makefile + +EXTRA_DIST = $(binaryfixscript) $(binaryBuiltFiles) $(binaryDerivedFiles) $(binaryDirFiles) + +preDist: $(binaryDir)/Makefile.in $(binaryDerivedFiles) -bindist: +bindist: $(binaryDerivedFiles) $(MAKE) - $(CP) src/splint preBuilt/splint - $(MAKE) -e dist dh_script=$(binaryfixscript) SUBDIRS="preBuilt lib imports doc" + $(RM) -f $(binaryDir)/splint + $(CP) src/splint $(binaryDir)/splint + $(MAKE) -e dist dh_script=$(binaryfixscript) SUBDIRS="$(binaryDir) lib imports doc" + $(MV) $(distdir).tar.gz $(distdir).`uname`.tgz dist-hook: cd $(distdir); pwd; $(dh_script) diff --git a/Makefile.binary.am b/Makefile.binary.am index 731b7ba..6392725 100644 --- a/Makefile.binary.am +++ b/Makefile.binary.am @@ -26,4 +26,11 @@ AUTOMAKE_OPTIONS = 1.5 foreign -SUBDIRS = preBuilt lib imports doc +binaryDir = bin + +SUBDIRS = $(binaryDir) lib imports doc + +all: config.h src/splint + +src/splint: $(binaryDir)/splint + ln -s ../$(binaryDir)/splint src/splint diff --git a/Makefile.binary.in b/Makefile.binary.in index 5eeb1c5..1ad55bf 100644 --- a/Makefile.binary.in +++ b/Makefile.binary.in @@ -87,7 +87,9 @@ install_sh = @install_sh@ AUTOMAKE_OPTIONS = 1.5 foreign -SUBDIRS = preBuilt lib imports doc +binaryDir = bin + +SUBDIRS = $(binaryDir) lib imports doc subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs @@ -408,6 +410,11 @@ uninstall-info: uninstall-info-recursive uninstall uninstall-am uninstall-info-am \ uninstall-info-recursive uninstall-recursive + +all: config.h src/splint + +src/splint: $(binaryDir)/splint + ln -s ../$(binaryDir)/splint src/splint # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/Makefile.in b/Makefile.in index 0db2368..ff51508 100644 --- a/Makefile.in +++ b/Makefile.in @@ -90,27 +90,31 @@ AUTOMAKE_OPTIONS = 1.5 foreign binaryfixscript = ./fixBinaryDist.sh SUBDIRS = lib imports test doc src +binaryDir = bin +binaryDirFiles = $(binaryDir)/Makefile.am $(binaryDir)/Makefile.in + binaryBuiltFiles = Makefile.binary.am configure.binary.ac + #include these in case we're trying to build on a systems #without the bleeding edge versions of automake and autoconf binaryDerivedFiles = Makefile.binary.in configure.binary -EXTRA_DIST = $(binaryfixscript) $(binaryBuiltFiles) $(binaryDerivedFiles) preBuilt/Makefile.am preBuilt/Makefile.in +EXTRA_DIST = $(binaryfixscript) $(binaryBuiltFiles) $(binaryDerivedFiles) $(binaryDirFiles) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = preBuilt/Makefile +CONFIG_CLEAN_FILES = DIST_SOURCES = RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive -DIST_COMMON = README ./stamp-h.in Makefile.am Makefile.in acinclude.m4 \ - aclocal.m4 config.hin config/config.guess config/config.sub \ - config/depcomp config/install-sh config/missing \ - config/mkinstalldirs configure configure.ac +DIST_COMMON = README ./stamp-h.in ChangeLog Makefile.am Makefile.in \ + acinclude.m4 aclocal.m4 config.hin config/config.guess \ + config/config.sub config/depcomp config/install-sh \ + config/missing config/mkinstalldirs configure configure.ac DIST_SUBDIRS = $(SUBDIRS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -156,8 +160,6 @@ $(srcdir)/./stamp-h.in: $(top_srcdir)/configure.ac $(ACLOCAL_M4) distclean-hdr: -rm -f config.h -preBuilt/Makefile: $(top_builddir)/config.status $(top_srcdir)/preBuilt/Makefile.in - cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd @@ -263,7 +265,7 @@ GZIP_ENV = --best distdir: $(DISTFILES) -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) mkdir $(distdir) - $(mkinstalldirs) $(distdir)/config $(distdir)/preBuilt + $(mkinstalldirs) $(distdir)/$(binaryDir) $(distdir)/config @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ @@ -421,10 +423,24 @@ uninstall-info: uninstall-info-recursive uninstall-info-recursive uninstall-recursive -bindist: +#try to remake these but don't stop if it fails. +configure.binary:configure.binary.ac + -autoconf -oconfigure.binary configure.binary.ac + +Makefile.binary.in:Makefile.binary.am + -automake Makefile.binary + +$(binaryDir)/Makefile.in: $(binaryDir)/Makefile.am + -automake $(binaryDir)/Makefile + +preDist: $(binaryDir)/Makefile.in $(binaryDerivedFiles) + +bindist: $(binaryDerivedFiles) $(MAKE) - $(CP) src/splint preBuilt/splint - $(MAKE) -e dist dh_script=$(binaryfixscript) SUBDIRS="preBuilt lib imports doc" + $(RM) -f $(binaryDir)/splint + $(CP) src/splint $(binaryDir)/splint + $(MAKE) -e dist dh_script=$(binaryfixscript) SUBDIRS="$(binaryDir) lib imports doc" + $(MV) $(distdir).tar.gz $(distdir).`uname`.tgz dist-hook: cd $(distdir); pwd; $(dh_script) diff --git a/configure b/configure index 5b86b6c..cbc0946 100755 --- a/configure +++ b/configure @@ -3173,7 +3173,7 @@ cat >>confdefs.h <confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -3500,7 +3500,7 @@ do "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "test/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "preBuilt/Makefile" ) CONFIG_FILES="$CONFIG_FILES preBuilt/Makefile" ;; + "bin/Makefile" ) CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;; *) { { echo "$as_me:3506: error: invalid argument: $ac_config_target" >&5 diff --git a/configure.ac b/configure.ac index 5a0c7b5..9800c71 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ dnl Process with autoconf to create a configure script -*- Autoconf -*- AC_PREREQ(2.50) + AC_INIT([Splint], [3.0.1.4], [splint-bug@splint.org], [splint]) dnl This MUST precede any other macro @@ -201,7 +202,7 @@ dnl test/tests2.2/Makefile dnl test/db1/Makefile]) AC_CONFIG_FILES([Makefile imports/Makefile lib/Makefile src/Makefile - test/Makefile doc/Makefile preBuilt/Makefile]) + test/Makefile doc/Makefile bin/Makefile]) AC_OUTPUT diff --git a/configure.binary b/configure.binary index 7bf8c6e..46e0446 100755 --- a/configure.binary +++ b/configure.binary @@ -3173,7 +3173,7 @@ cat >>confdefs.h <confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -3498,7 +3498,7 @@ do "imports/Makefile" ) CONFIG_FILES="$CONFIG_FILES imports/Makefile" ;; "lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "preBuilt/Makefile" ) CONFIG_FILES="$CONFIG_FILES preBuilt/Makefile" ;; + "bin/Makefile" ) CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;; *) { { echo "$as_me:3504: error: invalid argument: $ac_config_target" >&5 diff --git a/configure.binary.ac b/configure.binary.ac index 42a6546..9be0848 100644 --- a/configure.binary.ac +++ b/configure.binary.ac @@ -201,7 +201,7 @@ dnl test/tests2.2/Makefile dnl test/db1/Makefile]) AC_CONFIG_FILES([Makefile imports/Makefile lib/Makefile - doc/Makefile preBuilt/Makefile]) + doc/Makefile bin/Makefile]) AC_OUTPUT diff --git a/fixBinaryDist.sh b/fixBinaryDist.sh index eebc770..22e82f2 100755 --- a/fixBinaryDist.sh +++ b/fixBinaryDist.sh @@ -19,5 +19,8 @@ cp Makefile.binary.in Makefile.in #run these if possible... autoconf automake -mkdir src -ln -s ../preBuilt/splint src/splint +mkdir src || echo "COULD NOT MAKE src tar ball may be incorrect" +echo "Created this file because some versions of tar are too simple include this directory without it" > src/dummy + +# Need to do this in the makefile because the tar command in make dist wants to derefence symlinks +#ln -s ../bin/splint src/splint diff --git a/src/Headers/constants.h b/src/Headers/constants.h index f8be6c7..8c71980 100644 --- a/src/Headers/constants.h +++ b/src/Headers/constants.h @@ -70,7 +70,7 @@ # define LIBRARY_MARKER ";;; Splint Library " /*@constant int MAX_NAME_LENGTH=256; @*/ -# define MAX_NAME_LENGTH 256 +# define MAX_NAME_LENGTH 1024 /*@constant int MAX_LINE_LENGTH=1024; @*/ # define MAX_LINE_LENGTH 1024 diff --git a/src/Makefile.am b/src/Makefile.am index 6bedab6..558ff82 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -251,7 +251,7 @@ COMMONSRC = $(OVERFLOWCHSRC) $(CPPSRC) $(CSRC) $(CHECKSRC) $(GENERALSRC) \ ALLSRC = $(GRAMSRC) $(COMMONSRC) $(SPLINTSRC) $(DER_FILES) $(HEADERSRC) #files to run Splint on -LINTSRC = $(COMMONSRC) $(SPLINTSRC) +LINTSRC = $(COMMONSRC) $(SPLINTSRC) #ALLSRC = $(COMMONSRC) $(SPLINTSRC) $(DER_FILES) $(HEADERSRC) @@ -382,16 +382,21 @@ splintme: lintbuffercheck: ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude $(LINTSRC) $(LCLSRC) -dump lclint \ +forcehints -misplacedsharequal +showsourceloc -unrecogcomments \ - -supcounts -fcnuse -exportlocal -constuse -mts file -mts filerw +arraybounds +arrayboundsread +implictconstraint -dLINTBUFFERCHECK + -supcounts -fcnuse -exportlocal -constuse -mts file -mts filerw +bounds +boundsread +implictconstraint -dLINTBUFFERCHECK +binDir = bin -all: splint$(EXEEXT) +all: splint$(EXEEXT) ../$(top_builddir)/$(binDir)/splint$(EXEEXT) + +../$(top_builddir)/$(binDir)/splint$(EXEEXT): splint$(EXEEXT) + -$(RM) -f $(top_builddir)/$(binDir)/splint$(EXEEXT) + ln -s $(top_builddir)/src/splint$(EXEEXT) $(top_builddir)/$(binDir)/splint$(EXEEXT) up: -rm cgrammar.c llgrammar.c mtgrammar.c signature.c cscanner.c $(MAKE) clean -CLEANFILES = splint$(EXEEXT) +CLEANFILES = splint$(EXEEXT) ../$(top_builddir)/$(binDir)/splint$(EXEEXT) .c.o: @echo "Compiling "$<"..."; \ diff --git a/src/Makefile.in b/src/Makefile.in index 836fdd4..d0a64e4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -336,7 +336,7 @@ COMMONSRC = $(OVERFLOWCHSRC) $(CPPSRC) $(CSRC) $(CHECKSRC) $(GENERALSRC) \ ALLSRC = $(GRAMSRC) $(COMMONSRC) $(SPLINTSRC) $(DER_FILES) $(HEADERSRC) #files to run Splint on -LINTSRC = $(COMMONSRC) $(SPLINTSRC) +LINTSRC = $(COMMONSRC) $(SPLINTSRC) #ALLSRC = $(COMMONSRC) $(SPLINTSRC) $(DER_FILES) $(HEADERSRC) @@ -358,7 +358,9 @@ BUILT_SOURCES = Headers/signature_gen.h Headers/cgrammar_tokens.h \ CHECKS = $(subst .c,.check,$(splint_SOURCES)) -CLEANFILES = splint$(EXEEXT) +binDir = bin + +CLEANFILES = splint$(EXEEXT) ../$(top_builddir)/$(binDir)/splint$(EXEEXT) subdir = src mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h @@ -579,7 +581,7 @@ CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CFLAGS = @CFLAGS@ DIST_SOURCES = $(lcl_SOURCES) $(splint_SOURCES) -DIST_COMMON = ChangeLog Makefile.am Makefile.in +DIST_COMMON = Makefile.am Makefile.in SOURCES = $(lcl_SOURCES) $(splint_SOURCES) all: $(BUILT_SOURCES) @@ -1056,9 +1058,13 @@ splintme: lintbuffercheck: ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude $(LINTSRC) $(LCLSRC) -dump lclint \ +forcehints -misplacedsharequal +showsourceloc -unrecogcomments \ - -supcounts -fcnuse -exportlocal -constuse -mts file -mts filerw +arraybounds +arrayboundsread +implictconstraint -dLINTBUFFERCHECK + -supcounts -fcnuse -exportlocal -constuse -mts file -mts filerw +bounds +boundsread +implictconstraint -dLINTBUFFERCHECK + +all: splint$(EXEEXT) ../$(top_builddir)/$(binDir)/splint$(EXEEXT) -all: splint$(EXEEXT) +../$(top_builddir)/$(binDir)/splint$(EXEEXT): splint$(EXEEXT) + -$(RM) -f $(top_builddir)/$(binDir)/splint$(EXEEXT) + ln -s $(top_builddir)/src/splint$(EXEEXT) $(top_builddir)/$(binDir)/splint$(EXEEXT) up: -rm cgrammar.c llgrammar.c mtgrammar.c signature.c cscanner.c diff --git a/src/cscanner.l b/src/cscanner.l index 6118aca..74a3779 100644 --- a/src/cscanner.l +++ b/src/cscanner.l @@ -1713,20 +1713,23 @@ static bool handleSpecial (char *yyt) char c; char *ol; cstring olc; - - strcpy (l, yyt + 1); - /* Need to safe original l for deallocating. */ - ol = l; + int len_yyt; + + len_yyt = strlen (yyt +1) ; - l += strlen (yyt) - 1; + l = mstring_copy (yyt + 1); while ((c = char_fromInt (lminput ())) != '\n' && c != '\0') { - *l++ = c; + l = mstring_append(l, c); } - *l = '\0'; + /* Need to safe original l for deallocating. */ + ol = l; + + l += strlen (l); + olc = cstring_fromChars (ol); if (cstring_equalPrefixLit (olc, "pragma")) diff --git a/src/flex.head b/src/flex.head index 19b59cc..c73de11 100644 --- a/src/flex.head +++ b/src/flex.head @@ -54,8 +54,6 @@ /*@-retvalother@*/ /*drl added 11/27/2001*/ -/*@-arraybounds@*/ -/*@-arrayboundsread@*/ # ifdef __LCLINT__ diff --git a/src/flex.reset b/src/flex.reset index f0b2b28..0ef79de 100644 --- a/src/flex.reset +++ b/src/flex.reset @@ -50,11 +50,6 @@ /*@=redecl@*/ /*@=retvalother@*/ - -/*drl added 11/27/2001*/ -/*@=arraybounds@*/ -/*@=arrayboundsread@*/ - # ifdef OSF # define __GNUC__ # endif diff --git a/test/Makefile b/test/Makefile index fe8b0b3..a68f22a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -80,7 +80,7 @@ MV = mv OBJEXT = o PACKAGE = splint RM = rm -VERSION = 3.0.1.2 +VERSION = 3.0.1.4 am__include = include am__quote = install_sh = /net/af9/drl7x/reTmp/LCLintDev/config/install-sh @@ -114,7 +114,7 @@ SPLINTRNEST = $(SPLINTRNNEST) -exportlocal +debugfcnconstraint UNITTESTS = \ help \ abstptr abstract alias alttypes ansireserved argorder \ - args blocks break cases cast charlit clauses commentchar compdestroy \ + args arraydims blocks break cases cast charlit clauses commentchar compdestroy \ constannot controldepth csyntax czechnames czechoslovaknames deadparam \ decl enum exports external fields flags forbody format freearray \ funcpointer functionmacro glob globals impabstract info init inparam internal iter keep libs \ @@ -1028,6 +1028,11 @@ argorder: args: -$(SPLINTR) args -noeffect -expect 12 +.PHONY: arraydims +arraydims: + -$(SPLINTR) arraydims.c -varuse -expect 2 + -$(SPLINTR) arraydims.c -initsize -varuse + .PHONY: blocks blocks: -$(SPLINTR) blocks.c -expect 4 diff --git a/test/null6.lcd b/test/null6.lcd index 4484442..cd94c56 100644 --- a/test/null6.lcd +++ b/test/null6.lcd @@ -1,5 +1,5 @@ ;;; Splint Library null6.lcd -;;Splint 3.0.1.2 --- 14 Jan 2002 +;;Splint 3.0.1.4 --- 17 Jan 2002 ;;lib:298 ;;ctTable 0 u-2 19 38 diff --git a/test/tests2.5/newlint.lcd b/test/tests2.5/newlint.lcd index 07892eb..72bf5aa 100644 --- a/test/tests2.5/newlint.lcd +++ b/test/tests2.5/newlint.lcd @@ -1,5 +1,5 @@ ;;; Splint Library newlint.lcd -;;Splint 3.0.1.2 --- 14 Jan 2002 +;;Splint 3.0.1.4 --- 17 Jan 2002 ;;lib:298 ;;ctTable 0 u-2 19 38 -- 2.45.2