Subject: Missing initializer in ntpd.c and sendmail/Makefile.m4 cleanup (#225) Index: new/ntp/ntpd.c,usr.lib/sendmail/src/Makefile.m4 2.11BSD Description: When sysctl(3) was used to retrieve the kernel clock frequency the size variable was not initialized. The call could randomly fail depending on the contents of the stack call frame. In sendmail/src/Makefile.m4 the Version.c and version.c files were being used inconsistently due to sccs not being used. Repeat-By: ntpd: depending on the contents of the stack you will see that ntpd logs a sysctl() error when fetching the clockinfo structure from the kernel. sendmail: do a 'make install' without first doing a 'make'. Observe that Version.c is not compiled with the rest of the sources but is instead only compiled after the string extraction has finished. Fix: The change to ntpd.c is minor - adding an initialization step before the retrieval of the kernel clockinfo structure. Sendmail's Makefile has been a mess for years - this is an attempt to clean it up somewhat. The main problem is that 'm4SCCS' is not defined and thus the Version.c dependency is never included and the wrong '[V]version.c' is included in the build. SCCS is not used in the present system (it is present but the usability is unknown). To apply this patch cut where indicated and save to a file (/tmp/foo). Then: patch -p0 < /tmp/foo cd /usr/src/usr.lib/sendmail/src m4 < Makefile.m4 > Makefile make install /usr/lib/sendmail -bz make clean then kill the currently running sendmail process and restart the sendmail daemon. cd /usr/src/new/ntp make make install make clean if you are running the ntpd process you will need to kill the current ntpd and restart it. ====================cut here==================== *** /usr/src/new/ntp/ntpd.c.old Fri Jan 27 17:41:02 1995 --- /usr/src/new/ntp/ntpd.c Tue Jan 31 20:36:48 1995 *************** *** 1,9 **** #if !defined(lint) && defined(DOSCCS) ! static char *rcsid = "$Source: /usr/src/new/ntp/ntpd.c,v $ $Revision: 3.4.1.10 $ $Date: 95/01/27 17:20:17 $"; #endif lint /* * $Log: ntpd.c,v $ * Revision 3.4.1.10 95/01/27 17:20:17 sms * 2.11BSD - remove SETTICKADJ from ntpd.c. This was done for several reasons: * 1) tickadj does not (and never has) existed, 2) this is an old version and --- 1,12 ---- #if !defined(lint) && defined(DOSCCS) ! static char *rcsid = "$Source: /usr/src/new/ntp/ntpd.c,v $ $Revision: 3.4.1.11 $ $Date: 95/01/31 20:35:17 $"; #endif lint /* * $Log: ntpd.c,v $ + * Revision 3.4.1.11 95/01/31 20:35:17 sms + * Fix missing initializer before calling sysctl(). + * * Revision 3.4.1.10 95/01/27 17:20:17 sms * 2.11BSD - remove SETTICKADJ from ntpd.c. This was done for several reasons: * 1) tickadj does not (and never has) existed, 2) this is an old version and *************** *** 1032,1037 **** --- 1035,1041 ---- mib[0] = CTL_KERN; mib[1] = KERN_CLOCKRATE; + size = sizeof (struct clockinfo); if (sysctl(mib, 2, &cinfo, &size, NULL, 0) < 0) { syslog(LOG_ERR, "sysctl() for kern.clockrate: %m\n"); *** /usr/src/usr.lib/sendmail/src/Makefile.m4.old Fri Jul 15 15:47:38 1994 --- /usr/src/usr.lib/sendmail/src/Makefile.m4 Mon Jan 30 21:16:08 1995 *************** *** 7,13 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile.m4 5.10.1 (2.11BSD GTE) 7/15/94 # # # SENDMAIL Makefile. --- 7,13 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile.m4 5.10.2 (2.11BSD GTE) 1/30/95 # # # SENDMAIL Makefile. *************** *** 28,34 **** stats.o daemon.o usersmtp.o srvrsmtp.o queue.o \ macro.o util.o clock.o trace.o envelope.o OBJS2= sysexits.o arpadate.o convtime.o ctime.o ! OBJS= $(OBJS1) $(OBJS2) $(EXTRACT) str.o SBASE= conf.o collect.o parseaddr.o alias.o deliver.o headers.o \ recipient.o srvrsmtp.o queue.o util.o \ --- 28,34 ---- stats.o daemon.o usersmtp.o srvrsmtp.o queue.o \ macro.o util.o clock.o trace.o envelope.o OBJS2= sysexits.o arpadate.o convtime.o ctime.o ! OBJS= $(OBJS1) $(OBJS2) $(EXTRACT) Version.o str.o SBASE= conf.o collect.o parseaddr.o alias.o deliver.o headers.o \ recipient.o srvrsmtp.o queue.o util.o \ *************** *** 37,49 **** SOV1= main.o readcf.o macro.o SOV2= daemon.o savemail.o usersmtp.o err.o clock.o stats.o trace.o stab.o ! SRCS1= conf.h sendmail.h \ conf.c deliver.c main.c parseaddr.c err.c alias.c savemail.c \ ! sysexits.c util.c arpadate.c version.c collect.c \ macro.c headers.c readcf.c stab.c recipient.c stats.c daemon.c \ ! usersmtp.c srvrsmtp.c queue.c clock.c trace.c envelope.c ! SRCS2= TODO convtime.c ctime.c ! SRCS= Version.c $(SRCS1) $(SRCS2) ALL= sendmail ctimed O= -O --- 37,49 ---- SOV1= main.o readcf.o macro.o SOV2= daemon.o savemail.o usersmtp.o err.o clock.o stats.o trace.o stab.o ! SRCS= \ conf.c deliver.c main.c parseaddr.c err.c alias.c savemail.c \ ! sysexits.c util.c arpadate.c collect.c \ macro.c headers.c readcf.c stab.c recipient.c stats.c daemon.c \ ! usersmtp.c srvrsmtp.c queue.c clock.c trace.c envelope.c \ ! convtime.c ctime.c Version.c ! ALL= sendmail ctimed O= -O *************** *** 55,66 **** XREF= ctags -x INSTALL=install -c -s -o root - GET= sccs get - DELTA= sccs delta - WHAT= what - PRT= sccs prt - REL= - ROOT= root OBJMODE=755 --- 55,60 ---- *************** *** 69,86 **** all: $(ALL) ! sendmail: $(OBJS) Version.o ld $(SEPFLAG) $(COPTS) /lib/crt0.o -o sendmail \ -Z $(SOV1) -Z $(SOV2) -Y $(SBASE) $(LIBS) -lc chmod $(OBJMODE) sendmail ! size sendmail; ls -l sendmail; ifdef(`m4SCCS', `$(WHAT) < Version.o') ctimed: cc $(SEPFLAG) $(CFLAGS) ctimed.c -o ctimed install: all ! $(INSTALL) -m 4755 sendmail $(DESTDIR)/usr/lib ! chgrp kmem $(DESTDIR)/usr/lib/sendmail cp /dev/null $(DESTDIR)/usr/lib/sendmail.fc -if [ -s sendmail.sr ]; then \ install -c -o bin -m 644 sendmail.sr \ --- 63,79 ---- all: $(ALL) ! sendmail: $(OBJS) ld $(SEPFLAG) $(COPTS) /lib/crt0.o -o sendmail \ -Z $(SOV1) -Z $(SOV2) -Y $(SBASE) $(LIBS) -lc chmod $(OBJMODE) sendmail ! size sendmail; ls -l sendmail ctimed: cc $(SEPFLAG) $(CFLAGS) ctimed.c -o ctimed install: all ! $(INSTALL) -m 4755 -o root sendmail $(DESTDIR)/usr/lib cp /dev/null $(DESTDIR)/usr/lib/sendmail.fc -if [ -s sendmail.sr ]; then \ install -c -o bin -m 644 sendmail.sr \ *************** *** 88,122 **** fi install -c -s -o bin -m 0755 ctimed $(DESTDIR)/usr/lib/ctimed - version: newversion $(OBJS) Version.c - - newversion: - @rm -f SCCS/p.version.c version.c - @$(GET) $(REL) -e SCCS/s.version.c - @$(DELTA) -s SCCS/s.version.c - @$(GET) -t -s SCCS/s.version.c - - fullversion: $(OBJS) dumpVersion Version.o - - dumpVersion: - rm -f Version.c - - ifdef(`m4SCCS', - Version.c: version.c - @echo generating Version.c from version.c - @cp version.c Version.c - @chmod 644 Version.c - @echo "" >> Version.c - @echo "`# ifdef' COMMENT" >> Version.c - @$(PRT) SCCS/s.version.c >> Version.c - @echo "" >> Version.c - @echo "code versions:" >> Version.c - @echo "" >> Version.c - @$(WHAT) $(OBJS) >> Version.c - @echo "" >> Version.c - @echo "`#' endif COMMENT" >> Version.c - )dnl - $(OBJS1): sendmail.h $(OBJS): conf.h stats.o: mailstats.h --- 81,86 ---- *************** *** 129,143 **** clean: rm -f core sendmail rmail usersmtp uucp a.out XREF sendmail.cf ! rm -f sendmail.sr *.o ctimed strings - sources: $(SRCS) - - ifdef(`m4SCCS', - `$(SRCS1) $(SRCS2): - if test -d SCCS; then $(GET) $(REL) SCCS/s.$@; else touch $@; fi' - )dnl - print: $(SRCS) @ls -l | pr -h "sendmail directory" @$(XREF) *.c | pr -h "cross reference listing" --- 93,100 ---- clean: rm -f core sendmail rmail usersmtp uucp a.out XREF sendmail.cf ! rm -f sendmail.sr *.o ctimed strings version.c print: $(SRCS) @ls -l | pr -h "sendmail directory" @$(XREF) *.c | pr -h "cross reference listing" *************** *** 145,151 **** @pr Makefile *.m4 *.h *.[cs] lint: ! $(LINT) $(CCONFIG) $(SRCS1) str.o: strings ${XSTR} --- 102,108 ---- @pr Makefile *.m4 *.h *.[cs] lint: ! $(LINT) $(CCONFIG) $(SRCS) str.o: strings ${XSTR} *** /VERSION.old Mon Jan 30 20:45:58 1995 --- /VERSION Mon Jan 30 21:40:23 1995 *************** *** 1,4 **** ! Current Patch Level: 224 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 225 2.11 BSD ============ *** /usr/src/usr.lib/sendmail/src/Version.c.old Fri Jul 15 14:15:12 1994 --- /usr/src/usr.lib/sendmail/src/Version.c Tue Jan 31 20:33:55 1995 *************** *** 9,18 **** */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)version.c 5.51.1 (2.11BSD GTE) 7/15/94"; #endif ! char *Version = "5.51.1"; # ifdef COMMENT --- 9,18 ---- */ #if !defined(lint) && !defined(NOSCCS) ! static char SccsId[] = "@(#)version.c 5.52.1 (2.11BSD GTE) 7/15/94"; #endif ! char *Version = "5.52.1"; # ifdef COMMENT