diff --git a/MAINTAINERS b/MAINTAINERS index 7e6610f376e2..19222d702414 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18,6 +18,12 @@ However, this is not a 'big stick', it is an offer to help and a source of guidance. It does not override the communal nature of the tree. It is not a registry of 'turf' or private property. +*** +This list is prone to becoming stale quickly. The best way to find the recent +maintainer of a sub-system is to check recent logs for that directory or +sub-system. +*** + subsystem login notes ----------------------------- kqueue jmg Pre-commit review requested. Documentation Required. @@ -31,8 +37,6 @@ sys/security/audit rwatson Pre-commit review requested. ath(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org ahc(4) gibbs Pre-commit review requested. ahd(4) gibbs Pre-commit review requested. -PC Card imp Pre-commit review requested. -CardBus imp Pre-commit review requested. pci bus imp,jhb Pre-commit review requested. cdboot jhb Pre-commit review requested. pxeboot jhb Pre-commit review requested. @@ -66,8 +70,7 @@ net80211 adrian Pre-commit review requested, send to freebsd-wireless@freebsd.or nvi peter Try not to break it. libz peter Try not to break it. groff ru Recommends pre-commit review. -share/mk ru This is a vital component of the build system, so I - offer a pre-commit review for anything non-trivial. +share/mk imp, bapt, bdrewery, emaste, sjg Make is hard. ipfw ipfw Pre-commit review preferred. send to ipfw@freebsd.org drm rnoland Just keep me informed of changes, try not to break it. unifdef(1) fanf Pre-commit review requested. @@ -81,6 +84,7 @@ file obrien Insists to keep file blocked from other's unapproved contrib/bzip2 obrien Pre-commit review required. contrib/netbsd-tests freebsd-testing,ngie Pre-commit review requested. contrib/pjdfstest freebsd-testing,ngie Pre-commit review requested. +geom freebsd-geom@FreeBSD.org geom_concat pjd Pre-commit review preferred. geom_eli pjd Pre-commit review preferred. geom_gate pjd Pre-commit review preferred. @@ -92,16 +96,16 @@ geom_shsec pjd Pre-commit review preferred. geom_stripe pjd Pre-commit review preferred. geom_zero pjd Pre-commit review preferred. sbin/geom pjd Pre-commit review preferred. -zfs pjd Pre-commit review preferred. -nfs alfred Will be happy to review code, but not mandatory. -rpc.lockd alfred Will be happy to review code, but not mandatory. -truss alfred Will be happy to review code, but not mandatory. -rpc alfred Pre-commit review requested. +zfs freebsd-fs@FreeBSD.org +nfs freebsd-fs@FreeBSD.org, rmacklem is best for reviews. linux emul emulation Please discuss changes here. bs{diff,patch} cperciva Pre-commit review requested. portsnap cperciva Pre-commit review requested. freebsd-update cperciva Pre-commit review requested. openssl benl,jkim Pre-commit review requested. +sys/dev/usb hselasky If in doubt, ask. +sys/dev/sound/usb hselasky If in doubt, ask. +sys/compat/linuxkpi hselasky If in doubt, ask. sys/netgraph/bluetooth emax Pre-commit review preferred. lib/libbluetooth emax Pre-commit review preferred. lib/libsdp emax Pre-commit review preferred. diff --git a/Makefile.inc1 b/Makefile.inc1 index 2c79d96e9f2a..767387a114be 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -30,6 +30,8 @@ # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh) # WORLD_FLAGS= additional flags to pass to make(1) during buildworld # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel +# SUBDIR_OVERRIDE="list of dirs" to build rather than everything. +# All libraries and includes, and some build tools will still build. # # The intended user-driven targets are: @@ -59,7 +61,7 @@ # system here would require fine-grained ordering of all components based # on their dependencies. SRCDIR?= ${.CURDIR} -.if defined(SUBDIR_OVERRIDE) +.if !empty(SUBDIR_OVERRIDE) SUBDIR= ${SUBDIR_OVERRIDE} .else SUBDIR= lib libexec @@ -113,7 +115,6 @@ SUBDIR+= ${_DIR} .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121. .endif .endfor -.endif # We must do etc/ last as it hooks into building the man whatis file # by calling 'makedb' in share/man. This is only relevant for @@ -124,7 +125,10 @@ SUBDIR+=.WAIT .endif SUBDIR+=etc +.endif # !empty(SUBDIR_OVERRIDE) + .if defined(NOCLEAN) +.warning NOCLEAN option is deprecated. Use NO_CLEAN instead. NO_CLEAN= ${NOCLEAN} .endif .if defined(NO_CLEANDIR) @@ -394,6 +398,9 @@ TARGET_ABI= gnueabi .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++ +# XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes +# due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when +# building C++ files so this can come out if passing CXXFLAGS down is fixed. DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 .else TARGET_ABI?= unknown @@ -513,7 +520,7 @@ KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME} # Attempt to rebuild the entire system, with reasonable chance of # success, regardless of how old your existing system is. # -_worldtmp: +_worldtmp: .PHONY .if ${.CURDIR:C/[^,]//g} != "" # The m4 build of sendmail files doesn't like it if ',' is used # anywhere in the path of it's files. @@ -560,6 +567,16 @@ _worldtmp: mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ -p ${WORLDTMP}/usr/lib >/dev/null .endif +.if ${MK_LIB32} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${WORLDTMP}/usr >/dev/null +.if ${MK_DEBUG_FILES} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null +.endif +.endif .if ${MK_TESTS} != "no" mkdir -p ${WORLDTMP}${TESTSBASE} mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ @@ -620,8 +637,16 @@ _includes: @echo "--------------------------------------------------------------" @echo ">>> stage 4.1: building includes" @echo "--------------------------------------------------------------" +# Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need +# headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last. + ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \ + buildincludes + ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \ + installincludes +.if !empty(SUBDIR_OVERRIDE) && make(buildworld) ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks buildincludes ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks installincludes +.endif _libraries: @echo @echo "--------------------------------------------------------------" @@ -643,7 +668,7 @@ everything: @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${WMAKE} par-all .if defined(LIB32TMP) -build32: +build32: .PHONY @echo @echo "--------------------------------------------------------------" @echo ">>> stage 5.1: building 32 bit shim libraries" @@ -653,73 +678,76 @@ build32: -p ${LIB32TMP}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${LIB32TMP}/usr/include >/dev/null + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${LIB32TMP}/usr >/dev/null .if ${MK_DEBUG_FILES} != "no" mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ -p ${LIB32TMP}/usr/lib >/dev/null + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null .endif mkdir -p ${WORLDTMP} ln -sf ${.CURDIR}/sys ${WORLDTMP} .for _t in obj includes - cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t} - cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t} + ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t} + ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t} .if ${MK_CDDL} != "no" - cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t} + ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t} .endif - cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t} + ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t} .if ${MK_CRYPT} != "no" - cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t} + ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t} .endif .if ${MK_KERBEROS} != "no" - cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t} + ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t} .endif .endfor .for _dir in usr.bin/lex/lib - cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj + ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj .endfor .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic - cd ${.CURDIR}/${_dir}; \ + ${_+_}cd ${.CURDIR}/${_dir}; \ WORLDTMP=${WORLDTMP} \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ build-tools .endfor - cd ${.CURDIR}; \ + ${_+_}cd ${.CURDIR}; \ ${LIB32WMAKE} -f Makefile.inc1 libraries .for _t in obj depend all - cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \ + ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \ DIRPRFX=libexec/rtld-elf/ ${_t} - cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \ + ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \ DIRPRFX=usr.bin/ldd ${_t} .endfor -distribute32 install32: - cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} +distribute32 install32: .MAKE .PHONY + ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .if ${MK_CDDL} != "no" - cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} + ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif - cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} + ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .if ${MK_CRYPT} != "no" - cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} + ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif .if ${MK_KERBEROS} != "no" - cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} + ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif - cd ${.CURDIR}/libexec/rtld-elf; \ + ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//} - cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//} + ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \ + ${.TARGET:S/32$//} .endif WMAKE_TGTS= -.if !defined(SUBDIR_OVERRIDE) -WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools -.endif -WMAKE_TGTS+= _cleanobj _obj _build-tools -.if !defined(SUBDIR_OVERRIDE) -WMAKE_TGTS+= _cross-tools +WMAKE_TGTS+= _worldtmp _legacy +.if empty(SUBDIR_OVERRIDE) +WMAKE_TGTS+= _bootstrap-tools .endif +WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools WMAKE_TGTS+= _includes _libraries _depend everything -.if defined(LIB32TMP) && ${MK_LIB32} != "no" +.if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE) WMAKE_TGTS+= build32 .endif @@ -901,6 +929,14 @@ distributeworld installworld: _installcheck_world mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null .endif +.if ${MK_LIB32} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null +.if ${MK_DEBUG_FILES} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null +.endif +.endif .if ${MK_TESTS} != "no" && ${dist} == "tests" -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ @@ -917,10 +953,14 @@ distributeworld installworld: _installcheck_world sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \ sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG} +.if ${MK_LIB32} != "no" + ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \ + sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} +.endif .endif .endfor -mkdir ${DESTDIR}/${DISTDIR}/base - cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ + ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \ DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \ LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs @@ -988,7 +1028,7 @@ packageworld: # and do a 'make reinstall' on the *client* to install new binaries from the # most recent server build. # -reinstall: .MAKE +reinstall: .MAKE .PHONY @echo "--------------------------------------------------------------" @echo ">>> Making hierarchy" @echo "--------------------------------------------------------------" @@ -1003,7 +1043,7 @@ reinstall: .MAKE ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32 .endif -redistribute: .MAKE +redistribute: .MAKE .PHONY @echo "--------------------------------------------------------------" @echo ">>> Distributing everything" @echo "--------------------------------------------------------------" @@ -1013,12 +1053,12 @@ redistribute: .MAKE DISTRIBUTION=lib32 .endif -distrib-dirs: .MAKE - cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ +distrib-dirs: .MAKE .PHONY + ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET} -distribution: .MAKE - cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ +distribution: .MAKE .PHONY + ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET} ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \ ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \ @@ -1071,14 +1111,14 @@ INSTALLKERNEL= ${_kernel} .endif .endfor -buildkernel ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY +${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY # # buildkernel # # Builds all kernels defined by BUILDKERNELS. # -buildkernel: +buildkernel: .MAKE .PHONY .if empty(BUILDKERNELS) @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ false @@ -1105,14 +1145,14 @@ buildkernel: @echo "--------------------------------------------------------------" @echo ">>> stage 2.1: cleaning up the object tree" @echo "--------------------------------------------------------------" - cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR} + ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR} .endif .if !defined(NO_KERNELOBJ) @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.2: rebuilding the object tree" @echo "--------------------------------------------------------------" - cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj + ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj .endif @echo @echo "--------------------------------------------------------------" @@ -1124,13 +1164,13 @@ buildkernel: @echo "--------------------------------------------------------------" @echo ">>> stage 3.1: making dependencies" @echo "--------------------------------------------------------------" - cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ + ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ .endif @echo @echo "--------------------------------------------------------------" @echo ">>> stage 3.2: building everything" @echo "--------------------------------------------------------------" - cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ + ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ @echo "--------------------------------------------------------------" @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" @echo "--------------------------------------------------------------" @@ -1231,12 +1271,12 @@ packagekernel: # # Build the API documentation with doxygen # -doxygen: +doxygen: .PHONY @if [ ! -x `/usr/bin/which doxygen` ]; then \ echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \ exit 1; \ fi - cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all + ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all # # update @@ -1471,7 +1511,6 @@ _gcc_tools= gnu/usr.bin/cc/cc_tools _rescue=rescue/rescue .endif -build-tools: .MAKE .for _tool in \ bin/csh \ bin/sh \ @@ -1485,18 +1524,22 @@ build-tools: .MAKE usr.bin/mkesdb_static \ usr.bin/mkcsmapper_static \ usr.bin/vi/catalog +build-tools_${_tool}: .PHONY ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ cd ${.CURDIR}/${_tool} && \ ${MAKE} DIRPRFX=${_tool}/ obj && \ ${MAKE} DIRPRFX=${_tool}/ build-tools +build-tools: build-tools_${_tool} .endfor .for _tool in \ ${_gcc_tools} +build-tools_${_tool}: .PHONY ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \ cd ${.CURDIR}/${_tool} && \ ${MAKE} DIRPRFX=${_tool}/ obj && \ ${MAKE} DIRPRFX=${_tool}/ depend && \ ${MAKE} DIRPRFX=${_tool}/ all +build-tools: build-tools_${_tool} .endfor # @@ -1562,7 +1605,7 @@ _cc= gnu/usr.bin/cc _usb_tools= sys/boot/usb/tools .endif -cross-tools: .MAKE +cross-tools: .MAKE .PHONY .for _tool in \ ${_clang_libs} \ ${_clang} \ @@ -1581,12 +1624,13 @@ cross-tools: .MAKE ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install .endfor +NXBDESTDIR= ${OBJTREE}/nxb-bin NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin NXBMAKE= ${NXBENV} ${MAKE} \ - TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \ - CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \ + TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \ + CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \ MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \ MK_GDB=no MK_TESTS=no \ SSP_CFLAGS= \ @@ -1601,7 +1645,7 @@ NXBMAKE= ${NXBENV} ${MAKE} \ # For non-clang enabled targets that are still using the in tree gcc # we must build a gperf binary for one instance of its Makefiles. On # clang-enabled systems, the gperf binary is obsolete. -native-xtools: +native-xtools: .PHONY .if ${MK_GCC_BOOTSTRAP} != "no" mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \ @@ -1611,13 +1655,15 @@ native-xtools: ${NXBMAKE} DIRPRFX=${_gperf}/ all && \ ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install .endif - mkdir -p ${OBJTREE}/nxb-bin/bin - mkdir -p ${OBJTREE}/nxb-bin/sbin - mkdir -p ${OBJTREE}/nxb-bin/usr + mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ - -p ${OBJTREE}/nxb-bin/usr >/dev/null + -p ${NXBDESTDIR}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ - -p ${OBJTREE}/nxb-bin/usr/include >/dev/null + -p ${NXBDESTDIR}/usr/include >/dev/null +.if ${MK_DEBUG_FILES} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ + -p ${NXBDESTDIR}/usr/lib >/dev/null +.endif .for _tool in \ bin/cat \ bin/chmod \ @@ -1682,14 +1728,14 @@ native-xtools: ${NXBMAKE} DIRPRFX=${_tool}/ obj && \ ${NXBMAKE} DIRPRFX=${_tool}/ depend && \ ${NXBMAKE} DIRPRFX=${_tool}/ all && \ - ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install + ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install .endfor # # hierarchy - ensure that all the needed directories are present # -hierarchy hier: .MAKE - cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs +hierarchy hier: .MAKE .PHONY + ${_+_}cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs # # libraries - build all libraries, and install them under ${DESTDIR}. @@ -1698,8 +1744,8 @@ hierarchy hier: .MAKE # interdependencies (__L) are built automatically by the # ${.CURDIR}/tools/make_libdeps.sh script. # -libraries: .MAKE - cd ${.CURDIR} && \ +libraries: .MAKE .PHONY + ${_+_}cd ${.CURDIR} && \ ${MAKE} -f Makefile.inc1 _prereq_libs && \ ${MAKE} -f Makefile.inc1 _startup_libs && \ ${MAKE} -f Makefile.inc1 _prebuild_libs && \ @@ -2197,12 +2243,12 @@ xdev: xdev-build xdev-install .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools -_xb-worldtmp: +_xb-worldtmp: .PHONY mkdir -p ${CDTMP}/usr mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${CDTMP}/usr >/dev/null -_xb-bootstrap-tools: +_xb-bootstrap-tools: .PHONY .for _tool in \ ${_clang_tblgen} \ ${_gperf} @@ -2214,11 +2260,11 @@ _xb-bootstrap-tools: ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install .endfor -_xb-build-tools: +_xb-build-tools: .PHONY ${_+_}@cd ${.CURDIR}; \ ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools -_xb-cross-tools: +_xb-cross-tools: .PHONY .for _tool in \ ${_binutils} \ ${_elftctools} \ @@ -2233,7 +2279,7 @@ _xb-cross-tools: ${CDMAKE} DIRPRFX=${_tool}/ all .endfor -_xi-mtree: +_xi-mtree: .PHONY ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}" mkdir -p ${XDDESTDIR} mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ @@ -2242,6 +2288,10 @@ _xi-mtree: -p ${XDDESTDIR}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${XDDESTDIR}/usr/include >/dev/null +.if ${MK_LIB32} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \ + -p ${XDDESTDIR}/usr >/dev/null +.endif .if ${MK_TESTS} != "no" mkdir -p ${XDDESTDIR}${TESTSBASE} mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ @@ -2251,7 +2301,7 @@ _xi-mtree: .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries -_xi-cross-tools: +_xi-cross-tools: .PHONY @echo "_xi-cross-tools" .for _tool in \ ${_binutils} \ @@ -2265,17 +2315,17 @@ _xi-cross-tools: ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} .endfor -_xi-includes: +_xi-includes: .PHONY ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 buildincludes \ DESTDIR=${XDDESTDIR} ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 installincludes \ DESTDIR=${XDDESTDIR} -_xi-libraries: +_xi-libraries: .PHONY ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \ DESTDIR=${XDDESTDIR} -xdev-links: +xdev-links: .PHONY ${_+_}cd ${XDDESTDIR}/usr/bin; \ mkdir -p ../../../../usr/bin; \ for i in *; do \ diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index c04479edddda..0af25db96b0c 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -97,6 +97,15 @@ OLD_FILES+=usr/bin/colldef OLD_FILES+=usr/share/man/man1/colldef.1.gz OLD_FILES+=usr/bin/mklocale OLD_FILES+=usr/share/man/man1/mklocale.1.gz +# 20151030: OpenSSL 1.0.2d import +OLD_FILES+=usr/share/openssl/man/man3/CMS_set1_signer_certs.3.gz +OLD_FILES+=usr/share/openssl/man/man3/EVP_PKEY_ctrl.3.gz +OLD_FILES+=usr/share/openssl/man/man3/EVP_PKEY_ctrl_str.3.gz +OLD_FILES+=usr/share/openssl/man/man3/d2i_509_CRL_fp.3.gz +OLD_LIBS+=lib/libcrypto.so.7 +OLD_LIBS+=usr/lib/libssl.so.7 +OLD_LIBS+=usr/lib32/libcrypto.so.7 +OLD_LIBS+=usr/lib32/libssl.so.7 # 20151015: test symbols moved to /usr/lib/debug OLD_DIRS+=usr/tests/lib/atf/libatf-c++/.debug OLD_FILES+=usr/tests/lib/atf/libatf-c++/.debug/atf_c++_test.debug @@ -503,6 +512,8 @@ OLD_DIRS+=usr/share/doc/legal/intel_wpi OLD_FILES+=usr/share/doc/legal/intel_wpi/LICENSE # 20151006: new libc++ import OLD_FILES+=usr/include/c++/__tuple_03 +OLD_FILES+=usr/include/c++/v1/__tuple_03 +OLD_FILES+=usr/include/c++/v1/tr1/__tuple_03 # 20151006: new clang import which bumps version from 3.6.1 to 3.7.0. OLD_FILES+=usr/lib/clang/3.6.1/include/__stddef_max_align_t.h OLD_FILES+=usr/lib/clang/3.6.1/include/__wmmintrin_aes.h @@ -589,11 +600,16 @@ OLD_FILES+=usr/share/man/man4/dtrace-proc.4.gz OLD_FILES+=usr/share/man/man4/dtrace-sched.4.gz OLD_FILES+=usr/share/man/man4/dtrace-tcp.4.gz OLD_FILES+=usr/share/man/man4/dtrace-udp.4.gz +# 20150704: nvlist private headers no longer installed +OLD_FILES+=usr/include/sys/nv_impl.h +OLD_FILES+=usr/include/sys/nvlist_impl.h +OLD_FILES+=usr/include/sys/nvpair_impl.h # 20150624 OLD_LIBS+=usr/lib/libugidfw.so.4 OLD_LIBS+=usr/lib32/libugidfw.so.4 # 20150604: Move nvlist man pages to section 9. OLD_FILES+=usr/share/man/man3/libnv.3.gz +OLD_FILES+=usr/share/man/man3/nv.3.gz OLD_FILES+=usr/share/man/man3/nvlist.3.gz OLD_FILES+=usr/share/man/man3/nvlist_add_binary.3.gz OLD_FILES+=usr/share/man/man3/nvlist_add_bool.3.gz diff --git a/UPDATING b/UPDATING index 1095ba6ea5d1..a26c317586a2 100644 --- a/UPDATING +++ b/UPDATING @@ -31,6 +31,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20151030: + The OpenSSL has been upgraded to 1.0.2d. Any binaries requiring + libcrypto.so.7 or libssl.so.7 must be recompiled. + +20151020: + Qlogic 24xx/25xx firmware images were updated from 5.5.0 to 7.3.0. + Kernel modules isp_2400_multi and isp_2500_multi were removed and + should be replaced with isp_2400 and isp_2500 modules respectively. + 20151017: The build previously allowed using 'make -n' to not recurse into sub-directories while showing what commands would be executed, and diff --git a/bin/csh/config_p.h b/bin/csh/config_p.h index a1bbea65f175..0006fe0e1574 100644 --- a/bin/csh/config_p.h +++ b/bin/csh/config_p.h @@ -9,7 +9,7 @@ #ifndef _h_config #define _h_config -/****************** System dependant compilation flags ****************/ +/****************** System dependent compilation flags ****************/ /* * POSIX This system supports IEEE Std 1003.1-1988 (POSIX). */ diff --git a/bin/ls/tests/ls_tests.sh b/bin/ls/tests/ls_tests.sh index 39c856948427..fbbf24df34b9 100755 --- a/bin/ls/tests/ls_tests.sh +++ b/bin/ls/tests/ls_tests.sh @@ -418,10 +418,10 @@ T_flag_body() atf_check -e empty -o empty -s exit:0 touch a.file - birthtime_in_secs=$(stat -f %B -t %s a.file) - birthtime=$(date -j -f %s $birthtime_in_secs +"[[:space:]]+%b[[:space:]]+%e[[:space:]]+%H:%M:%S[[:space:]]+%Y") + mtime_in_secs=$(stat -f %m -t %s a.file) + mtime=$(date -j -f %s $mtime_in_secs +"[[:space:]]+%b[[:space:]]+%e[[:space:]]+%H:%M:%S[[:space:]]+%Y") - atf_check -e empty -o match:"$birthtime"'[[:space:]]+a\.file' \ + atf_check -e empty -o match:"$mtime"'[[:space:]]+a\.file' \ -s exit:0 ls -lT a.file } @@ -626,10 +626,10 @@ l_flag_body() atf_check -e empty -o empty -s exit:0 touch a.file - birthtime_in_secs=$(stat -f "%B" -t "%s" a.file) - birthtime=$(date -j -f "%s" $birthtime_in_secs +"%b[[:space:]]+%e[[:space:]]+%H:%M") + mtime_in_secs=$(stat -f "%m" -t "%s" a.file) + mtime=$(date -j -f "%s" $mtime_in_secs +"%b[[:space:]]+%e[[:space:]]+%H:%M") - expected_output=$(stat -f "%Sp[[:space:]]+%l[[:space:]]+%Su[[:space:]]+%Sg[[:space:]]+%z[[:space:]]+$birthtime[[:space:]]+a\\.file" a.file) + expected_output=$(stat -f "%Sp[[:space:]]+%l[[:space:]]+%Su[[:space:]]+%Sg[[:space:]]+%z[[:space:]]+$mtime[[:space:]]+a\\.file" a.file) atf_check -e empty -o match:"$expected_output" -s exit:0 ls -l a.file } diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index 5eca00fe0080..418f253d1414 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 14, 2015 +.Dd October 24, 2015 .Dt ZFS 8 .Os .Sh NAME @@ -272,8 +272,10 @@ .Ar tag snapshot Ns ... .Nm .Cm holds -.Op Fl r -.Ar snapshot Ns ... +.Op Fl Hp +.Op Fl r Ns | Ns Fl d Ar depth +.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns +.Ns ... .Nm .Cm release .Op Fl r @@ -3159,15 +3161,26 @@ snapshots of all descendent file systems. .It Xo .Nm .Cm holds -.Op Fl r -.Ar snapshot Ns ... +.Op Fl Hp +.Op Fl r Ns | Ns Fl d Ar depth +.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns +.Ns ... .Xc .Pp -Lists all existing user references for the given snapshot or snapshots. +Lists all existing user references for the given dataset or datasets. .Bl -tag -width indent +.It Fl H +Used for scripting mode. Do not print headers and separate fields by a single +tab instead of arbitrary white space. +.It Fl p +Display numbers in parsable (exact) values. .It Fl r -Lists the holds that are set on the named descendent snapshots, in addition to -listing the holds on the named snapshot. +Lists the holds that are set on the descendent snapshots of the named datasets +or snapshots, in addition to listing the holds on the named snapshots, if any. +.It Fl d Ar depth +Recursively display any holds on the named snapshots, or descendent snapshots of +the named datasets or snapshots, limiting the recursion to +.Ar depth . .El .It Xo .Nm diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c index b8466fe24e17..9db2f73278d8 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c @@ -329,7 +329,8 @@ get_usage(zfs_help_t idx) case HELP_HOLD: return (gettext("\thold [-r] ...\n")); case HELP_HOLDS: - return (gettext("\tholds [-r] ...\n")); + return (gettext("\tholds [-Hp] [-r|-d depth] " + " ...\n")); case HELP_RELEASE: return (gettext("\trelease [-r] ...\n")); case HELP_DIFF: @@ -5543,7 +5544,8 @@ typedef struct holds_cbdata { * */ static void -print_holds(boolean_t scripted, size_t nwidth, size_t tagwidth, nvlist_t *nvl) +print_holds(boolean_t scripted, boolean_t literal, size_t nwidth, + size_t tagwidth, nvlist_t *nvl) { int i; nvpair_t *nvp = NULL; @@ -5576,10 +5578,14 @@ print_holds(boolean_t scripted, size_t nwidth, size_t tagwidth, nvlist_t *nvl) size_t sepnum = scripted ? 1 : 2; (void) nvpair_value_uint64(nvp2, &val); - time = (time_t)val; - (void) localtime_r(&time, &t); - (void) strftime(tsbuf, DATETIME_BUF_LEN, - gettext(STRFTIME_FMT_STR), &t); + if (literal) + snprintf(tsbuf, DATETIME_BUF_LEN, "%llu", val); + else { + time = (time_t)val; + (void) localtime_r(&time, &t); + (void) strftime(tsbuf, DATETIME_BUF_LEN, + gettext(STRFTIME_FMT_STR), &t); + } (void) printf("%-*s%*c%-*s%*c%s\n", nwidth, zname, sepnum, sep, tagwidth, tagname, sepnum, sep, tsbuf); @@ -5600,7 +5606,7 @@ holds_callback(zfs_handle_t *zhp, void *data) const char *zname = zfs_get_name(zhp); size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN); - if (cbp->cb_recursive) { + if (cbp->cb_recursive && cbp->cb_snapname != NULL) { const char *snapname; char *delim = strchr(zname, '@'); if (delim == NULL) @@ -5628,9 +5634,12 @@ holds_callback(zfs_handle_t *zhp, void *data) } /* - * zfs holds [-r] ... + * zfs holds [-Hp] [-r | -d max] ... * - * -r Recursively hold + * -H Suppress header output + * -p Output literal values + * -r Recursively search for holds + * -d max Limit depth of recursive search */ static int zfs_do_holds(int argc, char **argv) @@ -5639,8 +5648,9 @@ zfs_do_holds(int argc, char **argv) int c; int i; boolean_t scripted = B_FALSE; + boolean_t literal = B_FALSE; boolean_t recursive = B_FALSE; - const char *opts = "rH"; + const char *opts = "d:rHp"; nvlist_t *nvl; int types = ZFS_TYPE_SNAPSHOT; @@ -5653,12 +5663,19 @@ zfs_do_holds(int argc, char **argv) /* check options */ while ((c = getopt(argc, argv, opts)) != -1) { switch (c) { + case 'd': + limit = parse_depth(optarg, &flags); + recursive = B_TRUE; + break; case 'r': recursive = B_TRUE; break; case 'H': scripted = B_TRUE; break; + case 'p': + literal = B_TRUE; + break; case '?': (void) fprintf(stderr, gettext("invalid option '%c'\n"), optopt); @@ -5684,18 +5701,14 @@ zfs_do_holds(int argc, char **argv) for (i = 0; i < argc; ++i) { char *snapshot = argv[i]; const char *delim; - const char *snapname; + const char *snapname = NULL; delim = strchr(snapshot, '@'); - if (delim == NULL) { - (void) fprintf(stderr, - gettext("'%s' is not a snapshot\n"), snapshot); - ++errors; - continue; + if (delim != NULL) { + snapname = delim + 1; + if (recursive) + snapshot[delim - snapshot] = '\0'; } - snapname = delim + 1; - if (recursive) - snapshot[delim - snapshot] = '\0'; cb.cb_recursive = recursive; cb.cb_snapname = snapname; @@ -5713,7 +5726,8 @@ zfs_do_holds(int argc, char **argv) /* * 2. print holds data */ - print_holds(scripted, cb.cb_max_namelen, cb.cb_max_taglen, nvl); + print_holds(scripted, literal, cb.cb_max_namelen, cb.cb_max_taglen, + nvl); if (nvlist_empty(nvl)) (void) printf(gettext("no datasets available\n")); diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c index b7cb66fee9ab..e439f04616af 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c @@ -683,6 +683,10 @@ tdesc_array_create(dwarf_t *dw, Dwarf_Die dim, tdesc_t *arrtdp, ar->ad_nelems = uval + 1; else if (die_signed(dw, dim, DW_AT_upper_bound, &sval, 0)) ar->ad_nelems = sval + 1; + else if (die_unsigned(dw, dim, DW_AT_count, &uval, 0)) + ar->ad_nelems = uval; + else if (die_signed(dw, dim, DW_AT_count, &sval, 0)) + ar->ad_nelems = sval; else ar->ad_nelems = 0; diff --git a/cddl/usr.sbin/dtrace/tests/Makefile.inc1 b/cddl/usr.sbin/dtrace/tests/Makefile.inc1 index 6958f787343a..6e7cc079c14d 100644 --- a/cddl/usr.sbin/dtrace/tests/Makefile.inc1 +++ b/cddl/usr.sbin/dtrace/tests/Makefile.inc1 @@ -4,7 +4,6 @@ TESTGROUP= ${.CURDIR:H:T}/${.CURDIR:T} TESTSRC= ${.CURDIR:H:H:H:H:H}/contrib/opensolaris/cmd/dtrace/test/tst/${TESTGROUP} TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace/${TESTGROUP} -.if !defined(_RECURSING_PROGS) FILESGROUPS+= FILES ${TESTGROUP} ${TESTGROUP}EXE ${TESTGROUP}= ${TESTFILES} @@ -25,7 +24,6 @@ ${TESTWRAPPER}.sh: ${GENTEST} ${EXCLUDE} ${${TESTGROUP}} sh ${GENTEST} -e ${EXCLUDE} ${TESTGROUP} ${${TESTGROUP}:S/ */ /} > ${.TARGET} CLEANFILES+= ${TESTWRAPPER}.sh -.endif # !defined(_RECURSING_PROGS) .PATH: ${TESTSRC} diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog index e1d6f10c3414..ec3255e6ffd5 100644 --- a/contrib/bmake/ChangeLog +++ b/contrib/bmake/ChangeLog @@ -1,3 +1,40 @@ +2015-10-20 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20151020 + Merge with NetBSD make, pick up + o var.c: fix uninitialized var + +2015-10-12 Simon J. Gerraty + + * var.c: the conditional expressions used with ':?' can be + expensive, if already discarding do not evaluate or expand + anything. + +2015-10-10 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20151010 + Merge with NetBSD make, pick up + o Add Boolean wantit flag to Var_Subst and Var_Parse + when FALSE we know we are discarding the result and can + skip operations like Cmd_Exec. + +2015-10-09 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20151009 + Merge with NetBSD make, pick up + o var.c: don't check for NULL before free() + o meta.c: meta_oodate, do not hard code ignore of makeDependfile + +2015-09-10 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20150910 + Merge with NetBSD make, pick up + o main.c: with -w print Enter/Leaving messages for objdir too + if necessary. + o centralize shell metachar handling + + * FILES: add metachar.[ch] + 2015-06-06 Simon J. Gerraty * Makefile (MAKE_VERSION): 20150606 diff --git a/contrib/bmake/FILES b/contrib/bmake/FILES index c46e74bd7a46..720eb1b9bfb7 100644 --- a/contrib/bmake/FILES +++ b/contrib/bmake/FILES @@ -71,6 +71,8 @@ make_malloc.h makefile.in meta.c meta.h +metachar.c +metachar.h missing/sys/cdefs.h mkdeps.sh nonints.h diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile index e5427a877f20..a059ec4df01a 100644 --- a/contrib/bmake/Makefile +++ b/contrib/bmake/Makefile @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.39 2015/06/07 15:54:37 sjg Exp $ +# $Id: Makefile,v 1.44 2015/10/20 21:41:40 sjg Exp $ # Base version on src date -MAKE_VERSION= 20150606 +MAKE_VERSION= 20151020 PROG= bmake @@ -18,6 +18,7 @@ SRCS= \ make.c \ make_malloc.c \ meta.c \ + metachar.c \ parse.c \ str.c \ strlist.c \ diff --git a/contrib/bmake/arch.c b/contrib/bmake/arch.c index 943f41ee8392..9ceee10cddb7 100644 --- a/contrib/bmake/arch.c +++ b/contrib/bmake/arch.c @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $ */ +/* $NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $"); +__RCSID("$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -310,7 +310,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) void *freeIt; char *result; - result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt); + result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt); if (freeIt) free(freeIt); if (result == var_Error) { @@ -325,7 +325,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) *cp++ = '\0'; if (subLibName) { - libName = Var_Subst(NULL, libName, ctxt, TRUE); + libName = Var_Subst(NULL, libName, ctxt, TRUE, TRUE); } @@ -351,7 +351,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) void *freeIt; char *result; - result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt); + result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt); if (freeIt) free(freeIt); if (result == var_Error) { @@ -404,7 +404,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) char *oldMemName = memName; size_t sz; - memName = Var_Subst(NULL, memName, ctxt, TRUE); + memName = Var_Subst(NULL, memName, ctxt, TRUE, TRUE); /* * Now form an archive spec and recurse to deal with nested diff --git a/contrib/bmake/compat.c b/contrib/bmake/compat.c index fd00eb7e03c3..6cf963ffb2da 100644 --- a/contrib/bmake/compat.c +++ b/contrib/bmake/compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $ */ +/* $NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -111,37 +111,14 @@ __RCSID("$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $"); #include "hash.h" #include "dir.h" #include "job.h" +#include "metachar.h" #include "pathnames.h" -/* - * The following array is used to make a fast determination of which - * characters are interpreted specially by the shell. If a command - * contains any of these characters, it is executed by the shell, not - * directly by us. - */ - -static char meta[256]; static GNode *curTarg = NULL; static GNode *ENDNode; static void CompatInterrupt(int); -static void -Compat_Init(void) -{ - const char *cp; - - Shell_Init(); /* setup default shell */ - - for (cp = "~#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) { - meta[(unsigned char) *cp] = 1; - } - /* - * The null character serves as a sentinel in the string. - */ - meta[0] = 1; -} - /*- *----------------------------------------------------------------------- * CompatInterrupt -- @@ -236,7 +213,7 @@ CompatRunCommand(void *cmdp, void *gnp) doIt = FALSE; cmdNode = Lst_Member(gn->commands, cmd); - cmdStart = Var_Subst(NULL, cmd, gn, FALSE); + cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE); /* * brk_string will return an argv with a NULL in av[0], thus causing @@ -271,8 +248,8 @@ CompatRunCommand(void *cmdp, void *gnp) break; case '+': doIt = TRUE; - if (!meta[0]) /* we came here from jobs */ - Compat_Init(); + if (!shellName) /* we came here from jobs */ + Shell_Init(); break; } cmd++; @@ -300,11 +277,13 @@ CompatRunCommand(void *cmdp, void *gnp) * Search for meta characters in the command. If there are no meta * characters, there's no need to execute a shell to execute the * command. + * + * Additionally variable assignments and empty commands + * go to the shell. Therefore treat '=' and ':' like shell + * meta characters as documented in make(1). */ - for (cp = cmd; !meta[(unsigned char)*cp]; cp++) { - continue; - } - useShell = (*cp != '\0'); + + useShell = needshell(cmd, FALSE); #endif /* @@ -512,8 +491,8 @@ Compat_Make(void *gnp, void *pgnp) GNode *gn = (GNode *)gnp; GNode *pgn = (GNode *)pgnp; - if (!meta[0]) /* we came here from jobs */ - Compat_Init(); + if (!shellName) /* we came here from jobs */ + Shell_Init(); if (gn->made == UNMADE && (gn == pgn || (pgn->type & OP_MADE) == 0)) { /* * First mark ourselves to be made, then apply whatever transformations @@ -693,7 +672,8 @@ Compat_Run(Lst targs) GNode *gn = NULL;/* Current root target */ int errors; /* Number of targets not remade due to errors */ - Compat_Init(); + if (!shellName) + Shell_Init(); if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) { bmake_signal(SIGINT, CompatInterrupt); diff --git a/contrib/bmake/cond.c b/contrib/bmake/cond.c index b05a56cbcc86..2d2f08760c7a 100644 --- a/contrib/bmake/cond.c +++ b/contrib/bmake/cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $ */ +/* $NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -289,7 +289,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func) int len; void *freeIt; - cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &freeIt); + cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); if (freeIt) free(freeIt); @@ -571,7 +571,7 @@ CondGetString(Boolean doEval, Boolean *quoted, void **freeIt, Boolean strictLHS) case '$': /* if we are in quotes, then an undefined variable is ok */ str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval), - &len, freeIt); + TRUE, &len, freeIt); if (str == var_Error) { if (*freeIt) { free(*freeIt); @@ -823,7 +823,7 @@ get_mpt_arg(char **linePtr, char **argPtr, const char *func MAKE_ATTR_UNUSED) /* We do all the work here and return the result as the length */ *argPtr = NULL; - val = Var_Parse(cp - 1, VAR_CMD, FALSE, &length, &freeIt); + val = Var_Parse(cp - 1, VAR_CMD, FALSE, TRUE, &length, &freeIt); /* * Advance *linePtr to beyond the closing ). Note that * we subtract one because 'length' is calculated from 'cp - 1'. diff --git a/contrib/bmake/configure.in b/contrib/bmake/configure.in index e2249b0db261..ae3e425f16af 100644 --- a/contrib/bmake/configure.in +++ b/contrib/bmake/configure.in @@ -1,11 +1,11 @@ dnl dnl RCSid: -dnl $Id: configure.in,v 1.53 2014/11/06 01:49:40 sjg Exp $ +dnl $Id: configure.in,v 1.54 2015/10/10 04:17:10 sjg Exp $ dnl dnl Process this file with autoconf to produce a configure script dnl AC_PREREQ(2.50) -AC_INIT([bmake], [20140214], [sjg@NetBSD.org]) +AC_INIT([bmake], [20151009], [sjg@NetBSD.org]) AC_CONFIG_HEADERS(config.h) dnl make srcdir absolute @@ -105,6 +105,7 @@ AC_CHECK_HEADERS( \ ar.h \ err.h \ fcntl.h \ + limits.h \ paths.h \ poll.h \ ranlib.h \ diff --git a/contrib/bmake/for.c b/contrib/bmake/for.c index 33bcf1392b8e..7f10e5626f9a 100644 --- a/contrib/bmake/for.c +++ b/contrib/bmake/for.c @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $ */ +/* $NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -30,14 +30,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $"; +static char rcsid[] = "$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $"); +__RCSID("$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -216,7 +216,7 @@ For_Eval(char *line) * We can't do the escapes here - because we don't know whether * we are substuting into ${...} or $(...). */ - sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE); + sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE, TRUE); /* * Split into words allowing for quoted strings. diff --git a/contrib/bmake/job.c b/contrib/bmake/job.c index 8a7a902e7115..20f693ab8618 100644 --- a/contrib/bmake/job.c +++ b/contrib/bmake/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $ */ +/* $NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $"); +__RCSID("$NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -731,7 +731,7 @@ JobPrintCommand(void *cmdp, void *jobp) numCommands += 1; - cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE); + cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE, TRUE); cmdTemplate = "%s\n"; @@ -919,7 +919,7 @@ JobPrintCommand(void *cmdp, void *jobp) static int JobSaveCommand(void *cmd, void *gn) { - cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE); + cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE, TRUE); (void)Lst_AtEnd(postCommands->commands, cmd); return(0); } @@ -2211,7 +2211,8 @@ Job_SetPrefix(void) Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0); } - targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", VAR_GLOBAL, 0); + targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", + VAR_GLOBAL, FALSE, TRUE); } /*- diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c index 3287115cf8b2..d7fe53412900 100644 --- a/contrib/bmake/main.c +++ b/contrib/bmake/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.232 2015/03/26 22:20:42 sjg Exp $ */ +/* $NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.232 2015/03/26 22:20:42 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.232 2015/03/26 22:20:42 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -172,6 +172,7 @@ Boolean keepgoing; /* -k flag */ Boolean queryFlag; /* -q flag */ Boolean touchFlag; /* -t flag */ Boolean enterFlag; /* -w flag */ +Boolean enterFlagObj; /* -w and objdir != srcdir */ Boolean ignoreErrors; /* -i flag */ Boolean beSilent; /* -s flag */ Boolean oldVars; /* variable substitution style */ @@ -722,7 +723,7 @@ Main_SetObjdir(const char *path) /* expand variable substitutions */ if (strchr(path, '$') != 0) { snprintf(buf, MAXPATHLEN, "%s", path); - path = p = Var_Subst(NULL, buf, VAR_GLOBAL, 0); + path = p = Var_Subst(NULL, buf, VAR_GLOBAL, FALSE, TRUE); } if (path[0] != '/') { @@ -741,6 +742,8 @@ Main_SetObjdir(const char *path) setenv("PWD", objdir, 1); Dir_InitDot(); rc = TRUE; + if (enterFlag && strcmp(objdir, curdir) != 0) + enterFlagObj = TRUE; } } @@ -803,7 +806,8 @@ MakeMode(const char *mode) char *mp = NULL; if (!mode) - mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", VAR_GLOBAL, 0); + mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", + VAR_GLOBAL, FALSE, TRUE); if (mode && *mode) { if (strstr(mode, "compat")) { @@ -1249,7 +1253,7 @@ main(int argc, char **argv) (char *)Lst_Datum(ln)); } else { p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}", - VAR_CMD, 0); + VAR_CMD, FALSE, TRUE); if (p1) { (void)str2Lst_Append(makefiles, p1, NULL); (void)Lst_Find(makefiles, NULL, ReadMakefile); @@ -1260,12 +1264,15 @@ main(int argc, char **argv) /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */ if (!noBuiltins || !printVars) { makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}", - VAR_CMD, 0); + VAR_CMD, FALSE, TRUE); doing_depend = TRUE; (void)ReadMakefile(makeDependfile, NULL); doing_depend = FALSE; } + if (enterFlagObj) + printf("%s: Entering directory `%s'\n", progname, objdir); + MakeMode(NULL); Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL); @@ -1295,7 +1302,7 @@ main(int argc, char **argv) */ static char VPATH[] = "${VPATH}"; - vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE); + vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE, TRUE); path = vpath; do { /* skip to end of directory */ @@ -1342,14 +1349,16 @@ main(int argc, char **argv) char *value; if (strchr(var, '$')) { - value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, 0); + value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, + FALSE, TRUE); } else if (expandVars) { char tmp[128]; if (snprintf(tmp, sizeof(tmp), "${%s}", var) >= (int)(sizeof(tmp))) Fatal("%s: variable name too big: %s", progname, var); - value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, + FALSE, TRUE); } else { value = Var_Value(var, VAR_GLOBAL, &p1); } @@ -1406,6 +1415,8 @@ main(int argc, char **argv) Trace_Log(MAKEEND, 0); + if (enterFlagObj) + printf("%s: Leaving directory `%s'\n", progname, objdir); if (enterFlag) printf("%s: Leaving directory `%s'\n", progname, curdir); @@ -1885,7 +1896,7 @@ PrintOnError(GNode *gn, const char *s) } strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", sizeof(tmp) - 1); - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); if (cp) { if (*cp) printf("%s", cp); @@ -1914,7 +1925,7 @@ Main_ExportMAKEFLAGS(Boolean first) strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}", sizeof(tmp)); - s = Var_Subst(NULL, tmp, VAR_CMD, 0); + s = Var_Subst(NULL, tmp, VAR_CMD, FALSE, TRUE); if (s && *s) { #ifdef POSIX setenv("MAKEFLAGS", s, 1); @@ -1936,7 +1947,8 @@ getTmpdir(void) * Honor $TMPDIR but only if it is valid. * Ensure it ends with /. */ - tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, 0); + tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, + FALSE, TRUE); if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) { free(tmpdir); tmpdir = bmake_strdup(_PATH_TMP); @@ -1991,7 +2003,7 @@ getBoolean(const char *name, Boolean bf) char *cp; if (snprintf(tmp, sizeof(tmp), "${%s:tl}", name) < (int)(sizeof(tmp))) { - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); if (cp) { switch(*cp) { diff --git a/contrib/bmake/make-bootstrap.sh.in b/contrib/bmake/make-bootstrap.sh.in index 2bb4c25a7058..638e29319ba2 100755 --- a/contrib/bmake/make-bootstrap.sh.in +++ b/contrib/bmake/make-bootstrap.sh.in @@ -52,7 +52,7 @@ do_link() { } BASE_OBJECTS="arch.o buf.o compat.o cond.o dir.o for.o getopt hash.o \ -job.o make.o make_malloc.o parse.o sigcompat.o str.o strlist.o \ +job.o make.o make_malloc.o metachar.o parse.o sigcompat.o str.o strlist.o \ suff.o targ.o trace.o var.o util.o" LST_OBJECTS="lstAppend.o lstDupl.o lstInit.o lstOpen.o \ diff --git a/contrib/bmake/make.c b/contrib/bmake/make.c index fde185065fab..b43bfd578cf0 100644 --- a/contrib/bmake/make.c +++ b/contrib/bmake/make.c @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj Exp $ */ +/* $NetBSD: make.c,v 1.92 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj Exp $"; +static char rcsid[] = "$NetBSD: make.c,v 1.92 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj Exp $"); +__RCSID("$NetBSD: make.c,v 1.92 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -485,7 +485,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn) if (gn->name) free(gn->name); } - gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE); + gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE, TRUE); if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) { /* See if we have a target for this node. */ tgn = Targ_FindNode(gn->name, TARG_NOCREATE); diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h index 9cf7243b58c9..7cf34d82e0a6 100644 --- a/contrib/bmake/make.h +++ b/contrib/bmake/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.95 2014/09/07 20:55:34 joerg Exp $ */ +/* $NetBSD: make.h,v 1.96 2015/09/21 21:50:16 pooka Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -519,8 +519,15 @@ int str2Lst_Append(Lst, char *, const char *); #define MAX(a, b) ((a > b) ? a : b) #endif +/* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ +#ifdef HAVE_LIMITS_H +#include +#endif #ifndef MAXPATHLEN -#define MAXPATHLEN BMAKE_PATH_MAX +#define MAXPATHLEN BMAKE_PATH_MAX +#endif +#ifndef PATH_MAX +#define PATH_MAX MAXPATHLEN #endif #endif /* _MAKE_H_ */ diff --git a/contrib/bmake/meta.c b/contrib/bmake/meta.c index 5600a772bed4..09febfc4c1fd 100644 --- a/contrib/bmake/meta.c +++ b/contrib/bmake/meta.c @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.38 2015/04/11 05:24:30 sjg Exp $ */ +/* $NetBSD: meta.c,v 1.40 2015/10/11 04:51:24 sjg Exp $ */ /* * Implement 'meta' mode. @@ -324,7 +324,7 @@ is_submake(void *cmdp, void *gnp) } cp = strchr(cmd, '$'); if ((cp)) { - mp = Var_Subst(NULL, cmd, gn, FALSE); + mp = Var_Subst(NULL, cmd, gn, FALSE, TRUE); cmd = mp; } cp2 = strstr(cmd, p_make); @@ -367,7 +367,7 @@ printCMD(void *cmdp, void *mfpp) char *cp = NULL; if (strchr(cmd, '$')) { - cmd = cp = Var_Subst(NULL, cmd, mfp->gn, FALSE); + cmd = cp = Var_Subst(NULL, cmd, mfp->gn, FALSE, TRUE); } fprintf(mfp->fp, "CMD %s\n", cmd); if (cp) @@ -462,7 +462,7 @@ meta_create(BuildMon *pbm, GNode *gn) char *mp; /* Describe the target we are building */ - mp = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", gn, 0); + mp = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", gn, FALSE, TRUE); if (*mp) fprintf(stdout, "%s\n", mp); free(mp); @@ -605,7 +605,8 @@ meta_mode_init(const char *make_mode) * We consider ourselves master of all within ${.MAKE.META.BAILIWICK} */ metaBailiwick = Lst_Init(FALSE); - cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, 0); + cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, + FALSE, TRUE); if (cp) { str2Lst_Append(metaBailiwick, cp, NULL); } @@ -616,7 +617,8 @@ meta_mode_init(const char *make_mode) Var_Append(MAKE_META_IGNORE_PATHS, "/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL); cp = Var_Subst(NULL, - "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, 0); + "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, + FALSE, TRUE); if (cp) { str2Lst_Append(metaIgnorePaths, cp, NULL); } @@ -727,7 +729,8 @@ meta_job_output(Job *job, char *cp, const char *nl) if (!meta_prefix) { char *cp2; - meta_prefix = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", VAR_GLOBAL, 0); + meta_prefix = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", + VAR_GLOBAL, FALSE, TRUE); if ((cp2 = strchr(meta_prefix, '$'))) meta_prefix_len = cp2 - meta_prefix; else @@ -1209,16 +1212,6 @@ meta_oodate(GNode *gn, Boolean oodate) break; } - if ((cp = strrchr(p, '/'))) { - cp++; - /* - * We don't normally expect to see this, - * but we do expect it to change. - */ - if (strcmp(cp, makeDependfile) == 0) - break; - } - /* * The rest of the record is the file name. * Check if it's not an absolute path. @@ -1322,7 +1315,7 @@ meta_oodate(GNode *gn, Boolean oodate) if (DEBUG(META)) fprintf(debug_file, "%s: %d: cannot compare command using .OODATE\n", fname, lineno); } - cmd = Var_Subst(NULL, cmd, gn, TRUE); + cmd = Var_Subst(NULL, cmd, gn, TRUE, TRUE); if ((cp = strchr(cmd, '\n'))) { int n; diff --git a/contrib/bmake/metachar.c b/contrib/bmake/metachar.c new file mode 100644 index 000000000000..49603383e660 --- /dev/null +++ b/contrib/bmake/metachar.c @@ -0,0 +1,88 @@ +/* $NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $ */ + +/*- + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + +#if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H) +#include +#endif + +#if defined(__RCSID) && !defined(lint) +__RCSID("$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $"); +#endif + +#include "metachar.h" +/* + * The following array is used to make a fast determination of which + * characters are interpreted specially by the shell. If a command + * contains any of these characters, it is executed by the shell, not + * directly by us. + * + * perhaps move it to ctype? + */ + +unsigned char _metachar[128] = { +// nul soh stx etx eot enq ack bel + 1, 0, 0, 0, 0, 0, 0, 0, +// bs ht nl vt np cr so si + 0, 0, 1, 0, 0, 0, 0, 0, +// dle dc1 dc2 dc3 dc4 nak syn etb + 0, 0, 0, 0, 0, 0, 0, 0, +// can em sub esc fs gs rs us + 0, 0, 0, 0, 0, 0, 0, 0, +// sp ! " # $ % & ' + 0, 1, 1, 1, 1, 0, 1, 1, +// ( ) * + , - . / + 1, 1, 1, 0, 0, 0, 0, 0, +// 0 1 2 3 4 5 6 7 + 0, 0, 0, 0, 0, 0, 0, 0, +// 8 9 : ; < = > ? + 0, 0, 0, 1, 1, 0, 1, 1, +// @ A B C D E F G + 0, 0, 0, 0, 0, 0, 0, 0, +// H I J K L M N O + 0, 0, 0, 0, 0, 0, 0, 0, +// P Q R S T U V W + 0, 0, 0, 0, 0, 0, 0, 0, +// X Y Z [ \ ] ^ _ + 0, 0, 0, 1, 1, 1, 1, 0, +// ` a b c d e f g + 1, 0, 0, 0, 0, 0, 0, 0, +// h i j k l m n o + 0, 0, 0, 0, 0, 0, 0, 0, +// p q r s t u v w + 0, 0, 0, 0, 0, 0, 0, 0, +// x y z { | } ~ del + 0, 0, 0, 1, 1, 1, 1, 0, +}; + diff --git a/sys/arm/samsung/s3c2xx0/s3c24x0var.h b/contrib/bmake/metachar.h similarity index 52% rename from sys/arm/samsung/s3c2xx0/s3c24x0var.h rename to contrib/bmake/metachar.h index 2ee042ea4318..db88d671067e 100644 --- a/sys/arm/samsung/s3c2xx0/s3c24x0var.h +++ b/contrib/bmake/metachar.h @@ -1,8 +1,11 @@ -/* $NetBSD: s3c24x0var.h,v 1.1 2003/07/31 19:49:44 bsh Exp $ */ +/* $NetBSD: metachar.h,v 1.4 2015/06/21 20:26:02 christos Exp $ */ /*- - * Copyright (c) 2003 Genetec corporation. All rights reserved. - * Written by Hiroyuki Bessho for Genetec corporation. + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,14 +15,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of Genetec corporation may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. * - * THIS SOFTWARE IS PROVIDED BY GENETEC CORP. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORP. + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -27,25 +27,35 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ +#ifndef _METACHAR_H +#define _METACHAR_H -#ifndef _ARM_S3C24X0VAR_H_ -#define _ARM_S3C24X0VAR_H_ +#include -#include +extern unsigned char _metachar[]; -struct s3c24x0_softc { - struct s3c2xx0_softc sc_sx; +#define ismeta(c) _metachar[(c) & 0x7f] - bus_space_handle_t sc_timer_ioh; /* Timer control registers */ -}; +static inline int +hasmeta(const char *cmd) +{ + while (!ismeta(*cmd)) + cmd++; -void s3c24x0_clock_freq(struct s3c2xx0_softc *); -void s3c2410_clock_freq2(vm_offset_t, int *, int *, int *); -void s3c2440_clock_freq2(vm_offset_t, int *, int *, int *); + return *cmd != '\0'; +} -void s3c24x0_sleep(int); +static inline int +needshell(const char *cmd, int white) +{ + while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') { + if (white && isspace((unsigned char)*cmd)) + break; + cmd++; + } -#endif /* _ARM_S3C24X0VAR_H_ */ + return *cmd != '\0'; +} + +#endif /* _METACHAR_H */ diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog index 85c8ae1715b2..e7f71b5ffb40 100644 --- a/contrib/bmake/mk/ChangeLog +++ b/contrib/bmake/mk/ChangeLog @@ -1,3 +1,48 @@ +2015-10-20 Simon J. Gerraty + + * install-mk (MK_VERSION): 20151020 + + * dirdeps.mk: Add logic for + make -f dirdeps.mk some/dir.${TARGET_SPEC} + +2015-10-14 Simon J. Gerraty + + * install-mk (MK_VERSION): 20151010 + +2015-10-02 Simon J. Gerraty + + * meta.stage.mk: use staging: ${STAGE_TARGETS:... + to have stage_lins run last in non-jobs mode. + Use .ORDER only for jobs mode. + +2015-09-02 Simon J. Gerraty + + * rst2htm.mk: allow for per target flags etc. + +2015-09-01 Simon J. Gerraty + + * install-mk (MK_VERSION): 20150901 + + * doc.mk: create dir if needed use DOC_INSTALL_OWN + +2015-06-15 Simon J. Gerraty + + * install-mk (MK_VERSION): 20150615 + + * auto.obj.mk: allow use of MAKEOBJDIRPREFIX too. + Follow make's normal precedence rules. + + * gendirdeps.mk: allow customization of the header. + eg. for FreeBSD: + GENDIRDEPS_HEADER= echo '\# ${FreeBSD:L:@v@$$$v$$ @:M*F*}'; + + * meta.autodep.mk: ignore dirdeps.cache* + + * meta.stage.mk: when bootstrapping options it can be handy to + throw warnings rather than errors for staging conflicts. + + * meta.sys.mk: include local.meta.sys.mk for customization + 2015-06-06 Simon J. Gerraty * install-mk (MK_VERSION): 20150606 diff --git a/contrib/bmake/mk/auto.obj.mk b/contrib/bmake/mk/auto.obj.mk index e25a721cdf69..fee3de29b7d5 100644 --- a/contrib/bmake/mk/auto.obj.mk +++ b/contrib/bmake/mk/auto.obj.mk @@ -1,4 +1,4 @@ -# $Id: auto.obj.mk,v 1.10 2015/04/16 16:59:00 sjg Exp $ +# $Id: auto.obj.mk,v 1.11 2015/06/16 06:28:21 sjg Exp $ # # @(#) Copyright (c) 2004, Simon J. Gerraty # @@ -40,7 +40,10 @@ MKOBJDIRS= auto .if !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto # Use __objdir here so it is easier to tweak without impacting # the logic. -__objdir?= ${MAKEOBJDIR} +.if !empty(MAKEOBJDIRPREFIX) && exists(${MAKEOBJDIRPREFIX}) +__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR} +.endif +__objdir?= ${MAKEOBJDIR:Uobj} __objdir:= ${__objdir:tA} .if ${.OBJDIR} != ${__objdir} # We need to chdir, make the directory if needed diff --git a/contrib/bmake/mk/dirdeps.mk b/contrib/bmake/mk/dirdeps.mk index 4aa101fbd8d0..823115d7a8ce 100644 --- a/contrib/bmake/mk/dirdeps.mk +++ b/contrib/bmake/mk/dirdeps.mk @@ -1,4 +1,4 @@ -# $Id: dirdeps.mk,v 1.54 2015/06/08 20:55:11 sjg Exp $ +# $Id: dirdeps.mk,v 1.55 2015/10/20 22:04:53 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -242,6 +242,21 @@ DEP_${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]} DEP_MACHINE := ${_DEP_TARGET_SPEC} .endif +.if ${MAKEFILE:T} == ${.PARSEFILE} && empty(DIRDEPS) && ${.TARGETS:Uall:M*/*} != "" +# This little trick let's us do +# +# mk -f dirdeps.mk some/dir.${TARGET_SPEC} +# +all: +${.TARGETS:Nall}: all +DIRDEPS := ${.TARGETS:M*/*} +# so that -DNO_DIRDEPS works +DEP_RELDIR := ${DIRDEPS:R:[1]} +# disable DIRDEPS_CACHE as it does not like this trick +MK_DIRDEPS_CACHE = no +.endif + + # pickup customizations # as below you can use !target(_DIRDEP_USE) to protect things # which should only be done once. diff --git a/contrib/bmake/mk/doc.mk b/contrib/bmake/mk/doc.mk index d496c42aeefb..d1385e9a4e82 100644 --- a/contrib/bmake/mk/doc.mk +++ b/contrib/bmake/mk/doc.mk @@ -1,4 +1,4 @@ -# $Id: doc.mk,v 1.4 2012/11/11 22:37:02 sjg Exp $ +# $Id: doc.mk,v 1.5 2015/09/08 06:15:31 sjg Exp $ .if !target(__${.PARSEFILE}__) __${.PARSEFILE}__: @@ -47,17 +47,19 @@ install: .else FILES?= ${SRCS} install: - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \ - Makefile ${FILES} ${EXTRA} ${DESTDIR}${BINDIR}/${DIR} + test -d ${DESTDIR}${DOCDIR}/${DIR} || \ + ${INSTALL} -d ${DOC_INSTALL_OWN} -m ${DIRMODE} ${DESTDIR}${DOCDIR}/${DIR} + ${INSTALL} ${COPY} ${DOC_INSTALL_OWN} -m ${DOCMODE} \ + Makefile ${FILES} ${EXTRA} ${DESTDIR}${DOCDIR}/${DIR} .endif spell: ${SRCS} spell ${SRCS} | sort | comm -23 - spell.ok > paper.spell -BINDIR?= /usr/share/doc -BINGRP?= bin -BINOWN?= bin -BINMODE?= 444 - .include + +.if !empty(DOCOWN) +DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOGGRP} +.endif + .endif diff --git a/contrib/bmake/mk/gendirdeps.mk b/contrib/bmake/mk/gendirdeps.mk index 614a20e3d451..2497f853c3b6 100644 --- a/contrib/bmake/mk/gendirdeps.mk +++ b/contrib/bmake/mk/gendirdeps.mk @@ -1,4 +1,4 @@ -# $Id: gendirdeps.mk,v 1.27 2015/06/08 20:55:11 sjg Exp $ +# $Id: gendirdeps.mk,v 1.29 2015/10/03 05:00:46 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -157,7 +157,7 @@ M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX} .endif # we are only interested in the dirs -# sepecifically those we read something from. +# specifically those we read something from. # we canonicalize them to keep things simple # if we are using a split-fs sandbox, it gets a little messier. _objtop := ${_OBJTOP:tA} @@ -310,7 +310,7 @@ CAT_DEPEND ?= .depend # The sed command at the end of the stream, allows for the filters # to output _{VAR} tokens which we will turn into proper ${VAR} references. ${_DEPENDFILE}: ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS} - @(echo '# Autogenerated - do NOT edit!'; echo; \ + @(${GENDIRDEPS_HEADER} echo '# Autogenerated - do NOT edit!'; echo; \ echo 'DIRDEPS = \'; \ echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \ ${_include_src_dirdeps} \ @@ -330,7 +330,7 @@ DIRDEPS := ${SUBDIR:S,^,${RELDIR}/,:O:u} all: ${_DEPENDFILE} ${_DEPENDFILE}: ${MAKEFILE} ${_this} - @(echo '# Autogenerated - do NOT edit!'; echo; \ + @(${GENDIRDEPS_HEADER} echo '# Autogenerated - do NOT edit!'; echo; \ echo 'DIRDEPS = \'; \ echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \ echo '.include '; \ diff --git a/contrib/bmake/mk/host-target.mk b/contrib/bmake/mk/host-target.mk index eacdf1d95111..b67c34d2523c 100644 --- a/contrib/bmake/mk/host-target.mk +++ b/contrib/bmake/mk/host-target.mk @@ -1,5 +1,5 @@ # RCSid: -# $Id: host-target.mk,v 1.7 2014/05/16 17:54:52 sjg Exp $ +# $Id: host-target.mk,v 1.9 2015/09/10 18:42:57 sjg Exp $ # Host platform information; may be overridden .if !defined(_HOST_OSNAME) @@ -10,16 +10,25 @@ _HOST_OSNAME != uname -s _HOST_OSREL != uname -r .export _HOST_OSREL .endif +.if !defined(_HOST_MACHINE) +_HOST_MACHINE != uname -m +.export _HOST_MACHINE +.endif .if !defined(_HOST_ARCH) -_HOST_ARCH != uname -p 2>/dev/null || uname -m +# for NetBSD prefer $MACHINE (amd64 rather than x86_64) +.if ${_HOST_OSNAME:NNetBSD} == "" +_HOST_ARCH := ${_HOST_MACHINE} +.else +_HOST_ARCH != uname -p 2> /dev/null || uname -m # uname -p may produce garbage on linux .if ${_HOST_ARCH:[\#]} > 1 -_HOST_ARCH != uname -m +_HOST_ARCH := ${_HOST_MACHINE} +.endif .endif .export _HOST_ARCH .endif .if !defined(HOST_MACHINE) -HOST_MACHINE != uname -m +HOST_MACHINE := ${_HOST_MACHINE} .export HOST_MACHINE .endif diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk index 05facd549ee9..eca75e00df66 100644 --- a/contrib/bmake/mk/install-mk +++ b/contrib/bmake/mk/install-mk @@ -55,7 +55,7 @@ # Simon J. Gerraty # RCSid: -# $Id: install-mk,v 1.112 2015/06/08 20:55:11 sjg Exp $ +# $Id: install-mk,v 1.115 2015/10/20 22:04:53 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -70,7 +70,7 @@ # sjg@crufty.net # -MK_VERSION=20150606 +MK_VERSION=20151020 OWNER= GROUP= MODE=444 diff --git a/contrib/bmake/mk/meta.autodep.mk b/contrib/bmake/mk/meta.autodep.mk index 64bc30bd4757..a062e47f92c8 100644 --- a/contrib/bmake/mk/meta.autodep.mk +++ b/contrib/bmake/mk/meta.autodep.mk @@ -1,4 +1,4 @@ -# $Id: meta.autodep.mk,v 1.36 2014/08/02 23:10:29 sjg Exp $ +# $Id: meta.autodep.mk,v 1.37 2015/06/16 06:29:17 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -97,6 +97,8 @@ UPDATE_DEPENDFILE = no # for example the result of running configure # just make sure this is not empty META_FILE_FILTER ?= N.meta +# never consider these +META_FILE_FILTER += Ndirdeps.cache* .if !empty(DPADD) # if we have any non-libs in DPADD, diff --git a/contrib/bmake/mk/meta.stage.mk b/contrib/bmake/mk/meta.stage.mk index 588f50e98204..4337c0eff5d7 100644 --- a/contrib/bmake/mk/meta.stage.mk +++ b/contrib/bmake/mk/meta.stage.mk @@ -1,4 +1,4 @@ -# $Id: meta.stage.mk,v 1.35 2015/05/20 06:40:33 sjg Exp $ +# $Id: meta.stage.mk,v 1.40 2015/10/04 17:36:54 sjg Exp $ # # @(#) Copyright (c) 2011, Simon J. Gerraty # @@ -23,6 +23,8 @@ _dirdep = ${RELDIR}.${MACHINE} _dirdep = ${RELDIR} .endif +CLEANFILES+= .dirdep + # this allows us to trace dependencies back to their src dir .dirdep: @echo '${_dirdep}' > $@ @@ -59,14 +61,23 @@ LN_CP_SCRIPT = LnCp() { \ ln $$1 $$2 2> /dev/null || \ cp -p $$1 $$2; } +# a staging conflict should cause an error +# a warning is handy when bootstapping different options. +STAGE_CONFLICT?= ERROR +.if ${STAGE_CONFLICT:tl} == "error" +STAGE_CONFLICT_ACTION= exit 1; +.else +STAGE_CONFLICT_ACTION= +.endif + # it is an error for more than one src dir to try and stage # the same file STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \ t=$$1; \ if [ -s $$t.dirdep ]; then \ cmp -s .dirdep $$t.dirdep && return; \ - echo "ERROR: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \ - exit 1; \ + echo "${STAGE_CONFLICT}: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \ + ${STAGE_CONFLICT_ACTION} \ fi; \ LnCp .dirdep $$t.dirdep || exit 1; } @@ -124,7 +135,7 @@ _STAGE_AS_BASENAME_USE: .USE ${.TARGET:T} .if !empty(STAGE_INCSDIR) STAGE_TARGETS += stage_incs -STAGE_INCS ?= ${.ALLSRC:N.dirdep} +STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*} stage_includes: stage_incs stage_incs: .dirdep @@ -135,7 +146,7 @@ stage_incs: .dirdep .if !empty(STAGE_LIBDIR) STAGE_TARGETS += stage_libs -STAGE_LIBS ?= ${.ALLSRC:N.dirdep} +STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*} stage_libs: .dirdep @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS} @@ -167,8 +178,8 @@ CLEANFILES += ${STAGE_SETS:@s@stage*$s@} # some makefiles need to populate multiple directories .for s in ${STAGE_SETS:O:u} -STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep} -STAGE_SYMLINKS.$s ?= ${.ALLSRC:N.dirdep} +STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} +STAGE_SYMLINKS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP} STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP} @@ -214,7 +225,7 @@ STAGE_TARGETS += stage_as # each ${file} will be staged as ${STAGE_AS_${file:T}} # one could achieve the same with SYMLINKS .for s in ${STAGE_AS_SETS:O:u} -STAGE_AS.$s ?= ${.ALLSRC:N.dirdep} +STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} stage_as: stage_as.$s stage_as.$s: .dirdep @@ -227,13 +238,15 @@ stage_as.$s: .dirdep CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes # stage_*links usually needs to follow any others. +# for non-jobs mode the order here matters +staging: ${STAGE_TARGETS:N*_links} ${STAGE_TARGETS:M*_links} + +.if ${.MAKE.JOBS:U0} > 0 && ${STAGE_TARGETS:M*_links} != "" +# the above isn't sufficient .for t in ${STAGE_TARGETS:N*links:O:u} .ORDER: $t stage_links -.ORDER: $t stage_symlinks .endfor - -# make sure this exists -staging: +.endif # generally we want staging to wait until everything else is done STAGING_WAIT ?= .WAIT diff --git a/contrib/bmake/mk/meta.sys.mk b/contrib/bmake/mk/meta.sys.mk index 1f7ac49dae07..1d1ba5338a10 100644 --- a/contrib/bmake/mk/meta.sys.mk +++ b/contrib/bmake/mk/meta.sys.mk @@ -1,4 +1,4 @@ -# $Id: meta.sys.mk,v 1.21 2015/06/01 22:43:49 sjg Exp $ +# $Id: meta.sys.mk,v 1.22 2015/06/16 06:31:05 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -20,6 +20,10 @@ .if ${MAKE_VERSION:U0} > 20100901 .if !target(.ERROR) +.-include "local.meta.sys.mk" + +# absoulte path to what we are reading. +_PARSEDIR = ${.PARSEDIR:tA} META_MODE += meta verbose .MAKE.MODE ?= ${META_MODE} @@ -69,6 +73,7 @@ MACHINE = host # for example, if using Makefild.depend for multiple machines, # allowing only MACHINE0 to update can keep things simple. MACHINE0 := ${MACHINE} +.export MACHINE0 .if defined(PYTHON) && exists(${PYTHON}) # we prefer the python version of this - it is much faster diff --git a/contrib/bmake/mk/own.mk b/contrib/bmake/mk/own.mk index f090bbe8e537..3fdb16bcfc9a 100644 --- a/contrib/bmake/mk/own.mk +++ b/contrib/bmake/mk/own.mk @@ -1,4 +1,4 @@ -# $Id: own.mk,v 1.28 2015/04/16 16:59:00 sjg Exp $ +# $Id: own.mk,v 1.29 2015/09/08 06:15:31 sjg Exp $ .if !target(__${.PARSEFILE}__) __${.PARSEFILE}__: @@ -133,7 +133,9 @@ USERGRP!= id -g .for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE $xOWN= ${USER} $xGRP= ${USERGRP} +$x_INSTALL_OWN= .endfor +PROG_INSTALL_OWN= .endif .endif @@ -143,6 +145,7 @@ BINGRP?= ${ROOT_GROUP} BINOWN?= root BINMODE?= 555 NONBINMODE?= 444 +DIRMODE?= 755 # Define MANZ to have the man pages compressed (gzip) #MANZ= 1 diff --git a/contrib/bmake/mk/rst2htm.mk b/contrib/bmake/mk/rst2htm.mk index 4d4c940b8bc7..296b73c68574 100644 --- a/contrib/bmake/mk/rst2htm.mk +++ b/contrib/bmake/mk/rst2htm.mk @@ -1,4 +1,4 @@ -# $Id: rst2htm.mk,v 1.9 2014/02/22 01:52:41 sjg Exp $ +# $Id: rst2htm.mk,v 1.10 2015/09/08 22:17:46 sjg Exp $ # # @(#) Copyright (c) 2009, Simon J. Gerraty # @@ -26,7 +26,12 @@ RST2PDF ?= rst2pdf RST2S5 ?= rst2s5.py # the following will run RST2S5 if the target name contains the word 'slides' # otherwise it uses RST2HTML -RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5} ${RST2S5_FLAGS}:${RST2HTML} ${RST2HTML_FLAGS}} +RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}} +RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS} +RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS} +RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}} + +RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}} RST_SUFFIXES ?= .rst .txt @@ -37,10 +42,10 @@ html: ${HTMFILES} .SUFFIXES: ${RST_SUFFIXES} .htm .pdf ${RST_SUFFIXES:@s@$s.htm@}: - ${RST2HTM} ${.IMPSRC} ${.TARGET} + ${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET} ${RST_SUFFIXES:@s@$s.pdf@}: - ${RST2PDF} ${.IMPSRC} ${.TARGET} + ${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET} .for s in ${RSTSRCS:O:u} ${s:R:T}.htm: $s diff --git a/contrib/bmake/nonints.h b/contrib/bmake/nonints.h index 9eaebc2e9b4b..2332858c25cc 100644 --- a/contrib/bmake/nonints.h +++ b/contrib/bmake/nonints.h @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.68 2015/05/05 21:51:09 sjg Exp $ */ +/* $NetBSD: nonints.h,v 1.69 2015/10/11 04:51:24 sjg Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -184,8 +184,8 @@ void Var_Set(const char *, const char *, GNode *, int); void Var_Append(const char *, const char *, GNode *); Boolean Var_Exists(const char *, GNode *); char *Var_Value(const char *, GNode *, char **); -char *Var_Parse(const char *, GNode *, Boolean, int *, void **); -char *Var_Subst(const char *, const char *, GNode *, Boolean); +char *Var_Parse(const char *, GNode *, Boolean, Boolean, int *, void **); +char *Var_Subst(const char *, const char *, GNode *, Boolean, Boolean); char *Var_GetTail(const char *); char *Var_GetHead(const char *); void Var_Init(void); diff --git a/contrib/bmake/os.sh b/contrib/bmake/os.sh index b714eb782cec..1df67b8cd7c3 100755 --- a/contrib/bmake/os.sh +++ b/contrib/bmake/os.sh @@ -17,7 +17,7 @@ # Simon J. Gerraty # RCSid: -# $Id: os.sh,v 1.46 2014/05/19 16:38:09 sjg Exp $ +# $Id: os.sh,v 1.47 2015/09/10 05:53:10 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -137,7 +137,10 @@ SunOS) # NetBSD at least has good backward compatibility # so NetBSD/i386 is good enough case $OS in - NetBSD) SHARE_ARCH=$OS/${MACHINE_ARCH:-$MACHINE};; + NetBSD) + HOST_ARCH=$MACHINE + SHARE_ARCH=$OS/$HOST + ;; OpenBSD) arch=`Which arch /usr/bin:/usr/ucb:$PATH` MACHINE_ARCH=`$arch -s` @@ -203,13 +206,14 @@ esac TMP_DIRS=${TMP_DIRS:-"/tmp /var/tmp"} MACHINE_ARCH=${MACHINE_ARCH:-$MACHINE} +HOST_ARCH=${HOST_ARCH:-$MACHINE_ARCH} # we mount server:/share/arch/$SHARE_ARCH as /usr/local -SHARE_ARCH=${SHARE_ARCH:-$OS/$OSMAJOR.X/$MACHINE_ARCH} +SHARE_ARCH=${SHARE_ARCH:-$OS/$OSMAJOR.X/$HOST_ARCH} LN=${LN:-ln} TR=${TR:-tr} # Some people like have /share/$HOST_TARGET/bin etc. -HOST_TARGET=`echo ${OS}${OSMAJOR}-${MACHINE_ARCH} | toLower` +HOST_TARGET=`echo ${OS}${OSMAJOR}-$HOST_ARCH | toLower` export HOST_TARGET case `echo -n .` in -n*) N=; C="\c";; *) N=-n; C=;; esac diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c index a55582ec1cd2..171847019acd 100644 --- a/contrib/bmake/parse.c +++ b/contrib/bmake/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $ */ +/* $NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $"); +__RCSID("$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -812,7 +812,7 @@ ParseMessage(char *line) while (isspace((u_char)*line)) line++; - line = Var_Subst(NULL, line, VAR_CMD, 0); + line = Var_Subst(NULL, line, VAR_CMD, FALSE, TRUE); Parse_Error(mtype, "%s", line); free(line); @@ -1229,7 +1229,7 @@ ParseDoDependency(char *line) int length; void *freeIt; - (void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt); + (void)Var_Parse(cp, VAR_CMD, TRUE, TRUE, &length, &freeIt); if (freeIt) free(freeIt); cp += length-1; @@ -1944,7 +1944,7 @@ Parse_DoVar(char *line, GNode *ctxt) if (!Var_Exists(line, ctxt)) Var_Set(line, "", ctxt, 0); - cp = Var_Subst(NULL, cp, ctxt, FALSE); + cp = Var_Subst(NULL, cp, ctxt, FALSE, TRUE); oldVars = oldOldVars; freeCp = TRUE; @@ -1959,7 +1959,7 @@ Parse_DoVar(char *line, GNode *ctxt) * expansion on the whole thing. The resulting string will need * freeing when we're done, so set freeCmd to TRUE. */ - cp = Var_Subst(NULL, cp, VAR_CMD, TRUE); + cp = Var_Subst(NULL, cp, VAR_CMD, TRUE, TRUE); freeCp = TRUE; } @@ -2298,7 +2298,7 @@ ParseDoInclude(char *line) * Substitute for any variables in the file name before trying to * find the thing. */ - file = Var_Subst(NULL, file, VAR_CMD, FALSE); + file = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE); Parse_include_file(file, endc == '>', silent); free(file); @@ -2524,7 +2524,7 @@ ParseTraditionalInclude(char *line) * Substitute for any variables in the file name before trying to * find the thing. */ - all_files = Var_Subst(NULL, file, VAR_CMD, FALSE); + all_files = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE); if (*file == '\0') { Parse_Error(PARSE_FATAL, @@ -2592,7 +2592,7 @@ ParseGmakeExport(char *line) /* * Expand the value before putting it in the environment. */ - value = Var_Subst(NULL, value, VAR_CMD, FALSE); + value = Var_Subst(NULL, value, VAR_CMD, FALSE, TRUE); setenv(variable, value, 1); } #endif @@ -3141,7 +3141,7 @@ Parse_File(const char *name, int fd) * variables expanded before being parsed. Tell the variable * module to complain if some variable is undefined... */ - line = Var_Subst(NULL, line, VAR_CMD, TRUE); + line = Var_Subst(NULL, line, VAR_CMD, TRUE, TRUE); /* * Need a non-circular list for the target nodes diff --git a/contrib/bmake/suff.c b/contrib/bmake/suff.c index c42d2ec57e8f..15a3cc87cbc0 100644 --- a/contrib/bmake/suff.c +++ b/contrib/bmake/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.73 2014/09/07 20:55:34 joerg Exp $ */ +/* $NetBSD: suff.c,v 1.74 2015/10/11 04:51:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.73 2014/09/07 20:55:34 joerg Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.74 2015/10/11 04:51:24 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.73 2014/09/07 20:55:34 joerg Exp $"); +__RCSID("$NetBSD: suff.c,v 1.74 2015/10/11 04:51:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -1543,7 +1543,7 @@ SuffExpandChildren(LstNode cln, GNode *pgn) if (DEBUG(SUFF)) { fprintf(debug_file, "Expanding \"%s\"...", cgn->name); } - cp = Var_Subst(NULL, cgn->name, pgn, TRUE); + cp = Var_Subst(NULL, cgn->name, pgn, TRUE, TRUE); if (cp != NULL) { Lst members = Lst_Init(FALSE); @@ -1596,7 +1596,7 @@ SuffExpandChildren(LstNode cln, GNode *pgn) int len; void *freeIt; - junk = Var_Parse(cp, pgn, TRUE, &len, &freeIt); + junk = Var_Parse(cp, pgn, TRUE, TRUE, &len, &freeIt); if (junk != var_Error) { cp += len - 1; } diff --git a/contrib/bmake/unit-tests/varmisc.exp b/contrib/bmake/unit-tests/varmisc.exp index 1636aafc11e5..e2af496afabe 100644 --- a/contrib/bmake/unit-tests/varmisc.exp +++ b/contrib/bmake/unit-tests/varmisc.exp @@ -1,2 +1,20 @@ +:D expanded when var set +true +TRUE +:U expanded when var undef +true +TRUE +:D skipped if var undef + +:U skipped when var set +is set +:? only lhs when value true +true +TRUE +:? only rhs when value false +false +FALSE +do not evaluate or expand :? if discarding +is set exit status 0 diff --git a/contrib/bmake/unit-tests/varmisc.mk b/contrib/bmake/unit-tests/varmisc.mk index 4b4a931a37ac..14b52d22c3e6 100644 --- a/contrib/bmake/unit-tests/varmisc.mk +++ b/contrib/bmake/unit-tests/varmisc.mk @@ -1,8 +1,42 @@ -# $Id: varmisc.mk,v 1.2 2014/08/30 22:25:14 sjg Exp $ +# $Id: varmisc.mk,v 1.5 2015/10/12 17:10:48 sjg Exp $ # # Miscellaneous variable tests. -all: unmatched_var_paren +all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none unmatched_var_paren: @echo ${foo::=foo-text} + +True = ${echo true >&2:L:sh}TRUE +False= ${echo false >&2:L:sh}FALSE + +VSET= is set +.undef UNDEF + +U_false: + @echo :U skipped when var set + @echo ${VSET:U${False}} + +D_false: + @echo :D skipped if var undef + @echo ${UNDEF:D${False}} + +U_true: + @echo :U expanded when var undef + @echo ${UNDEF:U${True}} + +D_true: + @echo :D expanded when var set + @echo ${VSET:D${True}} + +Q_lhs: + @echo :? only lhs when value true + @echo ${1:L:?${True}:${False}} + +Q_rhs: + @echo :? only rhs when value false + @echo ${0:L:?${True}:${False}} + +NQ_none: + @echo do not evaluate or expand :? if discarding + @echo ${VSET:U${1:L:?${True}:${False}}} diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c index e15c301cf9cf..6fd3825066e3 100644 --- a/contrib/bmake/var.c +++ b/contrib/bmake/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $ */ +/* $NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.199 2015/10/20 21:30:57 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -138,6 +138,7 @@ __RCSID("$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $"); #include "buf.h" #include "dir.h" #include "job.h" +#include "metachar.h" extern int makelevel; /* @@ -541,7 +542,7 @@ Var_Delete(const char *name, GNode *ctxt) char *cp; if (strchr(name, '$')) { - cp = Var_Subst(NULL, name, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, name, VAR_GLOBAL, FALSE, TRUE); } else { cp = (char *)name; } @@ -632,7 +633,7 @@ Var_Export1(const char *name, int parent) } n = snprintf(tmp, sizeof(tmp), "${%s}", name); if (n < (int)sizeof(tmp)) { - val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); setenv(name, val, 1); free(val); } @@ -700,7 +701,7 @@ Var_ExportVars(void) int ac; int i; - val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); av = brk_string(val, &ac, FALSE, &as); for (i = 0; i < ac; i++) { Var_Export1(av[i], 0); @@ -738,7 +739,7 @@ Var_Export(char *str, int isExport) } else { track = VAR_EXPORT_PARENT; } - val = Var_Subst(NULL, str, VAR_GLOBAL, 0); + val = Var_Subst(NULL, str, VAR_GLOBAL, FALSE, TRUE); av = brk_string(val, &ac, FALSE, &as); for (i = 0; i < ac; i++) { name = av[i]; @@ -826,7 +827,7 @@ Var_UnExport(char *str) /* Using .MAKE.EXPORTED */ n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}"); if (n < (int)sizeof(tmp)) { - vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); } } if (vlist) { @@ -856,7 +857,7 @@ Var_UnExport(char *str) n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":N%s}", v->name); if (n < (int)sizeof(tmp)) { - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL, 0); free(cp); } @@ -911,7 +912,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) * point in searching them all just to save a bit of memory... */ if (strchr(name, '$') != NULL) { - expanded_name = Var_Subst(NULL, name, ctxt, 0); + expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE); if (expanded_name[0] == 0) { if (DEBUG(VAR)) { fprintf(debug_file, "Var_Set(\"%s\", \"%s\", ...) " @@ -982,8 +983,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) out: - if (expanded_name != NULL) - free(expanded_name); + free(expanded_name); if (v != NULL) VarFreeEnv(v, TRUE); } @@ -1023,7 +1023,7 @@ Var_Append(const char *name, const char *val, GNode *ctxt) char *expanded_name = NULL; if (strchr(name, '$') != NULL) { - expanded_name = Var_Subst(NULL, name, ctxt, 0); + expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE); if (expanded_name[0] == 0) { if (DEBUG(VAR)) { fprintf(debug_file, "Var_Append(\"%s\", \"%s\", ...) " @@ -1061,8 +1061,7 @@ Var_Append(const char *name, const char *val, GNode *ctxt) Hash_SetValue(h, v); } } - if (expanded_name != NULL) - free(expanded_name); + free(expanded_name); } /*- @@ -1089,12 +1088,10 @@ Var_Exists(const char *name, GNode *ctxt) char *cp; if ((cp = strchr(name, '$')) != NULL) { - cp = Var_Subst(NULL, name, ctxt, FALSE); + cp = Var_Subst(NULL, name, ctxt, FALSE, TRUE); } v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); - if (cp != NULL) { - free(cp); - } + free(cp); if (v == NULL) { return(FALSE); } else { @@ -1389,7 +1386,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate, addSpace = TRUE; if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) { - varexp = Var_Subst(NULL, pat->rhs, ctx, 0); + varexp = Var_Subst(NULL, pat->rhs, ctx, FALSE, TRUE); Str_SYSVSubst(buf, varexp, ptr, len); free(varexp); } else { @@ -1809,7 +1806,7 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED, if (word && *word) { Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT); - s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum); + s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum, TRUE); if (s != NULL && *s != '\0') { if (addSpace && *s != '\n') Buf_AddByte(buf, ' '); @@ -2190,10 +2187,9 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, * delimiter, assume it's a variable * substitution and recurse. */ - cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt); + cp2 = Var_Parse(cp, ctxt, errnum, TRUE, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); - if (freeIt) - free(freeIt); + free(freeIt); cp += len - 1; } else { const char *cp2 = &cp[1]; @@ -2246,7 +2242,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, /*- *----------------------------------------------------------------------- * VarQuote -- - * Quote shell meta-characters in the string + * Quote shell meta-characters and space characters in the string * * Results: * The quoted string @@ -2261,29 +2257,25 @@ VarQuote(char *str) { Buffer buf; - /* This should cover most shells :-( */ - static const char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~"; const char *newline; - size_t len, nlen; + size_t nlen; if ((newline = Shell_GetNewline()) == NULL) newline = "\\\n"; nlen = strlen(newline); Buf_Init(&buf, 0); - while (*str != '\0') { - if ((len = strcspn(str, meta)) != 0) { - Buf_AddBytes(&buf, len, str); - str += len; - } else if (*str == '\n') { + + for (; *str != '\0'; str++) { + if (*str == '\n') { Buf_AddBytes(&buf, nlen, newline); - ++str; - } else { - Buf_AddByte(&buf, '\\'); - Buf_AddByte(&buf, *str); - ++str; + continue; } + if (isspace((unsigned char)*str) || ismeta((unsigned char)*str)) + Buf_AddByte(&buf, '\\'); + Buf_AddByte(&buf, *str); } + str = Buf_Destroy(&buf, FALSE); if (DEBUG(VAR)) fprintf(debug_file, "QuoteMeta: [%s]\n", str); @@ -2468,7 +2460,7 @@ VarStrftime(const char *fmt, int zulu) static char * ApplyModifiers(char *nstr, const char *tstr, int startc, int endc, - Var *v, GNode *ctxt, Boolean errnum, + Var *v, GNode *ctxt, Boolean errnum, Boolean wantit, int *lengthPtr, void **freePtr) { const char *start; @@ -2499,7 +2491,7 @@ ApplyModifiers(char *nstr, const char *tstr, int rlen; int c; - rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt); + rval = Var_Parse(tstr, ctxt, errnum, wantit, &rlen, &freeIt); /* * If we have not parsed up to endc or ':', @@ -2509,8 +2501,7 @@ ApplyModifiers(char *nstr, const char *tstr, (c = tstr[rlen]) != '\0' && c != ':' && c != endc) { - if (freeIt) - free(freeIt); + free(freeIt); goto apply_mods; } @@ -2526,17 +2517,15 @@ ApplyModifiers(char *nstr, const char *tstr, nstr = ApplyModifiers(nstr, rval, 0, 0, - v, ctxt, errnum, &used, freePtr); + v, ctxt, errnum, wantit, &used, freePtr); if (nstr == var_Error || (nstr == varNoError && errnum == 0) || strlen(rval) != (size_t) used) { - if (freeIt) - free(freeIt); + free(freeIt); goto out; /* error already reported */ } } - if (freeIt) - free(freeIt); + free(freeIt); if (*tstr == ':') tstr++; else if (!*tstr && endc) { @@ -2565,6 +2554,7 @@ ApplyModifiers(char *nstr, const char *tstr, char *sv_name; VarPattern pattern; int how; + int flags; if (v->name[0] == 0) goto bad_modifier; @@ -2600,8 +2590,9 @@ ApplyModifiers(char *nstr, const char *tstr, delim = startc == PROPEN ? PRCLOSE : BRCLOSE; pattern.flags = 0; + flags = (wantit) ? 0 : VAR_NOSUBST; pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, - &cp, delim, NULL, + &cp, delim, &flags, &pattern.rightLen, NULL); if (v->flags & VAR_JUNK) { @@ -2615,26 +2606,27 @@ ApplyModifiers(char *nstr, const char *tstr, termc = *--cp; delim = '\0'; - switch (how) { - case '+': - Var_Append(v->name, pattern.rhs, v_ctxt); - break; - case '!': - newStr = Cmd_Exec(pattern.rhs, &emsg); - if (emsg) - Error(emsg, nstr); - else - Var_Set(v->name, newStr, v_ctxt, 0); - if (newStr) - free(newStr); - break; - case '?': - if ((v->flags & VAR_JUNK) == 0) + if (wantit) { + switch (how) { + case '+': + Var_Append(v->name, pattern.rhs, v_ctxt); break; - /* FALLTHROUGH */ - default: - Var_Set(v->name, pattern.rhs, v_ctxt, 0); - break; + case '!': + newStr = Cmd_Exec(pattern.rhs, &emsg); + if (emsg) + Error(emsg, nstr); + else + Var_Set(v->name, newStr, v_ctxt, 0); + free(newStr); + break; + case '?': + if ((v->flags & VAR_JUNK) == 0) + break; + /* FALLTHROUGH */ + default: + Var_Set(v->name, pattern.rhs, v_ctxt, 0); + break; + } } free(UNCONST(pattern.rhs)); newStr = varNoError; @@ -2676,8 +2668,15 @@ ApplyModifiers(char *nstr, const char *tstr, case 'U': { Buffer buf; /* Buffer for patterns */ - int wantit; /* want data in buffer */ + int wantit_; /* want data in buffer */ + if (wantit) { + if (*tstr == 'U') + wantit_ = ((v->flags & VAR_JUNK) != 0); + else + wantit_ = ((v->flags & VAR_JUNK) == 0); + } else + wantit_ = wantit; /* * Pass through tstr looking for 1) escaped delimiters, * '$'s and backslashes (place the escaped character in @@ -2706,10 +2705,9 @@ ApplyModifiers(char *nstr, const char *tstr, int len; void *freeIt; - cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt); + cp2 = Var_Parse(cp, ctxt, errnum, wantit_, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); - if (freeIt) - free(freeIt); + free(freeIt); cp += len - 1; } else { Buf_AddByte(&buf, *cp); @@ -2718,13 +2716,9 @@ ApplyModifiers(char *nstr, const char *tstr, termc = *cp; - if (*tstr == 'U') - wantit = ((v->flags & VAR_JUNK) != 0); - else - wantit = ((v->flags & VAR_JUNK) == 0); if ((v->flags & VAR_JUNK) != 0) v->flags |= VAR_KEEP; - if (wantit) { + if (wantit_) { newStr = Buf_Destroy(&buf, FALSE); } else { newStr = nstr; @@ -2769,14 +2763,17 @@ ApplyModifiers(char *nstr, const char *tstr, pattern.flags = 0; delim = '!'; - + emsg = NULL; cp = ++tstr; if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, &cp, delim, NULL, &pattern.rightLen, NULL)) == NULL) goto cleanup; - newStr = Cmd_Exec(pattern.rhs, &emsg); + if (wantit) + newStr = Cmd_Exec(pattern.rhs, &emsg); + else + newStr = varNoError; free(UNCONST(pattern.rhs)); if (emsg) Error(emsg, nstr); @@ -3152,7 +3149,7 @@ ApplyModifiers(char *nstr, const char *tstr, * expand it. */ cp2 = pattern; - pattern = Var_Subst(NULL, cp2, ctxt, errnum); + pattern = Var_Subst(NULL, cp2, ctxt, errnum, TRUE); free(cp2); } if (DEBUG(VAR)) @@ -3238,15 +3235,32 @@ ApplyModifiers(char *nstr, const char *tstr, { VarPattern pattern; Boolean value; - + int cond_rc; + int lhs_flags, rhs_flags; + /* find ':', and then substitute accordingly */ - + if (wantit) { + cond_rc = Cond_EvalExpression(NULL, v->name, &value, 0, FALSE); + if (cond_rc == COND_INVALID) { + lhs_flags = rhs_flags = VAR_NOSUBST; + } else if (value) { + lhs_flags = 0; + rhs_flags = VAR_NOSUBST; + } else { + lhs_flags = VAR_NOSUBST; + rhs_flags = 0; + } + } else { + /* we are just consuming and discarding */ + cond_rc = value = 0; + lhs_flags = rhs_flags = VAR_NOSUBST; + } pattern.flags = 0; cp = ++tstr; delim = ':'; if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum, - &cp, delim, NULL, + &cp, delim, &lhs_flags, &pattern.leftLen, NULL)) == NULL) goto cleanup; @@ -3254,15 +3268,14 @@ ApplyModifiers(char *nstr, const char *tstr, /* BROPEN or PROPEN */ delim = endc; if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, - &cp, delim, NULL, + &cp, delim, &rhs_flags, &pattern.rightLen, NULL)) == NULL) goto cleanup; termc = *--cp; delim = '\0'; - if (Cond_EvalExpression(NULL, v->name, &value, 0, FALSE) - == COND_INVALID) { + if (cond_rc == COND_INVALID) { Error("Bad conditional expression `%s' in %s?%s:%s", v->name, v->name, pattern.lhs, pattern.rhs); goto cleanup; @@ -3424,9 +3437,12 @@ ApplyModifiers(char *nstr, const char *tstr, case 's': if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) { const char *emsg; - newStr = Cmd_Exec(nstr, &emsg); - if (emsg) - Error(emsg, nstr); + if (wantit) { + newStr = Cmd_Exec(nstr, &emsg); + if (emsg) + Error(emsg, nstr); + } else + newStr = varNoError; cp = tstr + 2; termc = *cp; break; @@ -3547,10 +3563,8 @@ ApplyModifiers(char *nstr, const char *tstr, if (delim != '\0') Error("Unclosed substitution for %s (%c missing)", v->name, delim); - if (*freePtr) { - free(*freePtr); - *freePtr = NULL; - } + free(*freePtr); + *freePtr = NULL; return (var_Error); } @@ -3565,6 +3579,7 @@ ApplyModifiers(char *nstr, const char *tstr, * str The string to parse * ctxt The context for the variable * errnum TRUE if undefined variables are an error + * wantit TRUE if we actually want the result * lengthPtr OUT: The length of the specification * freePtr OUT: Non-NULL if caller should free *freePtr * @@ -3583,8 +3598,9 @@ ApplyModifiers(char *nstr, const char *tstr, */ /* coverity[+alloc : arg-*4] */ char * -Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, - void **freePtr) +Var_Parse(const char *str, GNode *ctxt, + Boolean errnum, Boolean wantit, + int *lengthPtr, void **freePtr) { const char *tstr; /* Pointer into str */ Var *v; /* Variable in invocation */ @@ -3689,12 +3705,11 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, if (*tstr == '$') { int rlen; void *freeIt; - char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt); + char *rval = Var_Parse(tstr, ctxt, errnum, wantit, &rlen, &freeIt); if (rval != NULL) { Buf_AddBytes(&buf, strlen(rval), rval); } - if (freeIt) - free(freeIt); + free(freeIt); tstr += rlen - 1; } else @@ -3837,7 +3852,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, */ nstr = Buf_GetAll(&v->val, NULL); if (strchr(nstr, '$') != NULL) { - nstr = Var_Subst(NULL, nstr, ctxt, errnum); + nstr = Var_Subst(NULL, nstr, ctxt, errnum, wantit); *freePtr = nstr; } @@ -3850,7 +3865,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, extraFree = NULL; if (extramodifiers != NULL) { nstr = ApplyModifiers(nstr, extramodifiers, '(', ')', - v, ctxt, errnum, &used, &extraFree); + v, ctxt, errnum, wantit, &used, &extraFree); } if (haveModifier) { @@ -3858,11 +3873,9 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, tstr++; nstr = ApplyModifiers(nstr, tstr, startc, endc, - v, ctxt, errnum, &used, freePtr); + v, ctxt, errnum, wantit, &used, freePtr); tstr += used; - if (extraFree) { - free(extraFree); - } + free(extraFree); } else { *freePtr = extraFree; } @@ -3924,6 +3937,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, * str the string which to substitute * ctxt the context wherein to find variables * undefErr TRUE if undefineds are an error + * wantit TRUE if we actually want the result * * Results: * The resulting string. @@ -3933,7 +3947,8 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, *----------------------------------------------------------------------- */ char * -Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) +Var_Subst(const char *var, const char *str, GNode *ctxt, + Boolean undefErr, Boolean wantit) { Buffer buf; /* Buffer for forming things */ char *val; /* Value to substitute for a variable */ @@ -4031,7 +4046,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) continue; } - val = Var_Parse(str, ctxt, undefErr, &length, &freeIt); + val = Var_Parse(str, ctxt, undefErr, wantit, &length, &freeIt); /* * When we come down here, val should either point to the @@ -4079,10 +4094,8 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) Buf_AddBytes(&buf, length, val); trailingBslash = length > 0 && val[length - 1] == '\\'; } - if (freeIt) { - free(freeIt); - freeIt = NULL; - } + free(freeIt); + freeIt = NULL; } } diff --git a/contrib/gdb/gdb/arm-tdep.c b/contrib/gdb/gdb/arm-tdep.c index 128219f6ee46..cec90617439f 100644 --- a/contrib/gdb/gdb/arm-tdep.c +++ b/contrib/gdb/gdb/arm-tdep.c @@ -2580,6 +2580,21 @@ arm_elf_osabi_sniffer (bfd *abfd) osabi = GDB_OSABI_ARM_EABI_V2; break; + case EF_ARM_EABI_VER3: + case EF_ARM_EABI_VER4: + case EF_ARM_EABI_VER5: + /* + * GDB does not support these EABI versions. Fallback + * to the highest known to make the KGDB working with + * kernel ELF image. + */ + osabi = GDB_OSABI_ARM_EABI_V2; + printf ("\n%s:%d " + "arm_elf_osabi_sniffer: Unsupported ARM EABI " + "version 0x%x, falling back to 0x%x\n", + __FILE__, __LINE__, eflags, EF_ARM_EABI_VER2); + break; + case EF_ARM_EABI_UNKNOWN: /* Assume GNU tools. */ osabi = GDB_OSABI_ARM_APCS; diff --git a/contrib/groff/tmac/doc-syms b/contrib/groff/tmac/doc-syms index 4e736cb5ac2c..e89b658a2ca9 100644 --- a/contrib/groff/tmac/doc-syms +++ b/contrib/groff/tmac/doc-syms @@ -780,7 +780,6 @@ .ds doc-str-Lb-libfetch File Transfer Library for URLs (libfetch, \-lfetch) .ds doc-str-Lb-libform Curses Form Library (libform, \-lform) .ds doc-str-Lb-libgeom Userland API Library for kernel GEOM subsystem (libgeom, \-lgeom) -.ds doc-str-Lb-libgpib General-Purpose Instrument Bus (GPIB) library (libgpib, \-lgpib) .ds doc-str-Lb-libi386 i386 Architecture Library (libi386, \-li386) .ds doc-str-Lb-libintl Internationalized Message Handling Library (libintl, \-lintl) .ds doc-str-Lb-libipsec IPsec Policy Control Library (libipsec, \-lipsec) diff --git a/contrib/groff/tmac/groff_mdoc.man b/contrib/groff/tmac/groff_mdoc.man index c3ad6b4266dd..b9d0c3675154 100644 --- a/contrib/groff/tmac/groff_mdoc.man +++ b/contrib/groff/tmac/groff_mdoc.man @@ -1732,8 +1732,6 @@ and their results are: .Lb libform .It Li libgeom .Lb libgeom -.It Li libgpib -.Lb libgpib .It Li libi386 .Lb libi386 .It Li libintl diff --git a/contrib/jemalloc/ChangeLog b/contrib/jemalloc/ChangeLog index 58e4462be07a..8ed42cbeadb4 100644 --- a/contrib/jemalloc/ChangeLog +++ b/contrib/jemalloc/ChangeLog @@ -4,6 +4,32 @@ brevity. Much more detail can be found in the git revision history: https://github.com/jemalloc/jemalloc +* 4.0.4 (October 24, 2015) + + This bugfix release fixes another xallocx() regression. No other regressions + have come to light in over a month, so this is likely a good starting point + for people who prefer to wait for "dot one" releases with all the major issues + shaken out. + + Bug fixes: + - Fix xallocx(..., MALLOCX_ZERO to zero the last full trailing page of large + allocations that have been randomly assigned an offset of 0 when + --enable-cache-oblivious configure option is enabled. + +* 4.0.3 (September 24, 2015) + + This bugfix release continues the trend of xallocx() and heap profiling fixes. + + Bug fixes: + - Fix xallocx(..., MALLOCX_ZERO) to zero all trailing bytes of large + allocations when --enable-cache-oblivious configure option is enabled. + - Fix xallocx(..., MALLOCX_ZERO) to zero trailing bytes of huge allocations + when resizing from/to a size class that is not a multiple of the chunk size. + - Fix prof_tctx_dump_iter() to filter out nodes that were created after heap + profile dumping started. + - Work around a potentially bad thread-specific data initialization + interaction with NPTL (glibc's pthreads implementation). + * 4.0.2 (September 21, 2015) This bugfix release addresses a few bugs specific to heap profiling. diff --git a/contrib/jemalloc/FREEBSD-diffs b/contrib/jemalloc/FREEBSD-diffs index 25e823c60dfe..5700c51dc251 100644 --- a/contrib/jemalloc/FREEBSD-diffs +++ b/contrib/jemalloc/FREEBSD-diffs @@ -1,5 +1,5 @@ diff --git a/doc/jemalloc.xml.in b/doc/jemalloc.xml.in -index 8fc774b..fdbef95 100644 +index 26a5e14..2a801b7 100644 --- a/doc/jemalloc.xml.in +++ b/doc/jemalloc.xml.in @@ -53,11 +53,23 @@ @@ -47,7 +47,7 @@ index 8fc774b..fdbef95 100644 + diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in -index 8536a3e..0c2a81f 100644 +index 654cd08..ad5382d 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -8,6 +8,9 @@ diff --git a/contrib/jemalloc/VERSION b/contrib/jemalloc/VERSION index 210a4fef248a..f9b6da92d8db 100644 --- a/contrib/jemalloc/VERSION +++ b/contrib/jemalloc/VERSION @@ -1 +1 @@ -4.0.2-0-g486d249fb4715fd3de679b6c2a04f7e657883111 +4.0.4-0-g91010a9e2ebfc84b1ac1ed7fdde3bfed4f65f180 diff --git a/contrib/jemalloc/doc/jemalloc.3 b/contrib/jemalloc/doc/jemalloc.3 index 258206212381..57e163db2ccd 100644 --- a/contrib/jemalloc/doc/jemalloc.3 +++ b/contrib/jemalloc/doc/jemalloc.3 @@ -2,12 +2,12 @@ .\" Title: JEMALLOC .\" Author: Jason Evans .\" Generator: DocBook XSL Stylesheets v1.76.1 -.\" Date: 09/21/2015 +.\" Date: 10/24/2015 .\" Manual: User Manual -.\" Source: jemalloc 4.0.2-0-g486d249fb4715fd3de679b6c2a04f7e657883111 +.\" Source: jemalloc 4.0.4-0-g91010a9e2ebfc84b1ac1ed7fdde3bfed4f65f180 .\" Language: English .\" -.TH "JEMALLOC" "3" "09/21/2015" "jemalloc 4.0.2-0-g486d249fb471" "User Manual" +.TH "JEMALLOC" "3" "10/24/2015" "jemalloc 4.0.4-0-g91010a9e2ebf" "User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,7 +31,7 @@ jemalloc \- general purpose memory allocation functions .SH "LIBRARY" .PP -This manual describes jemalloc 4\&.0\&.2\-0\-g486d249fb4715fd3de679b6c2a04f7e657883111\&. More information can be found at the +This manual describes jemalloc 4\&.0\&.4\-0\-g91010a9e2ebfc84b1ac1ed7fdde3bfed4f65f180\&. More information can be found at the \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&. .PP The following configuration options are enabled in libc\*(Aqs built\-in jemalloc: @@ -1041,7 +1041,7 @@ Flush calling thread\*(Aqs thread\-specific cache (tcache)\&. This interface rel .PP "thread\&.prof\&.name" (\fBconst char *\fR) r\- or \-w [\fB\-\-enable\-prof\fR] .RS 4 -Get/set the descriptive name associated with the calling thread in memory profile dumps\&. An internal copy of the name string is created, so the input string need not be maintained after this interface completes execution\&. The output string of this interface should be copied for non\-ephemeral uses, because multiple implementation details can cause asynchronous string deallocation\&. Furthermore, each invocation of this interface can only read or write; simultaneous read/write is not supported due to string lifetime limitations\&. The name string must nil\-terminated and comprised only of characters in the sets recognized by +Get/set the descriptive name associated with the calling thread in memory profile dumps\&. An internal copy of the name string is created, so the input string need not be maintained after this interface completes execution\&. The output string of this interface should be copied for non\-ephemeral uses, because multiple implementation details can cause asynchronous string deallocation\&. Furthermore, each invocation of this interface can only read or write; simultaneous read/write is not supported due to string lifetime limitations\&. The name string must be nil\-terminated and comprised only of characters in the sets recognized by \fBisgraph\fR(3) and \fBisblank\fR(3)\&. diff --git a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h index 6c3cc181c64e..fe0160afeefb 100644 --- a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h +++ b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h @@ -314,6 +314,10 @@ typedef unsigned szind_t; #define PAGE ((size_t)(1U << LG_PAGE)) #define PAGE_MASK ((size_t)(PAGE - 1)) +/* Return the page base address for the page containing address a. */ +#define PAGE_ADDR2BASE(a) \ + ((void *)((uintptr_t)(a) & ~PAGE_MASK)) + /* Return the smallest pagesize multiple that is >= s. */ #define PAGE_CEILING(s) \ (((s) + PAGE_MASK) & ~PAGE_MASK) diff --git a/contrib/jemalloc/include/jemalloc/jemalloc.h b/contrib/jemalloc/include/jemalloc/jemalloc.h index 95a3a51f5735..d632d1e6bbe4 100644 --- a/contrib/jemalloc/include/jemalloc/jemalloc.h +++ b/contrib/jemalloc/include/jemalloc/jemalloc.h @@ -79,12 +79,12 @@ extern "C" { #include #include -#define JEMALLOC_VERSION "4.0.2-0-g486d249fb4715fd3de679b6c2a04f7e657883111" +#define JEMALLOC_VERSION "4.0.4-0-g91010a9e2ebfc84b1ac1ed7fdde3bfed4f65f180" #define JEMALLOC_VERSION_MAJOR 4 #define JEMALLOC_VERSION_MINOR 0 -#define JEMALLOC_VERSION_BUGFIX 2 +#define JEMALLOC_VERSION_BUGFIX 4 #define JEMALLOC_VERSION_NREV 0 -#define JEMALLOC_VERSION_GID "486d249fb4715fd3de679b6c2a04f7e657883111" +#define JEMALLOC_VERSION_GID "91010a9e2ebfc84b1ac1ed7fdde3bfed4f65f180" # define MALLOCX_LG_ALIGN(la) (la) # if LG_SIZEOF_PTR == 2 diff --git a/contrib/jemalloc/src/arena.c b/contrib/jemalloc/src/arena.c index 7f4a6caea1b2..43733cc15727 100644 --- a/contrib/jemalloc/src/arena.c +++ b/contrib/jemalloc/src/arena.c @@ -2679,6 +2679,22 @@ arena_ralloc_large_grow(arena_t *arena, arena_chunk_t *chunk, void *ptr, if (arena_run_split_large(arena, run, splitsize, zero)) goto label_fail; + if (config_cache_oblivious && zero) { + /* + * Zero the trailing bytes of the original allocation's + * last page, since they are in an indeterminate state. + * There will always be trailing bytes, because ptr's + * offset from the beginning of the run is a multiple of + * CACHELINE in [0 .. PAGE). + */ + void *zbase = (void *)((uintptr_t)ptr + oldsize); + void *zpast = PAGE_ADDR2BASE((void *)((uintptr_t)zbase + + PAGE)); + size_t nzero = (uintptr_t)zpast - (uintptr_t)zbase; + assert(nzero > 0); + memset(zbase, 0, nzero); + } + size = oldsize + splitsize; npages = (size + large_pad) >> LG_PAGE; diff --git a/contrib/jemalloc/src/huge.c b/contrib/jemalloc/src/huge.c index f8778db28fc5..1e9a66512f12 100644 --- a/contrib/jemalloc/src/huge.c +++ b/contrib/jemalloc/src/huge.c @@ -133,7 +133,7 @@ huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize_min, extent_node_t *node; arena_t *arena; chunk_hooks_t chunk_hooks = CHUNK_HOOKS_INITIALIZER; - bool zeroed; + bool pre_zeroed, post_zeroed; /* Increase usize to incorporate extra. */ for (usize = usize_min; usize < usize_max && (usize_next = s2u(usize+1)) @@ -145,26 +145,27 @@ huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize_min, node = huge_node_get(ptr); arena = extent_node_arena_get(node); + pre_zeroed = extent_node_zeroed_get(node); /* Fill if necessary (shrinking). */ if (oldsize > usize) { size_t sdiff = oldsize - usize; if (config_fill && unlikely(opt_junk_free)) { memset((void *)((uintptr_t)ptr + usize), 0x5a, sdiff); - zeroed = false; + post_zeroed = false; } else { - zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, ptr, - CHUNK_CEILING(oldsize), usize, sdiff); + post_zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, + ptr, CHUNK_CEILING(oldsize), usize, sdiff); } } else - zeroed = true; + post_zeroed = pre_zeroed; malloc_mutex_lock(&arena->huge_mtx); /* Update the size of the huge allocation. */ assert(extent_node_size_get(node) != usize); extent_node_size_set(node, usize); - /* Clear node's zeroed field if zeroing failed above. */ - extent_node_zeroed_set(node, extent_node_zeroed_get(node) && zeroed); + /* Update zeroed. */ + extent_node_zeroed_set(node, post_zeroed); malloc_mutex_unlock(&arena->huge_mtx); arena_chunk_ralloc_huge_similar(arena, ptr, oldsize, usize); @@ -172,7 +173,7 @@ huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize_min, /* Fill if necessary (growing). */ if (oldsize < usize) { if (zero || (config_fill && unlikely(opt_zero))) { - if (!zeroed) { + if (!pre_zeroed) { memset((void *)((uintptr_t)ptr + oldsize), 0, usize - oldsize); } @@ -190,10 +191,11 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize) arena_t *arena; chunk_hooks_t chunk_hooks; size_t cdiff; - bool zeroed; + bool pre_zeroed, post_zeroed; node = huge_node_get(ptr); arena = extent_node_arena_get(node); + pre_zeroed = extent_node_zeroed_get(node); chunk_hooks = chunk_hooks_get(arena); assert(oldsize > usize); @@ -209,21 +211,21 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize) if (config_fill && unlikely(opt_junk_free)) { huge_dalloc_junk((void *)((uintptr_t)ptr + usize), sdiff); - zeroed = false; + post_zeroed = false; } else { - zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, + post_zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, CHUNK_ADDR2BASE((uintptr_t)ptr + usize), CHUNK_CEILING(oldsize), CHUNK_ADDR2OFFSET((uintptr_t)ptr + usize), sdiff); } } else - zeroed = true; + post_zeroed = pre_zeroed; malloc_mutex_lock(&arena->huge_mtx); /* Update the size of the huge allocation. */ extent_node_size_set(node, usize); - /* Clear node's zeroed field if zeroing failed above. */ - extent_node_zeroed_set(node, extent_node_zeroed_get(node) && zeroed); + /* Update zeroed. */ + extent_node_zeroed_set(node, post_zeroed); malloc_mutex_unlock(&arena->huge_mtx); /* Zap the excess chunks. */ diff --git a/contrib/jemalloc/src/prof.c b/contrib/jemalloc/src/prof.c index 0a08062cc392..5d2b9598fdb4 100644 --- a/contrib/jemalloc/src/prof.c +++ b/contrib/jemalloc/src/prof.c @@ -1102,11 +1102,23 @@ prof_tctx_dump_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *arg) { bool propagate_err = *(bool *)arg; - if (prof_dump_printf(propagate_err, - " t%"FMTu64": %"FMTu64": %"FMTu64" [%"FMTu64": %"FMTu64"]\n", - tctx->thr_uid, tctx->dump_cnts.curobjs, tctx->dump_cnts.curbytes, - tctx->dump_cnts.accumobjs, tctx->dump_cnts.accumbytes)) - return (tctx); + switch (tctx->state) { + case prof_tctx_state_initializing: + case prof_tctx_state_nominal: + /* Not captured by this dump. */ + break; + case prof_tctx_state_dumping: + case prof_tctx_state_purgatory: + if (prof_dump_printf(propagate_err, + " t%"FMTu64": %"FMTu64": %"FMTu64" [%"FMTu64": " + "%"FMTu64"]\n", tctx->thr_uid, tctx->dump_cnts.curobjs, + tctx->dump_cnts.curbytes, tctx->dump_cnts.accumobjs, + tctx->dump_cnts.accumbytes)) + return (tctx); + break; + default: + not_reached(); + } return (NULL); } diff --git a/contrib/jemalloc/src/tsd.c b/contrib/jemalloc/src/tsd.c index 2100833a89e4..9ffe9afef7a0 100644 --- a/contrib/jemalloc/src/tsd.c +++ b/contrib/jemalloc/src/tsd.c @@ -73,6 +73,9 @@ tsd_cleanup(void *arg) tsd_t *tsd = (tsd_t *)arg; switch (tsd->state) { + case tsd_state_uninitialized: + /* Do nothing. */ + break; case tsd_state_nominal: #define O(n, t) \ n##_cleanup(tsd); diff --git a/contrib/libucl/CMakeLists.txt b/contrib/libucl/CMakeLists.txt new file mode 100644 index 000000000000..ae28a8908b37 --- /dev/null +++ b/contrib/libucl/CMakeLists.txt @@ -0,0 +1,260 @@ +PROJECT(libucl C) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) + +SET(LIBUCL_VERSION_MAJOR 0) +SET(LIBUCL_VERSION_MINOR 5) +SET(LIBUCL_VERSION_PATCH 0) + +SET(LIBUCL_VERSION + "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") + +INCLUDE(CheckCCompilerFlag) +INCLUDE(FindOpenSSL) + +OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) +OPTION(ENABLE_URL_SIGN "Enable signatures check in ucl includes (requires openssl) [default: OFF]" OFF) +OPTION(BUILD_SHARED_LIBS "Build Shared Libraries [default: OFF]" OFF) +OPTION(ENABLE_LUA "Enable lua support [default: OFF]" OFF) +OPTION(ENABLE_LUAJIT "Enable luajit support [default: OFF]" OFF) + +# Find lua installation +MACRO(FindLua) + # Find lua libraries + UNSET(LUA_INCLUDE_DIR CACHE) + UNSET(LUA_LIBRARY CACHE) + CMAKE_PARSE_ARGUMENTS(LUA "" "VERSION_MAJOR;VERSION_MINOR;ROOT" "" ${ARGN}) + + IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) + MESSAGE(FATAL_ERROR "Invalid FindLua invocation: ${ARGN}") + ENDIF() + + IF(ENABLE_LUAJIT MATCHES "ON") + MESSAGE(STATUS "Check for luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") + FIND_PATH(LUA_INCLUDE_DIR luajit.h + HINTS + "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" + $ENV{LUA_DIR} + PATH_SUFFIXES "include/luajit-2.0" + "include/luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "include/luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "include/luajit" + "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + include/lua include + PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} + ) + FIND_LIBRARY(LUA_LIBRARY + NAMES luajit + "luajit-2.0" + "luajit2.0" + "luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + HINTS + "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" + $ENV{LUA_DIR} + PATH_SUFFIXES lib64 lib + PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS} + DOC "Lua library" + ) + + IF(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR) + MESSAGE(STATUS "Fallback from luajit to plain lua") + SET(ENABLE_LUAJIT "OFF") + MESSAGE(STATUS "Check for lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") + FIND_PATH(LUA_INCLUDE_DIR lua.h + HINTS + "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" + $ENV{LUA_DIR} + PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + include/lua include + PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} + ) + FIND_LIBRARY(LUA_LIBRARY + NAMES lua + "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + HINTS + "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" + $ENV{LUA_DIR} + PATH_SUFFIXES lib64 lib + PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS} + DOC "Lua library" + ) + ENDIF() + ELSE(ENABLE_LUAJIT MATCHES "ON") + MESSAGE(STATUS "Check for lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") + FIND_PATH(LUA_INCLUDE_DIR lua.h + HINTS + "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" + $ENV{LUA_DIR} + PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + include/lua include + PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} + ) + FIND_LIBRARY(LUA_LIBRARY + NAMES lua + "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + HINTS + "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" + $ENV{LUA_DIR} + PATH_SUFFIXES lib64 lib + PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS} + DOC "Lua library" + ) + ENDIF(ENABLE_LUAJIT MATCHES "ON") + + IF(LUA_LIBRARY AND LUA_INCLUDE_DIR) + SET(LUA_FOUND 1) + IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) + SET(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR}) + SET(LUA_VERSION_MINOR ${LUA_VERSION_MINOR}) + ENDIF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) + IF(ENABLE_LUAJIT MATCHES "ON") + MESSAGE(STATUS "Found luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") + ELSE(ENABLE_LUAJIT MATCHES "ON") + MESSAGE(STATUS "Found lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") + ENDIF(ENABLE_LUAJIT MATCHES "ON") + ENDIF(LUA_LIBRARY AND LUA_INCLUDE_DIR) +ENDMACRO() + +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + +IF(ENABLE_URL_INCLUDE MATCHES "ON") + FIND_LIBRARY(LIBFETCH_LIBRARY NAMES fetch PATHS PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt + DOC "Path where the libfetch library can be found") + IF(LIBFETCH_LIBRARY) + FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include + /opt/include + /usr/local/include + DOC "Path to libfetch header") + ELSE(LIBFETCH_LIBRARY) + # Try to find libcurl + ProcessPackage(CURL libcurl) + IF(NOT CURL_FOUND) + MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") + ENDIF(NOT CURL_FOUND) + ENDIF(LIBFETCH_LIBRARY) +ENDIF(ENABLE_URL_INCLUDE MATCHES "ON") + +SET(CMAKE_C_WARN_FLAGS "") +CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) +CHECK_C_COMPILER_FLAG(-W SUPPORT_W) +CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) +CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) +CHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES) +IF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) + CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) +ENDIF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) +IF(SUPPORT_W) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") +ENDIF(SUPPORT_W) +IF(SUPPORT_WALL) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") +ENDIF(SUPPORT_WALL) +IF(SUPPORT_WPARAM) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") +ENDIF(SUPPORT_WPARAM) +IF(SUPPORT_WPOINTER_SIGN) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") +ENDIF(SUPPORT_WPOINTER_SIGN) +IF(SUPPORT_WSTRICT_PROTOTYPES) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes") +ENDIF(SUPPORT_WSTRICT_PROTOTYPES) +IF(SUPPORT_STD_FLAG) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") +ENDIF(SUPPORT_STD_FLAG) + +IF(ENABLE_URL_SIGN MATCHES "ON") + IF(OPENSSL_FOUND) + SET(HAVE_OPENSSL 1) + INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}") + ENDIF(OPENSSL_FOUND) +ENDIF(ENABLE_URL_SIGN MATCHES "ON") + +INCLUDE_DIRECTORIES("src") +INCLUDE_DIRECTORIES("include") +INCLUDE_DIRECTORIES("uthash") +INCLUDE_DIRECTORIES("klib") + +SET(UCLSRC src/ucl_util.c + src/ucl_parser.c + src/ucl_emitter.c + src/ucl_emitter_streamline.c + src/ucl_emitter_utils.c + src/ucl_hash.c + src/ucl_schema.c + src/ucl_msgpack.c + src/ucl_sexp.c + src/xxhash.c) + + +SET (LIB_TYPE STATIC) +IF (BUILD_SHARED_LIBS) + SET (LIB_TYPE SHARED) +ENDIF (BUILD_SHARED_LIBS) +ADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC}) +SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) + +IF(ENABLE_LUA MATCHES "ON") + IF(ENABLE_LUAJIT MATCHES "ON") + FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}") + IF(NOT LUA_FOUND) + MESSAGE(FATAL_ERROR "Lua not found, lua support is required") + ELSE(NOT LUA_FOUND) + INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}") + ENDIF(NOT LUA_FOUND) + ELSE(ENABLE_LUAJIT MATCHES "ON") + FindLua(VERSION_MAJOR "5" VERSION_MINOR "2" ROOT "${LUA_ROOT}") + IF(NOT LUA_FOUND) + FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}") + ENDIF(NOT LUA_FOUND) + IF(NOT LUA_FOUND) + MESSAGE(FATAL_ERROR "Lua not found, lua support is required") + ELSE(NOT LUA_FOUND) + INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}") + ENDIF(NOT LUA_FOUND) + ENDIF(ENABLE_LUAJIT MATCHES "ON") + SET(UCL_LUA_SRC lua/lua_ucl.c) + ADD_LIBRARY(lua-ucl ${LIB_TYPE} ${UCL_LUA_SRC}) + IF(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl "${LUAJIT_LIBRARY}") + ELSE(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl "${LUA_LIBRARY}") + ENDIF(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl ucl) + SET_TARGET_PROPERTIES(lua-ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) +ENDIF() + +IF(HAVE_FETCH_H) + TARGET_LINK_LIBRARIES(ucl fetch) +ELSE(HAVE_FETCH_H) + IF(CURL_FOUND) + TARGET_LINK_LIBRARIES(ucl ${CURL_LIBRARIES}) + ENDIF(CURL_FOUND) +ENDIF(HAVE_FETCH_H) +IF(ENABLE_URL_SIGN MATCHES "ON") + IF(OPENSSL_FOUND) + TARGET_LINK_LIBRARIES(ucl ${OPENSSL_LIBRARIES}) + ENDIF(OPENSSL_FOUND) +ENDIF(ENABLE_URL_SIGN MATCHES "ON") diff --git a/contrib/libucl/ChangeLog.md b/contrib/libucl/ChangeLog.md index 093ff97a842d..f714f40e75e4 100644 --- a/contrib/libucl/ChangeLog.md +++ b/contrib/libucl/ChangeLog.md @@ -32,3 +32,8 @@ ### Libucl 0.7.2 - Fixed serious bugs in schema and arrays iteration + +### Libucl 0.7.3 + +- Fixed a bug with macroes that come after an empty object +- Fixed a bug in include processing when an incorrect variable has been destroyed (use-after-free) diff --git a/contrib/libucl/README.md b/contrib/libucl/README.md index 797278ba932a..a742db1d2146 100644 --- a/contrib/libucl/README.md +++ b/contrib/libucl/README.md @@ -21,7 +21,7 @@ - [Performance](#performance) - [Conclusion](#conclusion) -## Introduction +## Introduction This document describes the main features and principles of the configuration language called `UCL` - universal configuration language. @@ -262,7 +262,20 @@ parser is created but before any configurations are parsed. all files that matches the specified pattern (normally the format of patterns is defined in `glob` manual page for your operating system). This option is meaningless for URL includes. * `url` (default: **true**) - allow URL includes. +* `path` (default: empty) - A UCL_ARRAY of directories to search for the include file. +Search ends after the first patch, unless `glob` is true, then all matches are included. +* `prefix` (default false) - Put included contents inside an object, instead +of loading them into the root. If no `key` is provided, one is automatically generated based on each files basename() +* `key` (default: ) - Key to load contents of include into. If +the key already exists, it must be the correct type +* `target` (default: object) - Specify if the `prefix` `key` should be an +object or an array. * `priority` (default: 0) - specify priority for the include (see below). +* `duplicate` (default: 'append') - specify policy of duplicates resolving: + - `append` - default strategy, if we have new object of higher priority then it replaces old one, if we have new object with less priority it is ignored completely, and if we have two duplicate objects with the same priority then we have a multi-value key (implicit array) + - `merge` - if we have object or array, then new keys are merged inside, if we have a plain object then an implicit array is formed (regardeless of priorities) + - `error` - create error on duplicate keys and stop parsing + - `rewrite` - always rewrite an old value with new one (ignoring priorities) Priorities are used by UCL parser to manage the policy of objects rewriting during including other files as following: diff --git a/contrib/libucl/cmake/CMakeLists.txt b/contrib/libucl/cmake/CMakeLists.txt deleted file mode 100644 index e84f61905c58..000000000000 --- a/contrib/libucl/cmake/CMakeLists.txt +++ /dev/null @@ -1,127 +0,0 @@ -PROJECT(libucl C) - -SET(LIBUCL_VERSION_MAJOR 0) -SET(LIBUCL_VERSION_MINOR 5) -SET(LIBUCL_VERSION_PATCH 0) - -SET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") - -INCLUDE(CheckCCompilerFlag) -INCLUDE(FindOpenSSL) -CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) - -OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) -OPTION(ENABLE_URL_SIGN "Enable signatures check in ucl includes (requires openssl) [default: OFF]" OFF) -OPTION(BUILD_SHARED_LIBS "Build Shared Libraries [default: OFF]" OFF) - -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - -IF(ENABLE_URL_INCLUDE MATCHES "ON") - FIND_LIBRARY(LIBFETCH_LIBRARY NAMES fetch PATHS PATH_SUFFIXES lib64 lib - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw - /opt/local - /opt/csw - /opt - DOC "Path where the libfetch library can be found") - IF(LIBFETCH_LIBRARY) - FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include - /opt/include - /usr/local/include - DOC "Path to libfetch header") - ELSE(LIBFETCH_LIBRARY) - # Try to find libcurl - ProcessPackage(CURL libcurl) - IF(NOT CURL_FOUND) - MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") - ENDIF(NOT CURL_FOUND) - ENDIF(LIBFETCH_LIBRARY) -ENDIF(ENABLE_URL_INCLUDE MATCHES "ON") - -SET(CMAKE_C_WARN_FLAGS "") -CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) -CHECK_C_COMPILER_FLAG(-W SUPPORT_W) -CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) -CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) -CHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES) -IF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) - CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) -ENDIF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) -IF(SUPPORT_W) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") -ENDIF(SUPPORT_W) -IF(SUPPORT_WALL) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") -ENDIF(SUPPORT_WALL) -IF(SUPPORT_WPARAM) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") -ENDIF(SUPPORT_WPARAM) -IF(SUPPORT_WPOINTER_SIGN) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") -ENDIF(SUPPORT_WPOINTER_SIGN) -IF(SUPPORT_WSTRICT_PROTOTYPES) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes") -ENDIF(SUPPORT_WSTRICT_PROTOTYPES) -IF(SUPPORT_STD_FLAG) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") -ENDIF(SUPPORT_STD_FLAG) - -IF(ENABLE_URL_SIGN MATCHES "ON") - IF(OPENSSL_FOUND) - SET(HAVE_OPENSSL 1) - INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}") - ENDIF(OPENSSL_FOUND) -ENDIF(ENABLE_URL_SIGN MATCHES "ON") - -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../src") -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../include") -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../uthash") -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../klib") - -SET(UCLSRC ../src/ucl_util.c - ../src/ucl_parser.c - ../src/ucl_emitter.c - ../src/ucl_emitter_streamline.c - ../src/ucl_emitter_utils.c - ../src/ucl_hash.c - ../src/ucl_schema.c - ../src/xxhash.c) - - -SET (LIB_TYPE STATIC) -IF (BUILD_SHARED_LIBS) - SET (LIB_TYPE SHARED) -ENDIF (BUILD_SHARED_LIBS) -ADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC}) -SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) - -IF(WITH_LUA) - SET(UCL_LUA_SRC ../lua/lua_ucl.c) - ADD_LIBRARY(lua-ucl ${LIB_TYPE} ${UCL_LUA_SRC}) - IF(ENABLE_LUAJIT MATCHES "ON") - TARGET_LINK_LIBRARIES(lua-ucl "${LUAJIT_LIBRARY}") - ELSE(ENABLE_LUAJIT MATCHES "ON") - TARGET_LINK_LIBRARIES(lua-ucl "${LUA_LIBRARY}") - ENDIF(ENABLE_LUAJIT MATCHES "ON") - TARGET_LINK_LIBRARIES(lua-ucl ucl) - SET_TARGET_PROPERTIES(lua-ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) -ENDIF(WITH_LUA) - -IF(HAVE_FETCH_H) - TARGET_LINK_LIBRARIES(ucl fetch) -ELSE(HAVE_FETCH_H) - IF(CURL_FOUND) - TARGET_LINK_LIBRARIES(ucl ${CURL_LIBRARIES}) - ENDIF(CURL_FOUND) -ENDIF(HAVE_FETCH_H) -IF(ENABLE_URL_SIGN MATCHES "ON") - IF(OPENSSL_FOUND) - TARGET_LINK_LIBRARIES(ucl ${OPENSSL_LIBRARIES}) - ENDIF(OPENSSL_FOUND) -ENDIF(ENABLE_URL_SIGN MATCHES "ON") diff --git a/contrib/libucl/configure.ac b/contrib/libucl/configure.ac index be6f6522f121..73d322717cbc 100644 --- a/contrib/libucl/configure.ac +++ b/contrib/libucl/configure.ac @@ -1,7 +1,7 @@ m4_define([maj_ver], [0]) m4_define([med_ver], [7]) -m4_define([min_ver], [2]) -m4_define([so_version], [5:0:1]) +m4_define([min_ver], [3]) +m4_define([so_version], [5:0:2]) m4_define([ucl_version], [maj_ver.med_ver.min_ver]) AC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl]) @@ -47,6 +47,7 @@ AC_CHECK_HEADERS_ONCE([libgen.h]) AC_CHECK_HEADERS_ONCE([stdio.h]) AC_CHECK_HEADERS_ONCE([float.h]) AC_CHECK_HEADERS_ONCE([math.h]) +AC_CHECK_HEADERS_ONCE([endian.h sys/endian.h machine/endian.h]) dnl Example of default-disabled feature AC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], diff --git a/contrib/libucl/doc/Makefile.am b/contrib/libucl/doc/Makefile.am index 2c7a588bf9a0..dcfacf6a9a25 100644 --- a/contrib/libucl/doc/Makefile.am +++ b/contrib/libucl/doc/Makefile.am @@ -4,6 +4,6 @@ dist_man_MANS = libucl.3 gen-man: @PANDOC@ tail -n +$$(grep -n '# Synopsis' api.md | cut -d':' -f1) api.md | \ - cat pandoc.template - | sed -e 's/^# \(.*\)/# \U\1/' \ + cat pandoc.template - | sed -e 's/^# \(.*\)/# \U\1/' \ -e "s/%%date%%/$$(LANG=C date +'%d %B, %Y')/" | \ - @PANDOC@ -s -f markdown -t man -o libucl.3 + @PANDOC@ -s -f markdown -t man -o libucl.3 diff --git a/contrib/libucl/doc/lua_api.md b/contrib/libucl/doc/lua_api.md index a53353b3c57e..f7af3caffff4 100644 --- a/contrib/libucl/doc/lua_api.md +++ b/contrib/libucl/doc/lua_api.md @@ -16,7 +16,7 @@ if not res then else local obj = parser:get_object() local got = ucl.to_format(obj, 'json') -endif +end local table = { str = 'value', @@ -25,6 +25,7 @@ local table = { func = function () return 'huh' end +} print(ucl.to_format(table, 'ucl')) @@ -115,6 +116,7 @@ local table = { func = function () return 'huh' end +} print(ucl.to_format(table, 'ucl')) diff --git a/contrib/libucl/examples/ucl_cpp.cc b/contrib/libucl/examples/ucl_cpp.cc new file mode 100644 index 000000000000..2d15d84a6c8d --- /dev/null +++ b/contrib/libucl/examples/ucl_cpp.cc @@ -0,0 +1,26 @@ +#include +#include +#include "ucl++.h" + +int main(int argc, char **argv) +{ + std::string input, err; + + input.assign((std::istreambuf_iterator(std::cin)), + std::istreambuf_iterator()); + + auto obj = ucl::Ucl::parse(input, err); + + if (obj) { + std::cout << obj.dump(UCL_EMIT_CONFIG) << std::endl; + + for (const auto &o : obj) { + std::cout << o.dump(UCL_EMIT_CONFIG) << std::endl; + } + } + else { + std::cerr << "Error: " << err << std::endl; + + return 1; + } +} diff --git a/contrib/libucl/include/ucl++.h b/contrib/libucl/include/ucl++.h new file mode 100644 index 000000000000..87d2041a60ec --- /dev/null +++ b/contrib/libucl/include/ucl++.h @@ -0,0 +1,422 @@ +/* + * Copyright (c) 2015, Vsevolod Stakhov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once +#include +#include +#include +#include + +#include "ucl.h" + +// C++11 API inspired by json11: https://github.com/dropbox/json11/ + +namespace ucl { + +struct ucl_map_construct_t { }; +constexpr ucl_map_construct_t ucl_map_construct = ucl_map_construct_t(); +struct ucl_array_construct_t { }; +constexpr ucl_array_construct_t ucl_array_construct = ucl_array_construct_t(); + +class Ucl final { +private: + + struct ucl_deleter { + void operator() (ucl_object_t *obj) { + ucl_object_unref (obj); + } + }; + + static int + append_char (unsigned char c, size_t nchars, void *ud) + { + std::string *out = reinterpret_cast(ud); + + out->append (nchars, (char)c); + + return nchars; + } + static int + append_len (unsigned const char *str, size_t len, void *ud) + { + std::string *out = reinterpret_cast(ud); + + out->append ((const char *)str, len); + + return len; + } + static int + append_int (int64_t elt, void *ud) + { + std::string *out = reinterpret_cast(ud); + auto nstr = std::to_string (elt); + + out->append (nstr); + + return nstr.size (); + } + static int + append_double (double elt, void *ud) + { + std::string *out = reinterpret_cast(ud); + auto nstr = std::to_string (elt); + + out->append (nstr); + + return nstr.size (); + } + + static struct ucl_emitter_functions default_emit_funcs() + { + struct ucl_emitter_functions func = { + Ucl::append_char, + Ucl::append_len, + Ucl::append_int, + Ucl::append_double, + nullptr, + nullptr + }; + + return func; + }; + + std::unique_ptr obj; + +public: + class const_iterator { + private: + struct ucl_iter_deleter { + void operator() (ucl_object_iter_t it) { + ucl_object_iterate_free (it); + } + }; + std::shared_ptr it; + std::unique_ptr cur; + public: + typedef std::forward_iterator_tag iterator_category; + + const_iterator(const Ucl &obj) { + it = std::shared_ptr(ucl_object_iterate_new (obj.obj.get()), + ucl_iter_deleter()); + cur.reset (new Ucl(ucl_object_iterate_safe (it.get(), true))); + } + + const_iterator() {} + const_iterator(const const_iterator &other) { + it = other.it; + } + ~const_iterator() {} + + const_iterator& operator=(const const_iterator &other) { + it = other.it; + return *this; + } + + bool operator==(const const_iterator &other) const + { + if (cur && other.cur) { + return cur->obj.get() == other.cur->obj.get(); + } + + return !cur && !other.cur; + } + + bool operator!=(const const_iterator &other) const + { + return !(*this == other); + } + + const_iterator& operator++() + { + if (it) { + cur.reset (new Ucl(ucl_object_iterate_safe (it.get(), true))); + } + + if (!*cur) { + it.reset (); + cur.reset (); + } + + return *this; + } + + const Ucl& operator*() const + { + return *cur; + } + const Ucl* operator->() const + { + return cur.get(); + } + }; + + // We grab ownership if get non-const ucl_object_t + Ucl(ucl_object_t *other) { + obj.reset (other); + } + + // Shared ownership + Ucl(const ucl_object_t *other) { + obj.reset (ucl_object_ref (other)); + } + + Ucl(const Ucl &other) { + obj.reset (ucl_object_ref (other.obj.get())); + } + + Ucl(Ucl &&other) { + obj.swap (other.obj); + } + + Ucl() noexcept { + obj.reset (ucl_object_typed_new (UCL_NULL)); + } + Ucl(std::nullptr_t) noexcept { + obj.reset (ucl_object_typed_new (UCL_NULL)); + } + Ucl(double value) { + obj.reset (ucl_object_typed_new (UCL_FLOAT)); + obj->value.dv = value; + } + Ucl(int64_t value) { + obj.reset (ucl_object_typed_new (UCL_INT)); + obj->value.iv = value; + } + Ucl(bool value) { + obj.reset (ucl_object_typed_new (UCL_BOOLEAN)); + obj->value.iv = static_cast(value); + } + Ucl(const std::string &value) { + obj.reset (ucl_object_fromstring_common (value.data (), value.size (), + UCL_STRING_RAW)); + } + Ucl(const char * value) { + obj.reset (ucl_object_fromstring_common (value, 0, UCL_STRING_RAW)); + } + + // Implicit constructor: anything with a to_json() function. + template + Ucl(const T & t) : Ucl(t.to_ucl()) {} + + // Implicit constructor: map-like objects (std::map, std::unordered_map, etc) + template ::value + && std::is_constructible::value, + int>::type = 0> + Ucl(const M & m) { + obj.reset (ucl_object_typed_new (UCL_OBJECT)); + auto cobj = obj.get (); + + for (const auto &e : m) { + ucl_object_insert_key (cobj, ucl_object_ref (e.second.obj.get()), + e.first.data (), e.first.size (), true); + } + } + + // Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc) + template ::value, + int>::type = 0> + Ucl(const V & v) { + obj.reset (ucl_object_typed_new (UCL_ARRAY)); + auto cobj = obj.get (); + + for (const auto &e : v) { + ucl_array_append (cobj, ucl_object_ref (e.obj.get())); + } + } + + ucl_type_t type () const { + if (obj) { + return ucl_object_type (obj.get ()); + } + return UCL_NULL; + } + + const std::string key () const { + std::string res; + + if (obj->key) { + res.assign (obj->key, obj->keylen); + } + + return res; + } + + double number_value () const + { + if (obj) { + return ucl_object_todouble (obj.get()); + } + + return 0.0; + } + + int64_t int_value () const + { + if (obj) { + return ucl_object_toint (obj.get()); + } + + return 0; + } + + bool bool_value () const + { + if (obj) { + return ucl_object_toboolean (obj.get()); + } + + return false; + } + + const std::string string_value () const + { + std::string res; + + if (obj) { + res.assign (ucl_object_tostring (obj.get())); + } + + return res; + } + + const Ucl operator[] (size_t i) const + { + if (type () == UCL_ARRAY) { + return Ucl (ucl_array_find_index (obj.get(), i)); + } + + return Ucl (nullptr); + } + + const Ucl operator[](const std::string &key) const + { + if (type () == UCL_OBJECT) { + return Ucl (ucl_object_find_keyl (obj.get(), + key.data (), key.size ())); + } + + return Ucl (nullptr); + } + // Serialize. + void dump (std::string &out, ucl_emitter_t type = UCL_EMIT_JSON) const + { + struct ucl_emitter_functions cbdata; + + cbdata = Ucl::default_emit_funcs(); + cbdata.ud = reinterpret_cast(&out); + + ucl_object_emit_full (obj.get(), type, &cbdata); + } + + std::string dump (ucl_emitter_t type = UCL_EMIT_JSON) const + { + std::string out; + + dump (out, type); + + return out; + } + + static Ucl parse (const std::string & in, std::string & err) + { + auto parser = ucl_parser_new (UCL_PARSER_DEFAULT); + + if (!ucl_parser_add_chunk (parser, (const unsigned char *)in.data (), + in.size ())) { + err.assign (ucl_parser_get_error (parser)); + ucl_parser_free (parser); + + return nullptr; + } + + auto obj = ucl_parser_get_object (parser); + ucl_parser_free (parser); + + // Obj will handle ownership + return Ucl (obj); + } + + static Ucl parse (const char * in, std::string & err) + { + if (in) { + return parse (std::string(in), err); + } else { + err = "null input"; + return nullptr; + } + } + + static Ucl parse (std::istream &ifs, std::string &err) + { + return Ucl::parse (std::string(std::istreambuf_iterator(ifs), + std::istreambuf_iterator()), err); + } + + bool operator== (const Ucl &rhs) const + { + return ucl_object_compare (obj.get(), rhs.obj.get ()) == 0; + } + bool operator< (const Ucl &rhs) const + { + return ucl_object_compare (obj.get(), rhs.obj.get ()) < 0; + } + bool operator!= (const Ucl &rhs) const { return !(*this == rhs); } + bool operator<= (const Ucl &rhs) const { return !(rhs < *this); } + bool operator> (const Ucl &rhs) const { return (rhs < *this); } + bool operator>= (const Ucl &rhs) const { return !(*this < rhs); } + + operator bool () const + { + if (!obj || type() == UCL_NULL) { + return false; + } + + if (type () == UCL_BOOLEAN) { + return bool_value (); + } + + return true; + } + + const_iterator begin() const + { + return const_iterator(*this); + } + const_iterator cbegin() const + { + return const_iterator(*this); + } + const_iterator end() const + { + return const_iterator(); + } + const_iterator cend() const + { + return const_iterator(); + } +}; + +}; diff --git a/contrib/libucl/include/ucl.h b/contrib/libucl/include/ucl.h index 823ac8d3bfc9..82a1fd1880f3 100644 --- a/contrib/libucl/include/ucl.h +++ b/contrib/libucl/include/ucl.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Vsevolod Stakhov +/* Copyright (c) 2013-2015, Vsevolod Stakhov * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -135,7 +135,9 @@ typedef enum ucl_emitter { UCL_EMIT_JSON = 0, /**< Emit fine formatted JSON */ UCL_EMIT_JSON_COMPACT, /**< Emit compacted JSON */ UCL_EMIT_CONFIG, /**< Emit human readable config format */ - UCL_EMIT_YAML /**< Emit embedded YAML format */ + UCL_EMIT_YAML, /**< Emit embedded YAML format */ + UCL_EMIT_MSGPACK, /**< Emit msgpack output */ + UCL_EMIT_MAX /**< Unsupported emitter type */ } ucl_emitter_t; /** @@ -145,6 +147,7 @@ typedef enum ucl_emitter { * UCL still has to perform copying implicitly. */ typedef enum ucl_parser_flags { + UCL_PARSER_DEFAULT = 0x0, /**< No special flags */ UCL_PARSER_KEY_LOWERCASE = 0x1, /**< Convert all keys to lower case */ UCL_PARSER_ZEROCOPY = 0x2, /**< Parse input in zero-copy mode if possible */ UCL_PARSER_NO_TIME = 0x4, /**< Do not parse time and treat time values as strings */ @@ -155,6 +158,7 @@ typedef enum ucl_parser_flags { * String conversion flags, that are used in #ucl_object_fromstring_common function. */ typedef enum ucl_string_flags { + UCL_STRING_RAW = 0x0, /**< Treat string as is */ UCL_STRING_ESCAPE = 0x1, /**< Perform JSON escape */ UCL_STRING_TRIM = 0x2, /**< Trim leading and trailing whitespaces */ UCL_STRING_PARSE_BOOLEAN = 0x4, /**< Parse passed string and detect boolean */ @@ -172,14 +176,35 @@ typedef enum ucl_string_flags { * Basic flags for an object */ typedef enum ucl_object_flags { - UCL_OBJECT_ALLOCATED_KEY = 0x1, /**< An object has key allocated internally */ - UCL_OBJECT_ALLOCATED_VALUE = 0x2, /**< An object has a string value allocated internally */ - UCL_OBJECT_NEED_KEY_ESCAPE = 0x4, /**< The key of an object need to be escaped on output */ - UCL_OBJECT_EPHEMERAL = 0x8, /**< Temporary object that does not need to be freed really */ - UCL_OBJECT_MULTILINE = 0x10, /**< String should be displayed as multiline string */ - UCL_OBJECT_MULTIVALUE = 0x20 /**< Object is a key with multiple values */ + UCL_OBJECT_ALLOCATED_KEY = (1 << 0), /**< An object has key allocated internally */ + UCL_OBJECT_ALLOCATED_VALUE = (1 << 1), /**< An object has a string value allocated internally */ + UCL_OBJECT_NEED_KEY_ESCAPE = (1 << 2), /**< The key of an object need to be escaped on output */ + UCL_OBJECT_EPHEMERAL = (1 << 3), /**< Temporary object that does not need to be freed really */ + UCL_OBJECT_MULTILINE = (1 << 4), /**< String should be displayed as multiline string */ + UCL_OBJECT_MULTIVALUE = (1 << 5), /**< Object is a key with multiple values */ + UCL_OBJECT_INHERITED = (1 << 6), /**< Object has been inherited from another */ + UCL_OBJECT_BINARY = (1 << 7) /**< Object contains raw binary data */ } ucl_object_flags_t; +/** + * Duplicate policy types + */ +enum ucl_duplicate_strategy { + UCL_DUPLICATE_APPEND = 0, /**< Default policy to merge based on priorities */ + UCL_DUPLICATE_MERGE, /**< Merge new object with old one */ + UCL_DUPLICATE_REWRITE, /**< Rewrite old keys */ + UCL_DUPLICATE_ERROR /**< Stop parsing on duplicate found */ +}; + +/** + * Input format type + */ +enum ucl_parse_type { + UCL_PARSE_UCL = 0, /**< Default ucl format */ + UCL_PARSE_MSGPACK, /**< Message pack input format */ + UCL_PARSE_CSEXP /**< Canonical S-expressions */ +}; + /** * UCL object structure. Please mention that the most of fields should not be touched by * UCL users. In future, this structure may be converted to private one. @@ -190,7 +215,7 @@ typedef struct ucl_object_s { */ union { int64_t iv; /**< Int value of an object */ - const char *sv; /**< String value of an object */ + const char *sv; /**< String value of an object */ double dv; /**< Double value of an object */ void *av; /**< Array */ void *ov; /**< Object */ @@ -495,6 +520,15 @@ UCL_EXTERN ucl_object_t* ucl_array_pop_first (ucl_object_t *top); UCL_EXTERN const ucl_object_t* ucl_array_find_index (const ucl_object_t *top, unsigned int index); +/** + * Return the index of `elt` in the array `top` + * @param top object to get a key from (must be of type UCL_ARRAY) + * @param elt element to find index of (must NOT be NULL) + * @return index of `elt` in the array `top or (unsigned int)-1 if `elt` is not found + */ +UCL_EXTERN unsigned int ucl_array_index_of (ucl_object_t *top, + ucl_object_t *elt); + /** * Replace an element in an array with a different element, returning the object * that was replaced. This object is not released, caller must unref the @@ -611,6 +645,19 @@ UCL_EXTERN const char* ucl_object_tolstring (const ucl_object_t *obj, size_t *tl UCL_EXTERN const ucl_object_t* ucl_object_find_key (const ucl_object_t *obj, const char *key); +/** + * Return object identified by a key in the specified object, if the first key is + * not found then look for the next one. This process is repeated unless + * the next argument in the list is not NULL. So, `ucl_object_find_any_key(obj, key, NULL)` + * is equal to `ucl_object_find_key(obj, key)` + * @param obj object to get a key from (must be of type UCL_OBJECT) + * @param key key to search + * @param ... list of alternative keys to search (NULL terminated) + * @return object matching the specified key or NULL if key was not found + */ +UCL_EXTERN const ucl_object_t* ucl_object_find_any_key (const ucl_object_t *obj, + const char *key, ...); + /** * Return object identified by a fixed size key in the specified object * @param obj object to get a key from (must be of type UCL_OBJECT) @@ -630,6 +677,16 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_keyl (const ucl_object_t *obj, UCL_EXTERN const ucl_object_t *ucl_lookup_path (const ucl_object_t *obj, const char *path); +/** + * Return object identified by object notation string using arbitrary delimiter + * @param obj object to search in + * @param path dot.notation.path to the path to lookup. May use numeric .index on arrays + * @param sep the sepatorator to use in place of . (incase keys have . in them) + * @return object matched the specified path or NULL if path is not found + */ +UCL_EXTERN const ucl_object_t *ucl_lookup_path_char (const ucl_object_t *obj, + const char *path, char sep); + /** * Returns a key of an object as a NULL terminated string * @param obj CL object @@ -683,7 +740,7 @@ UCL_EXTERN int ucl_object_compare (const ucl_object_t *o1, * @param cmp */ UCL_EXTERN void ucl_object_array_sort (ucl_object_t *ar, - int (*cmp)(const ucl_object_t *o1, const ucl_object_t *o2)); + int (*cmp)(const ucl_object_t **o1, const ucl_object_t **o2)); /** * Get the priority for specific UCL object @@ -769,6 +826,21 @@ typedef bool (*ucl_macro_handler) (const unsigned char *data, size_t len, const ucl_object_t *arguments, void* ud); +/** + * Context dependent macro handler for a parser + * @param data the content of macro + * @param len the length of content + * @param arguments arguments object + * @param context previously parsed context + * @param ud opaque user data + * @param err error pointer + * @return true if macro has been parsed + */ +typedef bool (*ucl_context_macro_handler) (const unsigned char *data, size_t len, + const ucl_object_t *arguments, + const ucl_object_t *context, + void* ud); + /* Opaque parser */ struct ucl_parser; @@ -779,6 +851,15 @@ struct ucl_parser; */ UCL_EXTERN struct ucl_parser* ucl_parser_new (int flags); +/** + * Sets the default priority for the parser applied to chunks that does not + * specify priority explicitly + * @param parser parser object + * @param prio default priority (0 .. 16) + * @return true if parser's default priority was set + */ +UCL_EXTERN bool ucl_parser_set_default_priority (struct ucl_parser *parser, + unsigned prio); /** * Register new handler for a macro * @param parser parser object @@ -786,9 +867,22 @@ UCL_EXTERN struct ucl_parser* ucl_parser_new (int flags); * @param handler handler (it is called immediately after macro is parsed) * @param ud opaque user data for a handler */ -UCL_EXTERN void ucl_parser_register_macro (struct ucl_parser *parser, const char *macro, +UCL_EXTERN void ucl_parser_register_macro (struct ucl_parser *parser, + const char *macro, ucl_macro_handler handler, void* ud); +/** + * Register new context dependent handler for a macro + * @param parser parser object + * @param macro macro name (without leading dot) + * @param handler handler (it is called immediately after macro is parsed) + * @param ud opaque user data for a handler + */ +UCL_EXTERN void ucl_parser_register_context_macro (struct ucl_parser *parser, + const char *macro, + ucl_context_macro_handler handler, + void* ud); + /** * Handler to detect unregistered variables * @param data variable data @@ -842,6 +936,21 @@ UCL_EXTERN bool ucl_parser_add_chunk (struct ucl_parser *parser, UCL_EXTERN bool ucl_parser_add_chunk_priority (struct ucl_parser *parser, const unsigned char *data, size_t len, unsigned priority); +/** + * Full version of ucl_add_chunk with priority and duplicate strategy + * @param parser parser structure + * @param data the pointer to the beginning of a chunk + * @param len the length of a chunk + * @param priority the desired priority of a chunk (only 4 least significant bits + * are considered for this parameter) + * @param strat duplicates merging strategy + * @param parse_type input format + * @return true if chunk has been added and false in case of error + */ +UCL_EXTERN bool ucl_parser_add_chunk_full (struct ucl_parser *parser, + const unsigned char *data, size_t len, unsigned priority, + enum ucl_duplicate_strategy strat, enum ucl_parse_type parse_type); + /** * Load ucl object from a string * @param parser parser structure @@ -852,6 +961,18 @@ UCL_EXTERN bool ucl_parser_add_chunk_priority (struct ucl_parser *parser, UCL_EXTERN bool ucl_parser_add_string (struct ucl_parser *parser, const char *data,size_t len); +/** + * Load ucl object from a string + * @param parser parser structure + * @param data the pointer to the string + * @param len the length of the string, if `len` is 0 then `data` must be zero-terminated string + * @param priority the desired priority of a chunk (only 4 least significant bits + * are considered for this parameter) + * @return true if string has been added and false in case of error + */ +UCL_EXTERN bool ucl_parser_add_string_priority (struct ucl_parser *parser, + const char *data, size_t len, unsigned priority); + /** * Load and add data from a file * @param parser parser structure @@ -862,6 +983,18 @@ UCL_EXTERN bool ucl_parser_add_string (struct ucl_parser *parser, UCL_EXTERN bool ucl_parser_add_file (struct ucl_parser *parser, const char *filename); +/** + * Load and add data from a file + * @param parser parser structure + * @param filename the name of file + * @param err if *err is NULL it is set to parser error + * @param priority the desired priority of a chunk (only 4 least significant bits + * are considered for this parameter) + * @return true if chunk has been added and false in case of error + */ +UCL_EXTERN bool ucl_parser_add_file_priority (struct ucl_parser *parser, + const char *filename, unsigned priority); + /** * Load and add data from a file descriptor * @param parser parser structure @@ -872,6 +1005,28 @@ UCL_EXTERN bool ucl_parser_add_file (struct ucl_parser *parser, UCL_EXTERN bool ucl_parser_add_fd (struct ucl_parser *parser, int fd); +/** + * Load and add data from a file descriptor + * @param parser parser structure + * @param filename the name of file + * @param err if *err is NULL it is set to parser error + * @param priority the desired priority of a chunk (only 4 least significant bits + * are considered for this parameter) + * @return true if chunk has been added and false in case of error + */ +UCL_EXTERN bool ucl_parser_add_fd_priority (struct ucl_parser *parser, + int fd, unsigned priority); + +/** + * Provide a UCL_ARRAY of paths to search for include files. The object is + * copied so caller must unref the object. + * @param parser parser structure + * @param paths UCL_ARRAY of paths to search + * @return true if the path search array was replaced in the parser + */ +UCL_EXTERN bool ucl_set_include_path (struct ucl_parser *parser, + ucl_object_t *paths); + /** * Get a top object for a parser (refcount is increased) * @param parser parser structure @@ -881,11 +1036,33 @@ UCL_EXTERN bool ucl_parser_add_fd (struct ucl_parser *parser, UCL_EXTERN ucl_object_t* ucl_parser_get_object (struct ucl_parser *parser); /** - * Get the error string if failing + * Get the error string if parsing has been failed * @param parser parser object + * @return error description */ UCL_EXTERN const char *ucl_parser_get_error(struct ucl_parser *parser); +/** + * Get the code of the last error + * @param parser parser object + * @return error code + */ +UCL_EXTERN int ucl_parser_get_error_code(struct ucl_parser *parser); + +/** + * Get the current column number within parser + * @param parser parser object + * @return current column number + */ +UCL_EXTERN unsigned ucl_parser_get_column(struct ucl_parser *parser); + +/** + * Get the current line number within parser + * @param parser parser object + * @return current line number + */ +UCL_EXTERN unsigned ucl_parser_get_linenum(struct ucl_parser *parser); + /** * Clear the error in the parser * @param parser parser object @@ -993,6 +1170,17 @@ struct ucl_emitter_context { UCL_EXTERN unsigned char *ucl_object_emit (const ucl_object_t *obj, enum ucl_emitter emit_type); +/** + * Emit object to a string that can contain `\0` inside + * @param obj object + * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is + * #UCL_EMIT_CONFIG then emit config like object + * @param len the resulting length + * @return dump of an object (must be freed after using) or NULL in case of error + */ +UCL_EXTERN unsigned char *ucl_object_emit_len (const ucl_object_t *obj, + enum ucl_emitter emit_type, size_t *len); + /** * Emit object to a string * @param obj object diff --git a/contrib/libucl/klib/kvec.h b/contrib/libucl/klib/kvec.h index b5cce8508f8e..b0a7504b2268 100644 --- a/contrib/libucl/klib/kvec.h +++ b/contrib/libucl/klib/kvec.h @@ -89,7 +89,7 @@ int main() { #define kv_concat(type, v1, v0) do { \ if ((v1).m < (v0).n + (v1).n) kv_resize(type, v1, (v0).n + (v1).n); \ - memcpy((v1).a + (v1).n, (v0).a, sizeof(type) * ((v0).n + (v1).n)); \ + memcpy((v1).a + (v1).n, (v0).a, sizeof(type) * (v0).n); \ (v1).n = (v0).n + (v1).n; \ } while (0) diff --git a/contrib/libucl/lua/lua_ucl.c b/contrib/libucl/lua/lua_ucl.c index 682b0b559fd3..b6162b432f59 100644 --- a/contrib/libucl/lua/lua_ucl.c +++ b/contrib/libucl/lua/lua_ucl.c @@ -69,6 +69,7 @@ func = "huh"; #define PARSER_META "ucl.parser.meta" #define EMITTER_META "ucl.emitter.meta" #define NULL_META "null.emitter.meta" +#define OBJECT_META "ucl.object.meta" static int ucl_object_lua_push_array (lua_State *L, const ucl_object_t *obj); static int ucl_object_lua_push_scalar (lua_State *L, const ucl_object_t *obj, bool allow_array); @@ -172,19 +173,33 @@ static int ucl_object_lua_push_array (lua_State *L, const ucl_object_t *obj) { const ucl_object_t *cur; + ucl_object_iter_t it; int i = 1, nelt = 0; - /* Optimize allocation by preallocation of table */ - LL_FOREACH (obj, cur) { - nelt ++; + if (obj->type == UCL_ARRAY) { + nelt = obj->len; + it = ucl_object_iterate_new (obj); + lua_createtable (L, nelt, 0); + + while ((cur = ucl_object_iterate_safe (it, true))) { + ucl_object_push_lua (L, cur, false); + lua_rawseti (L, -2, i); + i ++; + } } + else { + /* Optimize allocation by preallocation of table */ + LL_FOREACH (obj, cur) { + nelt ++; + } - lua_createtable (L, nelt, 0); + lua_createtable (L, nelt, 0); - LL_FOREACH (obj, cur) { - ucl_object_push_lua (L, cur, false); - lua_rawseti (L, -2, i); - i ++; + LL_FOREACH (obj, cur) { + ucl_object_push_lua (L, cur, false); + lua_rawseti (L, -2, i); + i ++; + } } return 1; @@ -259,7 +274,7 @@ ucl_object_push_lua (lua_State *L, const ucl_object_t *obj, bool allow_array) case UCL_OBJECT: return ucl_object_lua_push_object (L, obj, allow_array); case UCL_ARRAY: - return ucl_object_lua_push_array (L, obj->value.av); + return ucl_object_lua_push_array (L, obj); default: return ucl_object_lua_push_scalar (L, obj, allow_array); } @@ -322,6 +337,7 @@ ucl_object_lua_fromtable (lua_State *L, int idx) if (obj != NULL) { ucl_array_append (top, obj); } + lua_pop (L, 1); } } else { @@ -445,6 +461,24 @@ ucl_object_lua_import (lua_State *L, int idx) return obj; } +static int +lua_ucl_to_string (lua_State *L, const ucl_object_t *obj, enum ucl_emitter type) +{ + unsigned char *result; + + result = ucl_object_emit (obj, type); + + if (result != NULL) { + lua_pushstring (L, (const char *)result); + free (result); + } + else { + lua_pushnil (L); + } + + return 1; +} + static int lua_ucl_parser_init (lua_State *L) { @@ -474,6 +508,12 @@ lua_ucl_parser_get (lua_State *L, int index) return *((struct ucl_parser **) luaL_checkudata(L, index, PARSER_META)); } +static ucl_object_t * +lua_ucl_object_get (lua_State *L, int index) +{ + return *((ucl_object_t **) luaL_checkudata(L, index, OBJECT_META)); +} + /*** * @method parser:parse_file(name) * Parse UCL object from file. @@ -579,6 +619,108 @@ lua_ucl_parser_get_object (lua_State *L) return ret; } +/*** + * @method parser:get_object_wrapped() + * Get top object from parser and export it to userdata object without + * unwrapping to lua. + * @return {ucl.object or nil} ucl object wrapped variable + */ +static int +lua_ucl_parser_get_object_wrapped (lua_State *L) +{ + struct ucl_parser *parser; + ucl_object_t *obj, **pobj; + int ret = 1; + + parser = lua_ucl_parser_get (L, 1); + obj = ucl_parser_get_object (parser); + + if (obj != NULL) { + pobj = lua_newuserdata (L, sizeof (*pobj)); + *pobj = obj; + luaL_getmetatable (L, OBJECT_META); + lua_setmetatable (L, -2); + } + else { + lua_pushnil (L); + } + + return ret; +} + +/*** + * @method parser:validate(schema) + * Validates the top object in the parser against schema. Schema might be + * another object or a string that represents file to load schema from. + * + * @param {string/table} schema input schema + * @return {result,err} two values: boolean result and the corresponding error + * + */ +static int +lua_ucl_parser_validate (lua_State *L) +{ + struct ucl_parser *parser, *schema_parser; + ucl_object_t *schema; + const char *schema_file; + struct ucl_schema_error err; + + parser = lua_ucl_parser_get (L, 1); + + if (parser && parser->top_obj) { + if (lua_type (L, 2) == LUA_TTABLE) { + schema = ucl_object_lua_import (L, 2); + + if (schema == NULL) { + lua_pushboolean (L, false); + lua_pushstring (L, "cannot load schema from lua table"); + + return 2; + } + } + else if (lua_type (L, 2) == LUA_TSTRING) { + schema_parser = ucl_parser_new (0); + schema_file = luaL_checkstring (L, 2); + + if (!ucl_parser_add_file (schema_parser, schema_file)) { + lua_pushboolean (L, false); + lua_pushfstring (L, "cannot parse schema file \"%s\": " + "%s", schema_file, ucl_parser_get_error (parser)); + ucl_parser_free (schema_parser); + + return 2; + } + + schema = ucl_parser_get_object (schema_parser); + ucl_parser_free (schema_parser); + } + else { + lua_pushboolean (L, false); + lua_pushstring (L, "invalid schema argument"); + + return 2; + } + + if (!ucl_object_validate (schema, parser->top_obj, &err)) { + lua_pushboolean (L, false); + lua_pushfstring (L, "validation error: " + "%s", err.msg); + } + else { + lua_pushboolean (L, true); + lua_pushnil (L); + } + + ucl_object_unref (schema); + } + else { + lua_pushboolean (L, false); + lua_pushstring (L, "invalid parser or empty top object"); + } + + return 2; +} + static int lua_ucl_parser_gc (lua_State *L) { @@ -590,6 +732,161 @@ lua_ucl_parser_gc (lua_State *L) return 0; } +/*** + * @method object:unwrap() + * Unwraps opaque ucl object to the native lua object (performing copying) + * @return {variant} any lua object + */ +static int +lua_ucl_object_unwrap (lua_State *L) +{ + ucl_object_t *obj; + + obj = lua_ucl_object_get (L, 1); + + if (obj) { + ucl_object_push_lua (L, obj, true); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** + * @method object:tostring(type) + * Unwraps opaque ucl object to string (json by default). Optionally you can + * specify output format: + * + * - `json` - fine printed json + * - `json-compact` - compacted json + * - `config` - fine printed configuration + * - `ucl` - same as `config` + * - `yaml` - embedded yaml + * @param {string} type optional + * @return {string} string representation of the opaque ucl object + */ +static int +lua_ucl_object_tostring (lua_State *L) +{ + ucl_object_t *obj; + enum ucl_emitter format = UCL_EMIT_JSON_COMPACT; + + obj = lua_ucl_object_get (L, 1); + + if (obj) { + if (lua_gettop (L) > 1) { + if (lua_type (L, 2) == LUA_TSTRING) { + const char *strtype = lua_tostring (L, 2); + + if (strcasecmp (strtype, "json") == 0) { + format = UCL_EMIT_JSON; + } + else if (strcasecmp (strtype, "json-compact") == 0) { + format = UCL_EMIT_JSON_COMPACT; + } + else if (strcasecmp (strtype, "yaml") == 0) { + format = UCL_EMIT_YAML; + } + else if (strcasecmp (strtype, "config") == 0 || + strcasecmp (strtype, "ucl") == 0) { + format = UCL_EMIT_CONFIG; + } + } + } + + return lua_ucl_to_string (L, obj, format); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** + * @method object:validate(schema, path) + * Validates the given ucl object using schema object represented as another + * opaque ucl object. You can also specify path in the form `#/path/def` to + * specify the specific schema element to perform validation. + * + * @param {ucl.object} schema schema object + * @param {string} path optional path for validation procedure + * @return {result,err} two values: boolean result and the corresponding error + */ +static int +lua_ucl_object_validate (lua_State *L) +{ + ucl_object_t *obj, *schema; + const ucl_object_t *schema_elt; + bool res = false; + struct ucl_schema_error err; + const char *path = NULL; + + obj = lua_ucl_object_get (L, 1); + schema = lua_ucl_object_get (L, 2); + + if (schema && obj && ucl_object_type (schema) == UCL_OBJECT) { + if (lua_gettop (L) > 2 && lua_type (L, 3) == LUA_TSTRING) { + path = lua_tostring (L, 3); + if (path[0] == '#') { + path ++; + } + } + + if (path) { + schema_elt = ucl_lookup_path_char (schema, path, '/'); + } + else { + /* Use the top object */ + schema_elt = schema; + } + + if (schema_elt) { + res = ucl_object_validate (schema_elt, obj, &err); + + if (res) { + lua_pushboolean (L, res); + lua_pushnil (L); + } + else { + lua_pushboolean (L, res); + lua_pushfstring (L, "validation error: %s", err.msg); + } + } + else { + lua_pushboolean (L, res); + + if (path) { + lua_pushfstring (L, "cannot find the requested path: %s", path); + } + else { + /* Should not be reached */ + lua_pushstring (L, "unknown error"); + } + } + } + else { + lua_pushboolean (L, res); + lua_pushstring (L, "invalid object or schema"); + } + + return 2; +} + +static int +lua_ucl_object_gc (lua_State *L) +{ + ucl_object_t *obj; + + obj = lua_ucl_object_get (L, 1); + + ucl_object_unref (obj); + + return 0; +} + static void lua_ucl_parser_mt (lua_State *L) { @@ -610,25 +907,45 @@ lua_ucl_parser_mt (lua_State *L) lua_pushcfunction (L, lua_ucl_parser_get_object); lua_setfield (L, -2, "get_object"); + lua_pushcfunction (L, lua_ucl_parser_get_object_wrapped); + lua_setfield (L, -2, "get_object_wrapped"); + + lua_pushcfunction (L, lua_ucl_parser_validate); + lua_setfield (L, -2, "validate"); + lua_pop (L, 1); } -static int -lua_ucl_to_string (lua_State *L, const ucl_object_t *obj, enum ucl_emitter type) +static void +lua_ucl_object_mt (lua_State *L) { - unsigned char *result; + luaL_newmetatable (L, OBJECT_META); - result = ucl_object_emit (obj, type); + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); - if (result != NULL) { - lua_pushstring (L, (const char *)result); - free (result); - } - else { - lua_pushnil (L); - } + lua_pushcfunction (L, lua_ucl_object_gc); + lua_setfield (L, -2, "__gc"); - return 1; + lua_pushcfunction (L, lua_ucl_object_tostring); + lua_setfield (L, -2, "__tostring"); + + lua_pushcfunction (L, lua_ucl_object_tostring); + lua_setfield (L, -2, "tostring"); + + lua_pushcfunction (L, lua_ucl_object_unwrap); + lua_setfield (L, -2, "unwrap"); + + lua_pushcfunction (L, lua_ucl_object_unwrap); + lua_setfield (L, -2, "tolua"); + + lua_pushcfunction (L, lua_ucl_object_validate); + lua_setfield (L, -2, "validate"); + + lua_pushstring (L, OBJECT_META); + lua_setfield (L, -2, "class"); + + lua_pop (L, 1); } static int @@ -774,6 +1091,7 @@ luaopen_ucl (lua_State *L) { lua_ucl_parser_mt (L); lua_ucl_null_mt (L); + lua_ucl_object_mt (L); /* Create the refs weak table: */ lua_createtable (L, 0, 2); diff --git a/contrib/libucl/m4/ax_lua.m4 b/contrib/libucl/m4/ax_lua.m4 new file mode 100644 index 000000000000..f8e2fd4c85ce --- /dev/null +++ b/contrib/libucl/m4/ax_lua.m4 @@ -0,0 +1,664 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lua.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# +# DESCRIPTION +# +# Detect a Lua interpreter, optionally specifying a minimum and maximum +# version number. Set up important Lua paths, such as the directories in +# which to install scripts and modules (shared libraries). +# +# Also detect Lua headers and libraries. The Lua version contained in the +# header is checked to match the Lua interpreter version exactly. When +# searching for Lua libraries, the version number is used as a suffix. +# This is done with the goal of supporting multiple Lua installs (5.1, +# 5.2, and 5.3 side-by-side). +# +# A note on compatibility with previous versions: This file has been +# mostly rewritten for serial 18. Most developers should be able to use +# these macros without needing to modify configure.ac. Care has been taken +# to preserve each macro's behavior, but there are some differences: +# +# 1) AX_WITH_LUA is deprecated; it now expands to the exact same thing as +# AX_PROG_LUA with no arguments. +# +# 2) AX_LUA_HEADERS now checks that the version number defined in lua.h +# matches the interpreter version. AX_LUA_HEADERS_VERSION is therefore +# unnecessary, so it is deprecated and does not expand to anything. +# +# 3) The configure flag --with-lua-suffix no longer exists; the user +# should instead specify the LUA precious variable on the command line. +# See the AX_PROG_LUA description for details. +# +# Please read the macro descriptions below for more information. +# +# This file was inspired by Andrew Dalke's and James Henstridge's +# python.m4 and Tom Payne's, Matthieu Moy's, and Reuben Thomas's ax_lua.m4 +# (serial 17). Basically, this file is a mash-up of those two files. I +# like to think it combines the best of the two! +# +# AX_PROG_LUA: Search for the Lua interpreter, and set up important Lua +# paths. Adds precious variable LUA, which may contain the path of the Lua +# interpreter. If LUA is blank, the user's path is searched for an +# suitable interpreter. +# +# If MINIMUM-VERSION is supplied, then only Lua interpreters with a +# version number greater or equal to MINIMUM-VERSION will be accepted. If +# TOO-BIG-VERSION is also supplied, then only Lua interpreters with a +# version number greater or equal to MINIMUM-VERSION and less than +# TOO-BIG-VERSION will be accepted. +# +# The Lua version number, LUA_VERSION, is found from the interpreter, and +# substituted. LUA_PLATFORM is also found, but not currently supported (no +# standard representation). +# +# Finally, the macro finds four paths: +# +# luadir Directory to install Lua scripts. +# pkgluadir $luadir/$PACKAGE +# luaexecdir Directory to install Lua modules. +# pkgluaexecdir $luaexecdir/$PACKAGE +# +# These paths are found based on $prefix, $exec_prefix, Lua's +# package.path, and package.cpath. The first path of package.path +# beginning with $prefix is selected as luadir. The first path of +# package.cpath beginning with $exec_prefix is used as luaexecdir. This +# should work on all reasonable Lua installations. If a path cannot be +# determined, a default path is used. Of course, the user can override +# these later when invoking make. +# +# luadir Default: $prefix/share/lua/$LUA_VERSION +# luaexecdir Default: $exec_prefix/lib/lua/$LUA_VERSION +# +# These directories can be used by Automake as install destinations. The +# variable name minus 'dir' needs to be used as a prefix to the +# appropriate Automake primary, e.g. lua_SCRIPS or luaexec_LIBRARIES. +# +# If an acceptable Lua interpreter is found, then ACTION-IF-FOUND is +# performed, otherwise ACTION-IF-NOT-FOUND is preformed. If ACTION-IF-NOT- +# FOUND is blank, then it will default to printing an error. To prevent +# the default behavior, give ':' as an action. +# +# AX_LUA_HEADERS: Search for Lua headers. Requires that AX_PROG_LUA be +# expanded before this macro. Adds precious variable LUA_INCLUDE, which +# may contain Lua specific include flags, e.g. -I/usr/include/lua5.1. If +# LUA_INCLUDE is blank, then this macro will attempt to find suitable +# flags. +# +# LUA_INCLUDE can be used by Automake to compile Lua modules or +# executables with embedded interpreters. The *_CPPFLAGS variables should +# be used for this purpose, e.g. myprog_CPPFLAGS = $(LUA_INCLUDE). +# +# This macro searches for the header lua.h (and others). The search is +# performed with a combination of CPPFLAGS, CPATH, etc, and LUA_INCLUDE. +# If the search is unsuccessful, then some common directories are tried. +# If the headers are then found, then LUA_INCLUDE is set accordingly. +# +# The paths automatically searched are: +# +# * /usr/include/luaX.Y +# * /usr/include/lua/X.Y +# * /usr/include/luaXY +# * /usr/local/include/luaX.Y +# * /usr/local/include/lua-X.Y +# * /usr/local/include/lua/X.Y +# * /usr/local/include/luaXY +# +# (Where X.Y is the Lua version number, e.g. 5.1.) +# +# The Lua version number found in the headers is always checked to match +# the Lua interpreter's version number. Lua headers with mismatched +# version numbers are not accepted. +# +# If headers are found, then ACTION-IF-FOUND is performed, otherwise +# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then +# it will default to printing an error. To prevent the default behavior, +# set the action to ':'. +# +# AX_LUA_LIBS: Search for Lua libraries. Requires that AX_PROG_LUA be +# expanded before this macro. Adds precious variable LUA_LIB, which may +# contain Lua specific linker flags, e.g. -llua5.1. If LUA_LIB is blank, +# then this macro will attempt to find suitable flags. +# +# LUA_LIB can be used by Automake to link Lua modules or executables with +# embedded interpreters. The *_LIBADD and *_LDADD variables should be used +# for this purpose, e.g. mymod_LIBADD = $(LUA_LIB). +# +# This macro searches for the Lua library. More technically, it searches +# for a library containing the function lua_load. The search is performed +# with a combination of LIBS, LIBRARY_PATH, and LUA_LIB. +# +# If the search determines that some linker flags are missing, then those +# flags will be added to LUA_LIB. +# +# If libraries are found, then ACTION-IF-FOUND is performed, otherwise +# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then +# it will default to printing an error. To prevent the default behavior, +# set the action to ':'. +# +# AX_LUA_READLINE: Search for readline headers and libraries. Requires the +# AX_LIB_READLINE macro, which is provided by ax_lib_readline.m4 from the +# Autoconf Archive. +# +# If a readline compatible library is found, then ACTION-IF-FOUND is +# performed, otherwise ACTION-IF-NOT-FOUND is performed. +# +# LICENSE +# +# Copyright (c) 2015 Reuben Thomas +# Copyright (c) 2014 Tim Perkins +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 39 + +dnl ========================================================================= +dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION], +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_PROG_LUA], +[ + dnl Check for required tools. + AC_REQUIRE([AC_PROG_GREP]) + AC_REQUIRE([AC_PROG_SED]) + + dnl Make LUA a precious variable. + AC_ARG_VAR([LUA], [The Lua interpreter, e.g. /usr/bin/lua5.1]) + + dnl Find a Lua interpreter. + m4_define_default([_AX_LUA_INTERPRETER_LIST], + [lua lua5.3 lua53 lua5.2 lua52 lua5.1 lua51 lua50]) + + m4_if([$1], [], + [ dnl No version check is needed. Find any Lua interpreter. + AS_IF([test "x$LUA" = 'x'], + [AC_PATH_PROGS([LUA], [_AX_LUA_INTERPRETER_LIST], [:])]) + ax_display_LUA='lua' + + AS_IF([test "x$LUA" != 'x:'], + [ dnl At least check if this is a Lua interpreter. + AC_MSG_CHECKING([if $LUA is a Lua interpreter]) + _AX_LUA_CHK_IS_INTRP([$LUA], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([not a Lua interpreter]) + ]) + ]) + ], + [ dnl A version check is needed. + AS_IF([test "x$LUA" != 'x'], + [ dnl Check if this is a Lua interpreter. + AC_MSG_CHECKING([if $LUA is a Lua interpreter]) + _AX_LUA_CHK_IS_INTRP([$LUA], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([not a Lua interpreter]) + ]) + dnl Check the version. + m4_if([$2], [], + [_ax_check_text="whether $LUA version >= $1"], + [_ax_check_text="whether $LUA version >= $1, < $2"]) + AC_MSG_CHECKING([$_ax_check_text]) + _AX_LUA_CHK_VER([$LUA], [$1], [$2], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([version is out of range for specified LUA])]) + ax_display_LUA=$LUA + ], + [ dnl Try each interpreter until we find one that satisfies VERSION. + m4_if([$2], [], + [_ax_check_text="for a Lua interpreter with version >= $1"], + [_ax_check_text="for a Lua interpreter with version >= $1, < $2"]) + AC_CACHE_CHECK([$_ax_check_text], + [ax_cv_pathless_LUA], + [ for ax_cv_pathless_LUA in _AX_LUA_INTERPRETER_LIST none; do + test "x$ax_cv_pathless_LUA" = 'xnone' && break + _AX_LUA_CHK_IS_INTRP([$ax_cv_pathless_LUA], [], [continue]) + _AX_LUA_CHK_VER([$ax_cv_pathless_LUA], [$1], [$2], [break]) + done + ]) + dnl Set $LUA to the absolute path of $ax_cv_pathless_LUA. + AS_IF([test "x$ax_cv_pathless_LUA" = 'xnone'], + [LUA=':'], + [AC_PATH_PROG([LUA], [$ax_cv_pathless_LUA])]) + ax_display_LUA=$ax_cv_pathless_LUA + ]) + ]) + + AS_IF([test "x$LUA" = 'x:'], + [ dnl Run any user-specified action, or abort. + m4_default([$4], [AC_MSG_ERROR([cannot find suitable Lua interpreter])]) + ], + [ dnl Query Lua for its version number. + AC_CACHE_CHECK([for $ax_display_LUA version], + [ax_cv_lua_version], + [ dnl Get the interpreter version in X.Y format. This should work for + dnl interpreters version 5.0 and beyond. + ax_cv_lua_version=[`$LUA -e ' + -- return a version number in X.Y format + local _, _, ver = string.find(_VERSION, "^Lua (%d+%.%d+)") + print(ver)'`] + ]) + AS_IF([test "x$ax_cv_lua_version" = 'x'], + [AC_MSG_ERROR([invalid Lua version number])]) + AC_SUBST([LUA_VERSION], [$ax_cv_lua_version]) + AC_SUBST([LUA_SHORT_VERSION], [`echo "$LUA_VERSION" | $SED 's|\.||'`]) + + dnl The following check is not supported: + dnl At times (like when building shared libraries) you may want to know + dnl which OS platform Lua thinks this is. + AC_CACHE_CHECK([for $ax_display_LUA platform], + [ax_cv_lua_platform], + [ax_cv_lua_platform=[`$LUA -e 'print("unknown")'`]]) + AC_SUBST([LUA_PLATFORM], [$ax_cv_lua_platform]) + + dnl Use the values of $prefix and $exec_prefix for the corresponding + dnl values of LUA_PREFIX and LUA_EXEC_PREFIX. These are made distinct + dnl variables so they can be overridden if need be. However, the general + dnl consensus is that you shouldn't need this ability. + AC_SUBST([LUA_PREFIX], ['${prefix}']) + AC_SUBST([LUA_EXEC_PREFIX], ['${exec_prefix}']) + + dnl Lua provides no way to query the script directory, and instead + dnl provides LUA_PATH. However, we should be able to make a safe educated + dnl guess. If the built-in search path contains a directory which is + dnl prefixed by $prefix, then we can store scripts there. The first + dnl matching path will be used. + AC_CACHE_CHECK([for $ax_display_LUA script directory], + [ax_cv_lua_luadir], + [ AS_IF([test "x$prefix" = 'xNONE'], + [ax_lua_prefix=$ac_default_prefix], + [ax_lua_prefix=$prefix]) + + dnl Initialize to the default path. + ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION" + + dnl Try to find a path with the prefix. + _AX_LUA_FND_PRFX_PTH([$LUA], [$ax_lua_prefix], [script]) + AS_IF([test "x$ax_lua_prefixed_path" != 'x'], + [ dnl Fix the prefix. + _ax_strip_prefix=`echo "$ax_lua_prefix" | $SED 's|.|.|g'` + ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \ + $SED "s|^$_ax_strip_prefix|$LUA_PREFIX|"` + ]) + ]) + AC_SUBST([luadir], [$ax_cv_lua_luadir]) + AC_SUBST([pkgluadir], [\${luadir}/$PACKAGE]) + + dnl Lua provides no way to query the module directory, and instead + dnl provides LUA_PATH. However, we should be able to make a safe educated + dnl guess. If the built-in search path contains a directory which is + dnl prefixed by $exec_prefix, then we can store modules there. The first + dnl matching path will be used. + AC_CACHE_CHECK([for $ax_display_LUA module directory], + [ax_cv_lua_luaexecdir], + [ AS_IF([test "x$exec_prefix" = 'xNONE'], + [ax_lua_exec_prefix=$ax_lua_prefix], + [ax_lua_exec_prefix=$exec_prefix]) + + dnl Initialize to the default path. + ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION" + + dnl Try to find a path with the prefix. + _AX_LUA_FND_PRFX_PTH([$LUA], + [$ax_lua_exec_prefix], [module]) + AS_IF([test "x$ax_lua_prefixed_path" != 'x'], + [ dnl Fix the prefix. + _ax_strip_prefix=`echo "$ax_lua_exec_prefix" | $SED 's|.|.|g'` + ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \ + $SED "s|^$_ax_strip_prefix|$LUA_EXEC_PREFIX|"` + ]) + ]) + AC_SUBST([luaexecdir], [$ax_cv_lua_luaexecdir]) + AC_SUBST([pkgluaexecdir], [\${luaexecdir}/$PACKAGE]) + + dnl Run any user specified action. + $3 + ]) +]) + +dnl AX_WITH_LUA is now the same thing as AX_PROG_LUA. +AC_DEFUN([AX_WITH_LUA], +[ + AC_MSG_WARN([[$0 is deprecated, please use AX_PROG_LUA instead]]) + AX_PROG_LUA +]) + + +dnl ========================================================================= +dnl _AX_LUA_CHK_IS_INTRP(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +dnl ========================================================================= +AC_DEFUN([_AX_LUA_CHK_IS_INTRP], +[ + dnl A minimal Lua factorial to prove this is an interpreter. This should work + dnl for Lua interpreters version 5.0 and beyond. + _ax_lua_factorial=[`$1 2>/dev/null -e ' + -- a simple factorial + function fact (n) + if n == 0 then + return 1 + else + return n * fact(n-1) + end + end + print("fact(5) is " .. fact(5))'`] + AS_IF([test "$_ax_lua_factorial" = 'fact(5) is 120'], + [$2], [$3]) +]) + + +dnl ========================================================================= +dnl _AX_LUA_CHK_VER(PROG, MINIMUM-VERSION, [TOO-BIG-VERSION], +dnl [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +dnl ========================================================================= +AC_DEFUN([_AX_LUA_CHK_VER], +[ + dnl Check that the Lua version is within the bounds. Only the major and minor + dnl version numbers are considered. This should work for Lua interpreters + dnl version 5.0 and beyond. + _ax_lua_good_version=[`$1 -e ' + -- a script to compare versions + function verstr2num(verstr) + local _, _, majorver, minorver = string.find(verstr, "^(%d+)%.(%d+)") + if majorver and minorver then + return tonumber(majorver) * 100 + tonumber(minorver) + end + end + local minver = verstr2num("$2") + local _, _, trimver = string.find(_VERSION, "^Lua (.*)") + local ver = verstr2num(trimver) + local maxver = verstr2num("$3") or 1e9 + if minver <= ver and ver < maxver then + print("yes") + else + print("no") + end'`] + AS_IF([test "x$_ax_lua_good_version" = "xyes"], + [$4], [$5]) +]) + + +dnl ========================================================================= +dnl _AX_LUA_FND_PRFX_PTH(PROG, PREFIX, SCRIPT-OR-MODULE-DIR) +dnl ========================================================================= +AC_DEFUN([_AX_LUA_FND_PRFX_PTH], +[ + dnl Get the script or module directory by querying the Lua interpreter, + dnl filtering on the given prefix, and selecting the shallowest path. If no + dnl path is found matching the prefix, the result will be an empty string. + dnl The third argument determines the type of search, it can be 'script' or + dnl 'module'. Supplying 'script' will perform the search with package.path + dnl and LUA_PATH, and supplying 'module' will search with package.cpath and + dnl LUA_CPATH. This is done for compatibility with Lua 5.0. + + ax_lua_prefixed_path=[`$1 -e ' + -- get the path based on search type + local searchtype = "$3" + local paths = "" + if searchtype == "script" then + paths = (package and package.path) or LUA_PATH + elseif searchtype == "module" then + paths = (package and package.cpath) or LUA_CPATH + end + -- search for the prefix + local prefix = "'$2'" + local minpath = "" + local mindepth = 1e9 + string.gsub(paths, "(@<:@^;@:>@+)", + function (path) + path = string.gsub(path, "%?.*$", "") + path = string.gsub(path, "/@<:@^/@:>@*$", "") + if string.find(path, prefix) then + local depth = string.len(string.gsub(path, "@<:@^/@:>@", "")) + if depth < mindepth then + minpath = path + mindepth = depth + end + end + end) + print(minpath)'`] +]) + + +dnl ========================================================================= +dnl AX_LUA_HEADERS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_LUA_HEADERS], +[ + dnl Check for LUA_VERSION. + AC_MSG_CHECKING([if LUA_VERSION is defined]) + AS_IF([test "x$LUA_VERSION" != 'x'], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot check Lua headers without knowing LUA_VERSION]) + ]) + + dnl Make LUA_INCLUDE a precious variable. + AC_ARG_VAR([LUA_INCLUDE], [The Lua includes, e.g. -I/usr/include/lua5.1]) + + dnl Some default directories to search. + LUA_SHORT_VERSION=`echo "$LUA_VERSION" | $SED 's|\.||'` + m4_define_default([_AX_LUA_INCLUDE_LIST], + [ /usr/include/lua$LUA_VERSION \ + /usr/include/lua-$LUA_VERSION \ + /usr/include/lua/$LUA_VERSION \ + /usr/include/lua$LUA_SHORT_VERSION \ + /usr/local/include/lua$LUA_VERSION \ + /usr/local/include/lua-$LUA_VERSION \ + /usr/local/include/lua/$LUA_VERSION \ + /usr/local/include/lua$LUA_SHORT_VERSION \ + ]) + + dnl Try to find the headers. + _ax_lua_saved_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" + AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h]) + CPPFLAGS=$_ax_lua_saved_cppflags + + dnl Try some other directories if LUA_INCLUDE was not set. + AS_IF([test "x$LUA_INCLUDE" = 'x' && + test "x$ac_cv_header_lua_h" != 'xyes'], + [ dnl Try some common include paths. + for _ax_include_path in _AX_LUA_INCLUDE_LIST; do + test ! -d "$_ax_include_path" && continue + + AC_MSG_CHECKING([for Lua headers in]) + AC_MSG_RESULT([$_ax_include_path]) + + AS_UNSET([ac_cv_header_lua_h]) + AS_UNSET([ac_cv_header_lualib_h]) + AS_UNSET([ac_cv_header_lauxlib_h]) + AS_UNSET([ac_cv_header_luaconf_h]) + + _ax_lua_saved_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$_ax_include_path" + AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h]) + CPPFLAGS=$_ax_lua_saved_cppflags + + AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'], + [ LUA_INCLUDE="-I$_ax_include_path" + break + ]) + done + ]) + + AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'], + [ dnl Make a program to print LUA_VERSION defined in the header. + dnl TODO It would be really nice if we could do this without compiling a + dnl program, then it would work when cross compiling. But I'm not sure how + dnl to do this reliably. For now, assume versions match when cross compiling. + + AS_IF([test "x$cross_compiling" != 'xyes'], + [ AC_CACHE_CHECK([for Lua header version], + [ax_cv_lua_header_version], + [ _ax_lua_saved_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" + AC_RUN_IFELSE( + [ AC_LANG_SOURCE([[ +#include +#include +#include +int main(int argc, char ** argv) +{ + if(argc > 1) printf("%s", LUA_VERSION); + exit(EXIT_SUCCESS); +} +]]) + ], + [ ax_cv_lua_header_version=`./conftest$EXEEXT p | \ + $SED -n "s|^Lua \(@<:@0-9@:>@\{1,\}\.@<:@0-9@:>@\{1,\}\).\{0,\}|\1|p"` + ], + [ax_cv_lua_header_version='unknown']) + CPPFLAGS=$_ax_lua_saved_cppflags + ]) + + dnl Compare this to the previously found LUA_VERSION. + AC_MSG_CHECKING([if Lua header version matches $LUA_VERSION]) + AS_IF([test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"], + [ AC_MSG_RESULT([yes]) + ax_header_version_match='yes' + ], + [ AC_MSG_RESULT([no]) + ax_header_version_match='no' + ]) + ], + [ AC_MSG_WARN([cross compiling so assuming header version number matches]) + ax_header_version_match='yes' + ]) + ]) + + dnl Was LUA_INCLUDE specified? + AS_IF([test "x$ax_header_version_match" != 'xyes' && + test "x$LUA_INCLUDE" != 'x'], + [AC_MSG_ERROR([cannot find headers for specified LUA_INCLUDE])]) + + dnl Test the final result and run user code. + AS_IF([test "x$ax_header_version_match" = 'xyes'], [$1], + [m4_default([$2], [AC_MSG_ERROR([cannot find Lua includes])])]) +]) + +dnl AX_LUA_HEADERS_VERSION no longer exists, use AX_LUA_HEADERS. +AC_DEFUN([AX_LUA_HEADERS_VERSION], +[ + AC_MSG_WARN([[$0 is deprecated, please use AX_LUA_HEADERS instead]]) +]) + + +dnl ========================================================================= +dnl AX_LUA_LIBS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_LUA_LIBS], +[ + dnl TODO Should this macro also check various -L flags? + + dnl Check for LUA_VERSION. + AC_MSG_CHECKING([if LUA_VERSION is defined]) + AS_IF([test "x$LUA_VERSION" != 'x'], + [AC_MSG_RESULT([yes])], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot check Lua libs without knowing LUA_VERSION]) + ]) + + dnl Make LUA_LIB a precious variable. + AC_ARG_VAR([LUA_LIB], [The Lua library, e.g. -llua5.1]) + + AS_IF([test "x$LUA_LIB" != 'x'], + [ dnl Check that LUA_LIBS works. + _ax_lua_saved_libs=$LIBS + LIBS="$LUA_LIB $LIBS" + AC_SEARCH_LIBS([lua_load], [], + [_ax_found_lua_libs='yes'], + [_ax_found_lua_libs='no']) + LIBS=$_ax_lua_saved_libs + + dnl Check the result. + AS_IF([test "x$_ax_found_lua_libs" != 'xyes'], + [AC_MSG_ERROR([cannot find libs for specified LUA_LIB])]) + ], + [ dnl First search for extra libs. + _ax_lua_extra_libs='' + + _ax_lua_saved_libs=$LIBS + LIBS="$LUA_LIB $LIBS" + AC_SEARCH_LIBS([exp], [m]) + AC_SEARCH_LIBS([dlopen], [dl]) + LIBS=$_ax_lua_saved_libs + + AS_IF([test "x$ac_cv_search_exp" != 'xno' && + test "x$ac_cv_search_exp" != 'xnone required'], + [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp"]) + + AS_IF([test "x$ac_cv_search_dlopen" != 'xno' && + test "x$ac_cv_search_dlopen" != 'xnone required'], + [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen"]) + + dnl Try to find the Lua libs. + _ax_lua_saved_libs=$LIBS + LIBS="$LUA_LIB $LIBS" + AC_SEARCH_LIBS([lua_load], + [ lua$LUA_VERSION \ + lua$LUA_SHORT_VERSION \ + lua-$LUA_VERSION \ + lua-$LUA_SHORT_VERSION \ + lua \ + ], + [_ax_found_lua_libs='yes'], + [_ax_found_lua_libs='no'], + [$_ax_lua_extra_libs]) + LIBS=$_ax_lua_saved_libs + + AS_IF([test "x$ac_cv_search_lua_load" != 'xno' && + test "x$ac_cv_search_lua_load" != 'xnone required'], + [LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs"]) + ]) + + dnl Test the result and run user code. + AS_IF([test "x$_ax_found_lua_libs" = 'xyes'], [$1], + [m4_default([$2], [AC_MSG_ERROR([cannot find Lua libs])])]) +]) + + +dnl ========================================================================= +dnl AX_LUA_READLINE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ========================================================================= +AC_DEFUN([AX_LUA_READLINE], +[ + AX_LIB_READLINE + AS_IF([test "x$ac_cv_header_readline_readline_h" != 'x' && + test "x$ac_cv_header_readline_history_h" != 'x'], + [ LUA_LIBS_CFLAGS="-DLUA_USE_READLINE $LUA_LIBS_CFLAGS" + $1 + ], + [$2]) +]) diff --git a/contrib/libucl/python/setup.py b/contrib/libucl/python/setup.py new file mode 100644 index 000000000000..b2b8981705fb --- /dev/null +++ b/contrib/libucl/python/setup.py @@ -0,0 +1,37 @@ +import distutils.ccompiler +import distutils.sysconfig +from distutils.core import setup, Extension +import os + + +compiler = distutils.ccompiler.new_compiler() +search_paths=[os.path.expanduser('~/{}'), '/opt/local/{}', '/usr/local/{}', '/usr/{}'] +lib_paths = [ a.format("lib") for a in search_paths] +inc_paths = [ a.format("include") for a in search_paths] + +uclmodule = Extension('ucl', + include_dirs = inc_paths, + library_dirs = lib_paths, + libraries = ['ucl'], + sources = ['src/uclmodule.c'], + runtime_library_dirs = lib_paths, + language='c') + +setup(name='ucl', + version='1.0', + description='ucl parser and emmitter', + ext_modules = [uclmodule], + author="Eitan Adler", + author_email="lists@eitanadler.com", + url="https://github.com/vstakhov/libucl/", + license="MIT", + classifiers=["Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: DFSG approved", + "License :: OSI Approved :: MIT License", + "Programming Language :: C", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries", + ] + ) diff --git a/contrib/libucl/python/src/uclmodule.c b/contrib/libucl/python/src/uclmodule.c new file mode 100644 index 000000000000..d63b73aad9d8 --- /dev/null +++ b/contrib/libucl/python/src/uclmodule.c @@ -0,0 +1,156 @@ +// Attempts to load a UCL structure from a string +#include +#include + +static PyObject* +_basic_ucl_type(ucl_object_t const * const obj) { + if (obj->type == UCL_INT) { + return Py_BuildValue("L", (long long)ucl_object_toint (obj)); + } + else if (obj->type == UCL_FLOAT) { + return Py_BuildValue("d", ucl_object_todouble (obj)); + } + else if (obj->type == UCL_STRING) { + return Py_BuildValue("s", ucl_object_tostring (obj)); + } + else if (obj->type == UCL_BOOLEAN) { + // maybe used 'p' here? + return Py_BuildValue("s", ucl_object_tostring_forced (obj)); + } + else if (obj->type == UCL_TIME) { + return Py_BuildValue("d", ucl_object_todouble (obj)); + } + return NULL; +} + +static PyObject* +_iterate_valid_ucl(ucl_object_t const * obj) { + const ucl_object_t *tmp; + ucl_object_iter_t it = NULL; + + tmp = obj; + + while ((obj = ucl_iterate_object (tmp, &it, false))) { + + PyObject* val; + + val = _basic_ucl_type(obj); + if (!val) { + PyObject* key = NULL; + if (obj->key != NULL) { + key = Py_BuildValue("s", ucl_object_key(obj)); + } + + PyObject* ret; + ret = PyDict_New(); + if (obj->type == UCL_OBJECT) { + val = PyDict_New(); + const ucl_object_t *cur; + ucl_object_iter_t it_obj = NULL; + while ((cur = ucl_iterate_object (obj, &it_obj, true))) { + PyObject* keyobj = Py_BuildValue("s",ucl_object_key(cur)); + PyDict_SetItem(val, keyobj, _iterate_valid_ucl(cur)); + } + } + else if (obj->type == UCL_ARRAY) { + val = PyList_New(0); + const ucl_object_t *cur; + ucl_object_iter_t it_obj = NULL; + while ((cur = ucl_iterate_object (obj, &it_obj, true))) { + PyList_Append(val, _iterate_valid_ucl(cur)); + } + } + else if (obj->type == UCL_USERDATA) { + // XXX: this should be + // PyBytes_FromStringAndSize; where is the + // length from? + val = PyBytes_FromString(obj->value.ud); + } + } + return val; + } + + PyErr_SetString(PyExc_SystemError, "unhandled type"); + return NULL; +} + +static PyObject* +_internal_load_ucl(char* uclstr) { + PyObject* ret; + + struct ucl_parser *parser = ucl_parser_new (UCL_PARSER_NO_TIME); + + bool r = ucl_parser_add_string(parser, uclstr, 0); + if (r) { + if (ucl_parser_get_error (parser)) { + PyErr_SetString(PyExc_ValueError, ucl_parser_get_error(parser)); + ucl_parser_free(parser); + ret = NULL; + goto return_with_parser; + } else { + ucl_object_t* uclobj = ucl_parser_get_object(parser); + ret = _iterate_valid_ucl(uclobj); + ucl_object_unref(uclobj); + goto return_with_parser; + } + + } else { + PyErr_SetString(PyExc_ValueError, ucl_parser_get_error (parser)); + ret = NULL; + goto return_with_parser; + } + +return_with_parser: + ucl_parser_free(parser); + return ret; +} + +static PyObject* +ucl_load(PyObject *self, PyObject *args) { + char* uclstr; + if (PyArg_ParseTuple(args, "z", &uclstr)) { + if (!uclstr) { + Py_RETURN_NONE; + } + return _internal_load_ucl(uclstr); + } + return NULL; +} + +static PyObject* +ucl_validate(PyObject *self, PyObject *args) { + char *uclstr, *schema; + if (PyArg_ParseTuple(args, "zz", &uclstr, &schema)) { + if (!uclstr || !schema) { + Py_RETURN_NONE; + } + PyErr_SetString(PyExc_NotImplementedError, "schema validation is not yet supported"); + return NULL; + } + return NULL; +} + +static PyMethodDef uclMethods[] = { + {"load", ucl_load, METH_VARARGS, "Load UCL from stream"}, + {"validate", ucl_validate, METH_VARARGS, "Validate ucl stream against schema"}, + {NULL, NULL, 0, NULL} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef uclmodule = { + PyModuleDef_HEAD_INIT, + "ucl", + NULL, + -1, + uclMethods +}; + +PyMODINIT_FUNC +PyInit_ucl(void) { + return PyModule_Create(&uclmodule); +} +#else +void initucl(void) { + Py_InitModule("ucl", uclMethods); +} +#endif diff --git a/contrib/libucl/python/test.sh b/contrib/libucl/python/test.sh new file mode 100755 index 000000000000..53af6a3fd370 --- /dev/null +++ b/contrib/libucl/python/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -xe +python3.4 setup.py build_ext --inplace +./test_uclmodule.py -v +rm -rfv build +rm ucl.so diff --git a/contrib/libucl/python/test_uclmodule.py b/contrib/libucl/python/test_uclmodule.py new file mode 100755 index 000000000000..de295dc2000f --- /dev/null +++ b/contrib/libucl/python/test_uclmodule.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +import json +import unittest +import ucl +import sys + +if sys.version_info[:2] == (2, 7): + unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp + + +class TestUcl(unittest.TestCase): + def test_no_args(self): + with self.assertRaises(TypeError): + ucl.load() + + def test_multi_args(self): + with self.assertRaises(TypeError): + ucl.load(0,0) + + def test_none(self): + r = ucl.load(None) + self.assertEqual(r, None) + + def test_int(self): + r = ucl.load("a : 1") + self.assertEqual(ucl.load("a : 1"), { "a" : 1 } ) + + def test_braced_int(self): + self.assertEqual(ucl.load("{a : 1}"), { "a" : 1 } ) + + def test_nested_int(self): + self.assertEqual(ucl.load("a : { b : 1 }"), { "a" : { "b" : 1 } }) + + def test_str(self): + self.assertEqual(ucl.load("a : b"), {"a" : "b"}) + + def test_float(self): + self.assertEqual(ucl.load("a : 1.1"), {"a" : 1.1}) + + def test_empty_ucl(self): + r = ucl.load("{}") + self.assertEqual(r, {}) + + def test_single_brace(self): + self.assertEqual(ucl.load("{"), {}) + + def test_single_back_brace(self): + ucl.load("}") + + def test_single_square_forward(self): + self.assertEqual(ucl.load("["), []) + + def test_invalid_ucl(self): + with self.assertRaisesRegex(ValueError, "unfinished key$"): + ucl.load('{ "var"') + + def test_comment_ignored(self): + self.assertEqual(ucl.load("{/*1*/}"), {}) + + def test_1_in(self): + with open("../tests/basic/1.in", "r") as in1: + self.assertEqual(ucl.load(in1.read()), {'key1': 'value'}) + + def test_every_type(self): + totest="""{ + "key1": value; + "key2": value2; + "key3": "value;" + "key4": 1.0, + "key5": -0xdeadbeef + "key6": 0xdeadbeef.1 + "key7": 0xreadbeef + "key8": -1e-10, + "key9": 1 + "key10": true + "key11": no + "key12": yes + }""" + correct = { + 'key1': 'value', + 'key2': 'value2', + 'key3': 'value;', + 'key4': 1.0, + 'key5': -3735928559, + 'key6': '0xdeadbeef.1', + 'key7': '0xreadbeef', + 'key8': -1e-10, + 'key9': 1, + 'key10': 'true', + 'key11': 'false', + 'key12': 'true', + } + self.assertEqual(ucl.load(totest), correct) + + def test_validation_useless(self): + with self.assertRaises(NotImplementedError): + ucl.validate("","") + +if __name__ == '__main__': + unittest.main() diff --git a/contrib/libucl/src/Makefile.am b/contrib/libucl/src/Makefile.am index c3f0c9fffb60..c2f3a4b42347 100644 --- a/contrib/libucl/src/Makefile.am +++ b/contrib/libucl/src/Makefile.am @@ -11,6 +11,8 @@ libucl_la_SOURCES= ucl_emitter.c \ ucl_parser.c \ ucl_schema.c \ ucl_util.c \ + ucl_msgpack.c \ + ucl_sexp.c \ xxhash.c libucl_la_CFLAGS= $(libucl_common_cflags) \ @CURL_CFLAGS@ @@ -20,7 +22,8 @@ libucl_la_LIBADD= @LIBFETCH_LIBS@ \ @LIBREGEX_LIB@ \ @CURL_LIBS@ -include_HEADERS= $(top_srcdir)/include/ucl.h +include_HEADERS= $(top_srcdir)/include/ucl.h \ + $(top_srcdir)/include/ucl++.h noinst_HEADERS= ucl_internal.h \ xxhash.h \ ucl_hash.h \ diff --git a/contrib/libucl/src/tree.h b/contrib/libucl/src/tree.h index cee9373698c2..404b4a867be9 100644 --- a/contrib/libucl/src/tree.h +++ b/contrib/libucl/src/tree.h @@ -44,6 +44,13 @@ #define TREE_DELTA_MAX 1 +#ifndef _HU_FUNCTION +# if defined(__GNUC__) || defined(__clang__) +# define _HU_FUNCTION(x) __attribute__((__unused__)) x +# else +# define _HU_FUNCTION(x) x +# endif +#endif #define TREE_ENTRY(type) \ struct { \ @@ -68,9 +75,9 @@ #define TREE_DEFINE(node, field) \ \ - struct node *TREE_BALANCE_##node##_##field(struct node *); \ + static struct node *_HU_FUNCTION(TREE_BALANCE_##node##_##field)(struct node *); \ \ - struct node *TREE_ROTL_##node##_##field(struct node *self) \ + static struct node *_HU_FUNCTION(TREE_ROTL_##node##_##field)(struct node *self) \ { \ struct node *r= self->field.avl_right; \ self->field.avl_right= r->field.avl_left; \ @@ -78,7 +85,7 @@ return TREE_BALANCE_##node##_##field(r); \ } \ \ - struct node *TREE_ROTR_##node##_##field(struct node *self) \ + static struct node *_HU_FUNCTION(TREE_ROTR_##node##_##field)(struct node *self) \ { \ struct node *l= self->field.avl_left; \ self->field.avl_left= l->field.avl_right; \ @@ -86,7 +93,7 @@ return TREE_BALANCE_##node##_##field(l); \ } \ \ - struct node *TREE_BALANCE_##node##_##field(struct node *self) \ + static struct node *_HU_FUNCTION(TREE_BALANCE_##node##_##field)(struct node *self) \ { \ int delta= TREE_DELTA(self, field); \ \ @@ -111,7 +118,7 @@ return self; \ } \ \ - struct node *TREE_INSERT_##node##_##field \ + static struct node *_HU_FUNCTION(TREE_INSERT_##node##_##field) \ (struct node *self, struct node *elm, int (*compare)(struct node *lhs, struct node *rhs)) \ { \ if (!self) \ @@ -123,7 +130,7 @@ return TREE_BALANCE_##node##_##field(self); \ } \ \ - struct node *TREE_FIND_##node##_##field \ + static struct node *_HU_FUNCTION(TREE_FIND_##node##_##field) \ (struct node *self, struct node *elm, int (*compare)(struct node *lhs, struct node *rhs)) \ { \ if (!self) \ @@ -136,7 +143,7 @@ return TREE_FIND_##node##_##field(self->field.avl_right, elm, compare); \ } \ \ - struct node *TREE_MOVE_RIGHT(struct node *self, struct node *rhs) \ + static struct node *_HU_FUNCTION(TREE_MOVE_RIGHT)(struct node *self, struct node *rhs) \ { \ if (!self) \ return rhs; \ @@ -144,7 +151,7 @@ return TREE_BALANCE_##node##_##field(self); \ } \ \ - struct node *TREE_REMOVE_##node##_##field \ + static struct node *_HU_FUNCTION(TREE_REMOVE_##node##_##field) \ (struct node *self, struct node *elm, int (*compare)(struct node *lhs, struct node *rhs)) \ { \ if (!self) return 0; \ @@ -163,7 +170,7 @@ return TREE_BALANCE_##node##_##field(self); \ } \ \ - void TREE_FORWARD_APPLY_ALL_##node##_##field \ + static void _HU_FUNCTION(TREE_FORWARD_APPLY_ALL_##node##_##field) \ (struct node *self, void (*function)(struct node *node, void *data), void *data) \ { \ if (self) \ @@ -174,7 +181,7 @@ } \ } \ \ - void TREE_REVERSE_APPLY_ALL_##node##_##field \ + static void _HU_FUNCTION(TREE_REVERSE_APPLY_ALL_##node##_##field) \ (struct node *self, void (*function)(struct node *node, void *data), void *data) \ { \ if (self) \ diff --git a/contrib/libucl/src/ucl_chartable.h b/contrib/libucl/src/ucl_chartable.h index 5248e117c63d..db9f02900c02 100644 --- a/contrib/libucl/src/ucl_chartable.h +++ b/contrib/libucl/src/ucl_chartable.h @@ -26,7 +26,7 @@ #include "ucl_internal.h" -static const unsigned int ucl_chartable[255] = { +static const unsigned int ucl_chartable[256] = { UCL_CHARACTER_VALUE_END, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, @@ -255,6 +255,7 @@ UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR, UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR, UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR, UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR, +UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR, UCL_CHARACTER_KEY_START|UCL_CHARACTER_KEY|UCL_CHARACTER_VALUE_STR }; diff --git a/contrib/libucl/src/ucl_emitter.c b/contrib/libucl/src/ucl_emitter.c index 9ddf3584a25b..8bfbf09b8bd7 100644 --- a/contrib/libucl/src/ucl_emitter.c +++ b/contrib/libucl/src/ucl_emitter.c @@ -62,6 +62,7 @@ UCL_EMIT_TYPE_OPS(json); UCL_EMIT_TYPE_OPS(json_compact); UCL_EMIT_TYPE_OPS(config); UCL_EMIT_TYPE_OPS(yaml); +UCL_EMIT_TYPE_OPS(msgpack); #define UCL_EMIT_TYPE_CONTENT(type) { \ .ucl_emitter_write_elt = ucl_emit_ ## type ## _elt, \ @@ -71,12 +72,12 @@ UCL_EMIT_TYPE_OPS(yaml); .ucl_emitter_end_array = ucl_emit_ ## type ##_end_array \ } - const struct ucl_emitter_operations ucl_standartd_emitter_ops[] = { [UCL_EMIT_JSON] = UCL_EMIT_TYPE_CONTENT(json), [UCL_EMIT_JSON_COMPACT] = UCL_EMIT_TYPE_CONTENT(json_compact), [UCL_EMIT_CONFIG] = UCL_EMIT_TYPE_CONTENT(config), - [UCL_EMIT_YAML] = UCL_EMIT_TYPE_CONTENT(yaml) + [UCL_EMIT_YAML] = UCL_EMIT_TYPE_CONTENT(yaml), + [UCL_EMIT_MSGPACK] = UCL_EMIT_TYPE_CONTENT(msgpack) }; /* @@ -469,19 +470,150 @@ UCL_EMIT_TYPE_IMPL(json_compact, true) UCL_EMIT_TYPE_IMPL(config, false) UCL_EMIT_TYPE_IMPL(yaml, false) +static void +ucl_emit_msgpack_elt (struct ucl_emitter_context *ctx, + const ucl_object_t *obj, bool first, bool print_key) +{ + ucl_object_iter_t it; + struct ucl_object_userdata *ud; + const char *ud_out; + const ucl_object_t *cur, *celt; + + switch (obj->type) { + case UCL_INT: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + ucl_emitter_print_int_msgpack (ctx, ucl_object_toint (obj)); + break; + + case UCL_FLOAT: + case UCL_TIME: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + ucl_emitter_print_double_msgpack (ctx, ucl_object_todouble (obj)); + break; + + case UCL_BOOLEAN: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + ucl_emitter_print_bool_msgpack (ctx, ucl_object_toboolean (obj)); + break; + + case UCL_STRING: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + + if (obj->flags & UCL_OBJECT_BINARY) { + ucl_emitter_print_binary_string_msgpack (ctx, obj->value.sv, + obj->len); + } + else { + ucl_emitter_print_string_msgpack (ctx, obj->value.sv, obj->len); + } + break; + + case UCL_NULL: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + ucl_emitter_print_null_msgpack (ctx); + break; + + case UCL_OBJECT: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + ucl_emit_msgpack_start_obj (ctx, obj, print_key); + it = NULL; + + while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { + LL_FOREACH (cur, celt) { + ucl_emit_msgpack_elt (ctx, celt, false, true); + /* XXX: + * in msgpack the length of objects is encoded within a single elt + * so in case of multi-value keys we are using merely the first + * element ignoring others + */ + break; + } + } + + break; + + case UCL_ARRAY: + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + ucl_emit_msgpack_start_array (ctx, obj, print_key); + it = NULL; + + while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { + ucl_emit_msgpack_elt (ctx, cur, false, false); + } + + break; + + case UCL_USERDATA: + ud = (struct ucl_object_userdata *)obj; + ucl_emitter_print_key_msgpack (print_key, ctx, obj); + + if (ud->emitter) { + ud_out = ud->emitter (obj->value.ud); + if (ud_out == NULL) { + ud_out = "null"; + } + } + ucl_emitter_print_string_msgpack (ctx, obj->value.sv, obj->len); + break; + } +} + +static void +ucl_emit_msgpack_start_obj (struct ucl_emitter_context *ctx, + const ucl_object_t *obj, bool print_key) +{ + ucl_emitter_print_object_msgpack (ctx, obj->len); +} + +static void +ucl_emit_msgpack_start_array (struct ucl_emitter_context *ctx, + const ucl_object_t *obj, bool print_key) +{ + ucl_emitter_print_array_msgpack (ctx, obj->len); +} + +static void +ucl_emit_msgpack_end_object (struct ucl_emitter_context *ctx, + const ucl_object_t *obj) +{ + +} + +static void +ucl_emit_msgpack_end_array (struct ucl_emitter_context *ctx, + const ucl_object_t *obj) +{ + +} + unsigned char * ucl_object_emit (const ucl_object_t *obj, enum ucl_emitter emit_type) +{ + return ucl_object_emit_len (obj, emit_type, NULL); +} + +unsigned char * +ucl_object_emit_len (const ucl_object_t *obj, enum ucl_emitter emit_type, + size_t *outlen) { unsigned char *res = NULL; struct ucl_emitter_functions *func; + UT_string *s; + if (obj == NULL) { return NULL; } func = ucl_object_emit_memory_funcs ((void **)&res); + s = func->ud; if (func != NULL) { ucl_object_emit_full (obj, emit_type, func); + + if (outlen != NULL) { + *outlen = s->i; + } + ucl_object_emit_funcs_free (func); } diff --git a/contrib/libucl/src/ucl_emitter_utils.c b/contrib/libucl/src/ucl_emitter_utils.c index 91cad78bcbf6..95ac9a5d5776 100644 --- a/contrib/libucl/src/ucl_emitter_utils.c +++ b/contrib/libucl/src/ucl_emitter_utils.c @@ -62,6 +62,12 @@ static const struct ucl_emitter_context ucl_standard_emitters[] = { .id = UCL_EMIT_YAML, .func = NULL, .ops = &ucl_standartd_emitter_ops[UCL_EMIT_YAML] + }, + [UCL_EMIT_MSGPACK] = { + .name = "msgpack", + .id = UCL_EMIT_MSGPACK, + .func = NULL, + .ops = &ucl_standartd_emitter_ops[UCL_EMIT_MSGPACK] } }; @@ -73,7 +79,7 @@ static const struct ucl_emitter_context ucl_standard_emitters[] = { const struct ucl_emitter_context * ucl_emit_get_standard_context (enum ucl_emitter emit_type) { - if (emit_type >= UCL_EMIT_JSON && emit_type <= UCL_EMIT_YAML) { + if (emit_type >= UCL_EMIT_JSON && emit_type < UCL_EMIT_MAX) { return &ucl_standard_emitters[emit_type]; } diff --git a/contrib/libucl/src/ucl_hash.c b/contrib/libucl/src/ucl_hash.c index 275e84d478aa..7de8196fa014 100644 --- a/contrib/libucl/src/ucl_hash.c +++ b/contrib/libucl/src/ucl_hash.c @@ -26,6 +26,9 @@ #include "khash.h" #include "kvec.h" +#include +#include + struct ucl_hash_elt { const ucl_object_t *obj; size_t ar_idx; @@ -37,11 +40,78 @@ struct ucl_hash_struct { bool caseless; }; +static uint64_t +ucl_hash_seed (void) +{ + static uint64_t seed; + + if (seed == 0) { +#ifdef UCL_RANDOM_FUNCTION + seed = UCL_RANDOM_FUNCTION; +#else + /* Not very random but can be useful for our purposes */ + seed = time (NULL); +#endif + } + + return seed; +} + +static const unsigned char lc_map[256] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; + +#if (defined(WORD_BIT) && WORD_BIT == 64) || \ + (defined(__WORDSIZE) && __WORDSIZE == 64) || \ + defined(__x86_64__) || \ + defined(__amd64__) +#define UCL64_BIT_HASH 1 +#endif + +#ifdef UCL64_BIT_HASH static inline uint32_t ucl_hash_func (const ucl_object_t *o) { - return XXH32 (o->key, o->keylen, 0xdeadbeef); + return XXH64 (o->key, o->keylen, ucl_hash_seed ()); } +#else +static inline uint32_t +ucl_hash_func (const ucl_object_t *o) +{ + return XXH32 (o->key, o->keylen, ucl_hash_seed ()); +} +#endif static inline int ucl_hash_equal (const ucl_object_t *k1, const ucl_object_t *k2) @@ -56,33 +126,91 @@ ucl_hash_equal (const ucl_object_t *k1, const ucl_object_t *k2) KHASH_INIT (ucl_hash_node, const ucl_object_t *, struct ucl_hash_elt, 1, ucl_hash_func, ucl_hash_equal) +#ifdef UCL64_BIT_HASH static inline uint32_t ucl_hash_caseless_func (const ucl_object_t *o) { - void *xxh = XXH32_init (0xdeadbeef); - char hash_buf[64], *c; - const char *p; - ssize_t remain = o->keylen; + unsigned len = o->keylen; + unsigned leftover = o->keylen % 4; + unsigned fp, i; + const uint8_t* s = (const uint8_t*)o->key; + union { + struct { + unsigned char c1, c2, c3, c4; + } c; + uint32_t pp; + } u; + XXH64_state_t st; - p = o->key; - c = &hash_buf[0]; + fp = len - leftover; + XXH64_reset (&st, ucl_hash_seed ()); - while (remain > 0) { - *c++ = tolower (*p++); - - if (c - &hash_buf[0] == sizeof (hash_buf)) { - XXH32_update (xxh, hash_buf, sizeof (hash_buf)); - c = &hash_buf[0]; - } - remain --; + for (i = 0; i != fp; i += 4) { + u.c.c1 = s[i], u.c.c2 = s[i + 1], u.c.c3 = s[i + 2], u.c.c4 = s[i + 3]; + u.c.c1 = lc_map[u.c.c1]; + u.c.c2 = lc_map[u.c.c2]; + u.c.c3 = lc_map[u.c.c3]; + u.c.c4 = lc_map[u.c.c4]; + XXH64_update (&st, &u.pp, sizeof (u)); } - if (c - &hash_buf[0] != 0) { - XXH32_update (xxh, hash_buf, c - &hash_buf[0]); + u.pp = 0; + switch (leftover) { + case 3: + u.c.c3 = lc_map[(unsigned char)s[i++]]; + case 2: + u.c.c2 = lc_map[(unsigned char)s[i++]]; + case 1: + u.c.c1 = lc_map[(unsigned char)s[i]]; + XXH64_update (&st, &u.pp, leftover); + break; } - return XXH32_digest (xxh); + return XXH64_digest (&st); } +#else +static inline uint32_t +ucl_hash_caseless_func (const ucl_object_t *o) +{ + unsigned len = o->keylen; + unsigned leftover = o->keylen % 4; + unsigned fp, i; + const uint8_t* s = (const uint8_t*)o->key; + union { + struct { + unsigned char c1, c2, c3, c4; + } c; + uint32_t pp; + } u; + XXH32_state_t st; + + fp = len - leftover; + XXH32_reset (&st, ucl_hash_seed ()); + + for (i = 0; i != fp; i += 4) { + u.c.c1 = s[i], u.c.c2 = s[i + 1], u.c.c3 = s[i + 2], u.c.c4 = s[i + 3]; + u.c.c1 = lc_map[u.c.c1]; + u.c.c2 = lc_map[u.c.c2]; + u.c.c3 = lc_map[u.c.c3]; + u.c.c4 = lc_map[u.c.c4]; + XXH32_update (&st, &u.pp, sizeof (u)); + } + + u.pp = 0; + switch (leftover) { + case 3: + u.c.c3 = lc_map[(unsigned char)s[i++]]; + case 2: + u.c.c2 = lc_map[(unsigned char)s[i++]]; + case 1: + u.c.c1 = lc_map[(unsigned char)s[i]]; + XXH32_update (&st, &u.pp, leftover); + break; + } + + return XXH32_digest (&st); +} +#endif static inline int ucl_hash_caseless_equal (const ucl_object_t *k1, const ucl_object_t *k2) @@ -254,6 +382,11 @@ ucl_hash_iterate (ucl_hash_t *hashlin, ucl_hash_iter_t *iter) if (it == NULL) { it = UCL_ALLOC (sizeof (*it)); + + if (it == NULL) { + return NULL; + } + it->cur = &hashlin->ar.a[0]; it->end = it->cur + hashlin->ar.n; } @@ -336,7 +469,7 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) k = kh_get (ucl_hash_caseless_node, h, obj); if (k != kh_end (h)) { elt = &kh_value (h, k); - kv_A (hashlin->ar, elt->ar_idx) = NULL; + kv_del (const ucl_object_t *, hashlin->ar, elt->ar_idx); kh_del (ucl_hash_caseless_node, h, k); } } @@ -346,7 +479,7 @@ ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) k = kh_get (ucl_hash_node, h, obj); if (k != kh_end (h)) { elt = &kh_value (h, k); - kv_A (hashlin->ar, elt->ar_idx) = NULL; + kv_del (const ucl_object_t *, hashlin->ar, elt->ar_idx); kh_del (ucl_hash_node, h, k); } } diff --git a/contrib/libucl/src/ucl_internal.h b/contrib/libucl/src/ucl_internal.h index bdbe691d092b..31d6b1361383 100644 --- a/contrib/libucl/src/ucl_internal.h +++ b/contrib/libucl/src/ucl_internal.h @@ -145,15 +145,19 @@ enum ucl_character_type { struct ucl_macro { char *name; - ucl_macro_handler handler; + union { + ucl_macro_handler handler; + ucl_context_macro_handler context_handler; + } h; void* ud; + bool is_context; UT_hash_handle hh; }; struct ucl_stack { ucl_object_t *obj; struct ucl_stack *next; - int level; + uint64_t level; }; struct ucl_chunk { @@ -164,6 +168,8 @@ struct ucl_chunk { unsigned int line; unsigned int column; unsigned priority; + enum ucl_duplicate_strategy strategy; + enum ucl_parse_type parse_type; struct ucl_chunk *next; }; @@ -191,8 +197,12 @@ struct ucl_parser { enum ucl_parser_state prev_state; unsigned int recursion; int flags; + unsigned default_priority; + int err_code; ucl_object_t *top_obj; ucl_object_t *cur_obj; + ucl_object_t *trash_objs; + ucl_object_t *includepaths; char *cur_file; struct ucl_macro *macroes; struct ucl_stack *stack; @@ -220,13 +230,21 @@ size_t ucl_unescape_json_string (char *str, size_t len); * Handle include macro * @param data include data * @param len length of data + * @param args UCL object representing arguments to the macro * @param ud user data - * @param err error ptr * @return */ bool ucl_include_handler (const unsigned char *data, size_t len, const ucl_object_t *args, void* ud); +/** + * Handle tryinclude macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ud user data + * @return + */ bool ucl_try_include_handler (const unsigned char *data, size_t len, const ucl_object_t *args, void* ud); @@ -234,17 +252,52 @@ bool ucl_try_include_handler (const unsigned char *data, size_t len, * Handle includes macro * @param data include data * @param len length of data + * @param args UCL object representing arguments to the macro * @param ud user data - * @param err error ptr * @return */ bool ucl_includes_handler (const unsigned char *data, size_t len, const ucl_object_t *args, void* ud); +/** + * Handle priority macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ud user data + * @return + */ +bool ucl_priority_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud); + +/** + * Handle load macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ud user data + * @return + */ +bool ucl_load_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud); +/** + * Handle inherit macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ctx the current context object + * @param ud user data + * @return + */ +bool ucl_inherit_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, const ucl_object_t *ctx, void* ud); + size_t ucl_strlcpy (char *dst, const char *src, size_t siz); size_t ucl_strlcpy_unsafe (char *dst, const char *src, size_t siz); size_t ucl_strlcpy_tolower (char *dst, const char *src, size_t siz); +char *ucl_strnstr (const char *s, const char *find, int len); +char *ucl_strncasestr (const char *s, const char *find, int len); #ifdef __GNUC__ static inline void @@ -252,9 +305,10 @@ ucl_create_err (UT_string **err, const char *fmt, ...) __attribute__ (( format( printf, 2, 3) )); #endif +#undef UCL_FATAL_ERRORS + static inline void ucl_create_err (UT_string **err, const char *fmt, ...) - { if (*err == NULL) { utstring_new (*err); @@ -263,6 +317,10 @@ ucl_create_err (UT_string **err, const char *fmt, ...) utstring_printf_va (*err, fmt, ap); va_end (ap); } + +#ifdef UCL_FATAL_ERRORS + assert (0); +#endif } /** @@ -311,7 +369,7 @@ ucl_maybe_parse_boolean (ucl_object_t *obj, const unsigned char *start, size_t l } } - if (ret) { + if (ret && obj != NULL) { obj->type = UCL_BOOLEAN; obj->value.iv = val; } @@ -396,4 +454,89 @@ unsigned char * ucl_object_emit_single_json (const ucl_object_t *obj); */ bool ucl_maybe_long_string (const ucl_object_t *obj); +/** + * Print integer to the msgpack output + * @param ctx + * @param val + */ +void ucl_emitter_print_int_msgpack (struct ucl_emitter_context *ctx, + int64_t val); +/** + * Print integer to the msgpack output + * @param ctx + * @param val + */ +void ucl_emitter_print_double_msgpack (struct ucl_emitter_context *ctx, + double val); +/** + * Print double to the msgpack output + * @param ctx + * @param val + */ +void ucl_emitter_print_bool_msgpack (struct ucl_emitter_context *ctx, + bool val); +/** + * Print string to the msgpack output + * @param ctx + * @param s + * @param len + */ +void ucl_emitter_print_string_msgpack (struct ucl_emitter_context *ctx, + const char *s, size_t len); + +/** + * Print binary string to the msgpack output + * @param ctx + * @param s + * @param len + */ +void ucl_emitter_print_binary_string_msgpack (struct ucl_emitter_context *ctx, + const char *s, size_t len); + +/** + * Print array preamble for msgpack + * @param ctx + * @param len + */ +void ucl_emitter_print_array_msgpack (struct ucl_emitter_context *ctx, + size_t len); + +/** + * Print object preamble for msgpack + * @param ctx + * @param len + */ +void ucl_emitter_print_object_msgpack (struct ucl_emitter_context *ctx, + size_t len); +/** + * Print NULL to the msgpack output + * @param ctx + */ +void ucl_emitter_print_null_msgpack (struct ucl_emitter_context *ctx); +/** + * Print object's key if needed to the msgpack output + * @param print_key + * @param ctx + * @param obj + */ +void ucl_emitter_print_key_msgpack (bool print_key, + struct ucl_emitter_context *ctx, + const ucl_object_t *obj); + +/** + * Add new element to an object using the current merge strategy and priority + * @param parser + * @param nobj + * @return + */ +bool ucl_parser_process_object_element (struct ucl_parser *parser, + ucl_object_t *nobj); + +/** + * Parse msgpack chunk + * @param parser + * @return + */ +bool ucl_parse_msgpack (struct ucl_parser *parser); + #endif /* UCL_INTERNAL_H_ */ diff --git a/contrib/libucl/src/ucl_msgpack.c b/contrib/libucl/src/ucl_msgpack.c new file mode 100644 index 000000000000..e8ebfba8a35e --- /dev/null +++ b/contrib/libucl/src/ucl_msgpack.c @@ -0,0 +1,1600 @@ +/* + * Copyright (c) 2015, Vsevolod Stakhov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ucl.h" +#include "ucl_internal.h" + +#ifdef HAVE_ENDIAN_H +#include +#elif defined(HAVE_SYS_ENDIAN_H) +#include +#elif defined(HAVE_MACHINE_ENDIAN_H) +#include +#endif + +#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) + #if __BYTE_ORDER == __LITTLE_ENDIAN + #define __LITTLE_ENDIAN__ + #elif __BYTE_ORDER == __BIG_ENDIAN + #define __BIG_ENDIAN__ + #elif _WIN32 + #define __LITTLE_ENDIAN__ + #endif +#endif + +#define SWAP_LE_BE16(val) ((uint16_t) ( \ + (uint16_t) ((uint16_t) (val) >> 8) | \ + (uint16_t) ((uint16_t) (val) << 8))) + +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3) +# define SWAP_LE_BE32(val) ((uint32_t)__builtin_bswap32 ((uint32_t)(val))) +# define SWAP_LE_BE64(val) ((uint64_t)__builtin_bswap64 ((uint64_t)(val))) +#else + #define SWAP_LE_BE32(val) ((uint32_t)( \ + (((uint32_t)(val) & (uint32_t)0x000000ffU) << 24) | \ + (((uint32_t)(val) & (uint32_t)0x0000ff00U) << 8) | \ + (((uint32_t)(val) & (uint32_t)0x00ff0000U) >> 8) | \ + (((uint32_t)(val) & (uint32_t)0xff000000U) >> 24))) + + #define SWAP_LE_BE64(val) ((uint64_t)( \ + (((uint64_t)(val) & \ + (uint64_t)(0x00000000000000ffULL)) << 56) | \ + (((uint64_t)(val) & \ + (uint64_t)(0x000000000000ff00ULL)) << 40) | \ + (((uint64_t)(val) & \ + (uint64_t)(0x0000000000ff0000ULL)) << 24) | \ + (((uint64_t)(val) & \ + (uint64_t) (0x00000000ff000000ULL)) << 8) | \ + (((uint64_t)(val) & \ + (uint64_t)(0x000000ff00000000ULL)) >> 8) | \ + (((uint64_t)(val) & \ + (uint64_t)(0x0000ff0000000000ULL)) >> 24) | \ + (((uint64_t)(val) & \ + (uint64_t)(0x00ff000000000000ULL)) >> 40) | \ + (((uint64_t)(val) & \ + (uint64_t)(0xff00000000000000ULL)) >> 56))) +#endif + +#ifdef __LITTLE_ENDIAN__ +#define TO_BE16 SWAP_LE_BE16 +#define TO_BE32 SWAP_LE_BE32 +#define TO_BE64 SWAP_LE_BE64 +#define FROM_BE16 SWAP_LE_BE16 +#define FROM_BE32 SWAP_LE_BE32 +#define FROM_BE64 SWAP_LE_BE64 +#else +#define TO_BE16(val) (uint16_t)(val) +#define TO_BE32(val) (uint32_t)(val) +#define TO_BE64(val) (uint64_t)(val) +#define FROM_BE16(val) (uint16_t)(val) +#define FROM_BE32(val) (uint32_t)(val) +#define FROM_BE64(val) (uint64_t)(val) +#endif + +void +ucl_emitter_print_int_msgpack (struct ucl_emitter_context *ctx, int64_t val) +{ + const struct ucl_emitter_functions *func = ctx->func; + unsigned char buf[sizeof(uint64_t) + 1]; + const unsigned char mask_positive = 0x7f, mask_negative = 0xe0, + uint8_ch = 0xcc, uint16_ch = 0xcd, uint32_ch = 0xce, uint64_ch = 0xcf, + int8_ch = 0xd0, int16_ch = 0xd1, int32_ch = 0xd2, int64_ch = 0xd3; + unsigned len; + + if (val >= 0) { + if (val <= 0x7f) { + /* Fixed num 7 bits */ + len = 1; + buf[0] = mask_positive & val; + } + else if (val <= 0xff) { + len = 2; + buf[0] = uint8_ch; + buf[1] = val & 0xff; + } + else if (val <= 0xffff) { + uint16_t v = TO_BE16 (val); + + len = 3; + buf[0] = uint16_ch; + memcpy (&buf[1], &v, sizeof (v)); + } + else if (val <= 0xffffffff) { + uint32_t v = TO_BE32 (val); + + len = 5; + buf[0] = uint32_ch; + memcpy (&buf[1], &v, sizeof (v)); + } + else { + uint64_t v = TO_BE64 (val); + + len = 9; + buf[0] = uint64_ch; + memcpy (&buf[1], &v, sizeof (v)); + } + } + else { + uint64_t uval; + /* Bithack abs */ + uval = ((val ^ (val >> 63)) - (val >> 63)); + + if (val > -(1 << 5)) { + len = 1; + buf[0] = (mask_negative | uval) & 0xff; + } + else if (uval <= 0xff) { + len = 2; + buf[0] = int8_ch; + buf[1] = (unsigned char)val; + } + else if (uval <= 0xffff) { + uint16_t v = TO_BE16 (val); + + len = 3; + buf[0] = int16_ch; + memcpy (&buf[1], &v, sizeof (v)); + } + else if (uval <= 0xffffffff) { + uint32_t v = TO_BE32 (val); + + len = 5; + buf[0] = int32_ch; + memcpy (&buf[1], &v, sizeof (v)); + } + else { + uint64_t v = TO_BE64 (val); + + len = 9; + buf[0] = int64_ch; + memcpy (&buf[1], &v, sizeof (v)); + } + } + + func->ucl_emitter_append_len (buf, len, func->ud); +} + +void +ucl_emitter_print_double_msgpack (struct ucl_emitter_context *ctx, double val) +{ + const struct ucl_emitter_functions *func = ctx->func; + union { + double d; + uint64_t i; + } u; + const unsigned char dbl_ch = 0xcb; + unsigned char buf[sizeof(double) + 1]; + + /* Convert to big endian */ + u.d = val; + u.i = TO_BE64 (u.i); + + buf[0] = dbl_ch; + memcpy (&buf[1], &u.d, sizeof (double)); + func->ucl_emitter_append_len (buf, sizeof (buf), func->ud); +} + +void +ucl_emitter_print_bool_msgpack (struct ucl_emitter_context *ctx, bool val) +{ + const struct ucl_emitter_functions *func = ctx->func; + const unsigned char true_ch = 0xc3, false_ch = 0xc2; + + func->ucl_emitter_append_character (val ? true_ch : false_ch, 1, func->ud); +} + +void +ucl_emitter_print_string_msgpack (struct ucl_emitter_context *ctx, + const char *s, size_t len) +{ + const struct ucl_emitter_functions *func = ctx->func; + const unsigned char fix_mask = 0xA0, l8_ch = 0xd9, l16_ch = 0xda, l32_ch = 0xdb; + unsigned char buf[5]; + unsigned blen; + + if (len <= 0x1F) { + blen = 1; + buf[0] = (len | fix_mask) & 0xff; + } + else if (len <= 0xff) { + blen = 2; + buf[0] = l8_ch; + buf[1] = len & 0xff; + } + else if (len <= 0xffff) { + uint16_t bl = TO_BE16 (len); + + blen = 3; + buf[0] = l16_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + else { + uint32_t bl = TO_BE32 (len); + + blen = 5; + buf[0] = l32_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + + func->ucl_emitter_append_len (buf, blen, func->ud); + func->ucl_emitter_append_len (s, len, func->ud); +} + +void +ucl_emitter_print_binary_string_msgpack (struct ucl_emitter_context *ctx, + const char *s, size_t len) +{ + const struct ucl_emitter_functions *func = ctx->func; + const unsigned char l8_ch = 0xc4, l16_ch = 0xc5, l32_ch = 0xc6; + unsigned char buf[5]; + unsigned blen; + + if (len <= 0xff) { + blen = 2; + buf[0] = l8_ch; + buf[1] = len & 0xff; + } + else if (len <= 0xffff) { + uint16_t bl = TO_BE16 (len); + + blen = 3; + buf[0] = l16_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + else { + uint32_t bl = TO_BE32 (len); + + blen = 5; + buf[0] = l32_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + + func->ucl_emitter_append_len (buf, blen, func->ud); + func->ucl_emitter_append_len (s, len, func->ud); +} + +void +ucl_emitter_print_null_msgpack (struct ucl_emitter_context *ctx) +{ + const struct ucl_emitter_functions *func = ctx->func; + const unsigned char nil = 0xc0; + + func->ucl_emitter_append_character (nil, 1, func->ud); +} + +void +ucl_emitter_print_key_msgpack (bool print_key, struct ucl_emitter_context *ctx, + const ucl_object_t *obj) +{ + if (print_key) { + ucl_emitter_print_string_msgpack (ctx, obj->key, obj->keylen); + } +} + +void +ucl_emitter_print_array_msgpack (struct ucl_emitter_context *ctx, size_t len) +{ + const struct ucl_emitter_functions *func = ctx->func; + const unsigned char fix_mask = 0x90, l16_ch = 0xdc, l32_ch = 0xdd; + unsigned char buf[5]; + unsigned blen; + + if (len <= 0xF) { + blen = 1; + buf[0] = (len | fix_mask) & 0xff; + } + else if (len <= 0xffff) { + uint16_t bl = TO_BE16 (len); + + blen = 3; + buf[0] = l16_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + else { + uint32_t bl = TO_BE32 (len); + + blen = 5; + buf[0] = l32_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + + func->ucl_emitter_append_len (buf, blen, func->ud); +} + +void +ucl_emitter_print_object_msgpack (struct ucl_emitter_context *ctx, size_t len) +{ + const struct ucl_emitter_functions *func = ctx->func; + const unsigned char fix_mask = 0x80, l16_ch = 0xde, l32_ch = 0xdf; + unsigned char buf[5]; + unsigned blen; + + if (len <= 0xF) { + blen = 1; + buf[0] = (len | fix_mask) & 0xff; + } + else if (len <= 0xffff) { + uint16_t bl = TO_BE16 (len); + + blen = 3; + buf[0] = l16_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + else { + uint32_t bl = TO_BE32 (len); + + blen = 5; + buf[0] = l32_ch; + memcpy (&buf[1], &bl, sizeof (bl)); + } + + func->ucl_emitter_append_len (buf, blen, func->ud); +} + + +enum ucl_msgpack_format { + msgpack_positive_fixint = 0, + msgpack_fixmap, + msgpack_fixarray, + msgpack_fixstr, + msgpack_nil, + msgpack_false, + msgpack_true, + msgpack_bin8, + msgpack_bin16, + msgpack_bin32, + msgpack_ext8, + msgpack_ext16, + msgpack_ext32, + msgpack_float32, + msgpack_float64, + msgpack_uint8, + msgpack_uint16, + msgpack_uint32, + msgpack_uint64, + msgpack_int8, + msgpack_int16, + msgpack_int32, + msgpack_int64, + msgpack_fixext1, + msgpack_fixext2, + msgpack_fixext4, + msgpack_fixext8, + msgpack_fixext16, + msgpack_str8, + msgpack_str16, + msgpack_str32, + msgpack_array16, + msgpack_array32, + msgpack_map16, + msgpack_map32, + msgpack_negative_fixint, + msgpack_invalid +}; + +typedef ssize_t (*ucl_msgpack_parse_function)(struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); + +static ssize_t ucl_msgpack_parse_map (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_array (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_string (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_int (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_float (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_bool (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_null (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); +static ssize_t ucl_msgpack_parse_ignore (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain); + +#define MSGPACK_FLAG_FIXED (1 << 0) +#define MSGPACK_FLAG_CONTAINER (1 << 1) +#define MSGPACK_FLAG_TYPEVALUE (1 << 2) +#define MSGPACK_FLAG_EXT (1 << 3) +#define MSGPACK_FLAG_ASSOC (1 << 4) +#define MSGPACK_FLAG_KEY (1 << 5) +#define MSGPACK_CONTAINER_BIT (1ULL << 62) + +/* + * Search tree packed in array + */ +struct ucl_msgpack_parser { + uint8_t prefix; /* Prefix byte */ + uint8_t prefixlen; /* Length of prefix in bits */ + uint8_t fmt; /* The desired format */ + uint8_t len; /* Length of the object + (either length bytes + or length of value in case + of fixed objects */ + uint8_t flags; /* Flags of the specified type */ + ucl_msgpack_parse_function func; /* Parser function */ +} parsers[] = { + { + 0xa0, + 3, + msgpack_fixstr, + 0, + MSGPACK_FLAG_FIXED|MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0x0, + 1, + msgpack_positive_fixint, + 0, + MSGPACK_FLAG_FIXED|MSGPACK_FLAG_TYPEVALUE, + ucl_msgpack_parse_int + }, + { + 0xe0, + 3, + msgpack_negative_fixint, + 0, + MSGPACK_FLAG_FIXED|MSGPACK_FLAG_TYPEVALUE, + ucl_msgpack_parse_int + }, + { + 0x80, + 4, + msgpack_fixmap, + 0, + MSGPACK_FLAG_FIXED|MSGPACK_FLAG_CONTAINER|MSGPACK_FLAG_ASSOC, + ucl_msgpack_parse_map + }, + { + 0x90, + 4, + msgpack_fixarray, + 0, + MSGPACK_FLAG_FIXED|MSGPACK_FLAG_CONTAINER, + ucl_msgpack_parse_array + }, + { + 0xd9, + 8, + msgpack_str8, + 1, + MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0xc4, + 8, + msgpack_bin8, + 1, + MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0xcf, + 8, + msgpack_uint64, + 8, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xd3, + 8, + msgpack_int64, + 8, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xce, + 8, + msgpack_uint32, + 4, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xd2, + 8, + msgpack_int32, + 4, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xcb, + 8, + msgpack_float64, + 8, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_float + }, + { + 0xca, + 8, + msgpack_float32, + 4, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_float + }, + { + 0xc2, + 8, + msgpack_false, + 1, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_TYPEVALUE, + ucl_msgpack_parse_bool + }, + { + 0xc3, + 8, + msgpack_true, + 1, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_TYPEVALUE, + ucl_msgpack_parse_bool + }, + { + 0xcc, + 8, + msgpack_uint8, + 1, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xcd, + 8, + msgpack_uint16, + 2, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xd0, + 8, + msgpack_int8, + 1, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xd1, + 8, + msgpack_int16, + 2, + MSGPACK_FLAG_FIXED, + ucl_msgpack_parse_int + }, + { + 0xc0, + 8, + msgpack_nil, + 0, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_TYPEVALUE, + ucl_msgpack_parse_null + }, + { + 0xda, + 8, + msgpack_str16, + 2, + MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0xdb, + 8, + msgpack_str32, + 4, + MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0xc5, + 8, + msgpack_bin16, + 2, + MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0xc6, + 8, + msgpack_bin32, + 4, + MSGPACK_FLAG_KEY, + ucl_msgpack_parse_string + }, + { + 0xdc, + 8, + msgpack_array16, + 2, + MSGPACK_FLAG_CONTAINER, + ucl_msgpack_parse_array + }, + { + 0xdd, + 8, + msgpack_array32, + 4, + MSGPACK_FLAG_CONTAINER, + ucl_msgpack_parse_array + }, + { + 0xde, + 8, + msgpack_map16, + 2, + MSGPACK_FLAG_CONTAINER|MSGPACK_FLAG_ASSOC, + ucl_msgpack_parse_map + }, + { + 0xdf, + 8, + msgpack_map32, + 4, + MSGPACK_FLAG_CONTAINER|MSGPACK_FLAG_ASSOC, + ucl_msgpack_parse_map + }, + { + 0xc7, + 8, + msgpack_ext8, + 1, + MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xc8, + 8, + msgpack_ext16, + 2, + MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xc9, + 8, + msgpack_ext32, + 4, + MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xd4, + 8, + msgpack_fixext1, + 1, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xd5, + 8, + msgpack_fixext2, + 2, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xd6, + 8, + msgpack_fixext4, + 4, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xd7, + 8, + msgpack_fixext8, + 8, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + }, + { + 0xd8, + 8, + msgpack_fixext16, + 16, + MSGPACK_FLAG_FIXED | MSGPACK_FLAG_EXT, + ucl_msgpack_parse_ignore + } +}; + +#undef MSGPACK_DEBUG_PARSER + +static inline struct ucl_msgpack_parser * +ucl_msgpack_get_parser_from_type (unsigned char t) +{ + unsigned int i, shift, mask; + + for (i = 0; i < sizeof (parsers) / sizeof (parsers[0]); i ++) { + shift = CHAR_BIT - parsers[i].prefixlen; + mask = parsers[i].prefix >> shift; + + if (mask == (t >> shift)) { + return &parsers[i]; + } + } + + return NULL; +} + +static inline struct ucl_stack * +ucl_msgpack_get_container (struct ucl_parser *parser, + struct ucl_msgpack_parser *obj_parser, uint64_t len) +{ + struct ucl_stack *stack; + + assert (obj_parser != NULL); + + if (obj_parser->flags & MSGPACK_FLAG_CONTAINER) { + assert ((len & MSGPACK_CONTAINER_BIT) == 0); + /* + * Insert new container to the stack + */ + if (parser->stack == NULL) { + parser->stack = calloc (1, sizeof (struct ucl_stack)); + + if (parser->stack == NULL) { + ucl_create_err (&parser->err, "no memory"); + return NULL; + } + } + else { + stack = calloc (1, sizeof (struct ucl_stack)); + + if (stack == NULL) { + ucl_create_err (&parser->err, "no memory"); + return NULL; + } + + stack->next = parser->stack; + parser->stack = stack; + } + + parser->stack->level = len | MSGPACK_CONTAINER_BIT; + +#ifdef MSGPACK_DEBUG_PARSER + stack = parser->stack; + while (stack) { + fprintf(stderr, "+"); + stack = stack->next; + } + + fprintf(stderr, "%s -> %d\n", obj_parser->flags & MSGPACK_FLAG_ASSOC ? "object" : "array", (int)len); +#endif + } + else { + /* + * Get the current stack top + */ + if (parser->stack) { + return parser->stack; + } + else { + ucl_create_err (&parser->err, "bad top level object for msgpack"); + return NULL; + } + } + + return parser->stack; +} + +static bool +ucl_msgpack_is_container_finished (struct ucl_stack *container) +{ + uint64_t level; + + assert (container != NULL); + + if (container->level & MSGPACK_CONTAINER_BIT) { + level = container->level & ~MSGPACK_CONTAINER_BIT; + + if (level == 0) { + return true; + } + } + + return false; +} + +static bool +ucl_msgpack_insert_object (struct ucl_parser *parser, + const unsigned char *key, + size_t keylen, ucl_object_t *obj) +{ + uint64_t level; + struct ucl_stack *container; + + container = parser->stack; + assert (container != NULL); + assert (container->level > 0); + assert (obj != NULL); + assert (container->obj != NULL); + + if (container->obj->type == UCL_ARRAY) { + ucl_array_append (container->obj, obj); + } + else if (container->obj->type == UCL_OBJECT) { + if (key == NULL || keylen == 0) { + ucl_create_err (&parser->err, "cannot insert object with no key"); + return false; + } + + obj->key = key; + obj->keylen = keylen; + + if (!(parser->flags & UCL_PARSER_ZEROCOPY)) { + ucl_copy_key_trash (obj); + } + + ucl_parser_process_object_element (parser, obj); + } + else { + ucl_create_err (&parser->err, "bad container type"); + return false; + } + + if (container->level & MSGPACK_CONTAINER_BIT) { + level = container->level & ~MSGPACK_CONTAINER_BIT; + container->level = (level - 1) | MSGPACK_CONTAINER_BIT; + } + + return true; +} + +static struct ucl_stack * +ucl_msgpack_get_next_container (struct ucl_parser *parser) +{ + struct ucl_stack *cur = NULL; + uint64_t level; + + cur = parser->stack; + + if (cur == NULL) { + return NULL; + } + + if (cur->level & MSGPACK_CONTAINER_BIT) { + level = cur->level & ~MSGPACK_CONTAINER_BIT; + + if (level == 0) { + /* We need to switch to the previous container */ + parser->stack = cur->next; + parser->cur_obj = cur->obj; + free (cur); + +#ifdef MSGPACK_DEBUG_PARSER + cur = parser->stack; + while (cur) { + fprintf(stderr, "-"); + cur = cur->next; + } + fprintf(stderr, "-%s -> %d\n", parser->cur_obj->type == UCL_OBJECT ? "object" : "array", (int)parser->cur_obj->len); +#endif + + return ucl_msgpack_get_next_container (parser); + } + } + + /* + * For UCL containers we don't know length, so we just insert the whole + * message pack blob into the top level container + */ + + assert (cur->obj != NULL); + + return cur; +} + +#define CONSUME_RET do { \ + if (ret != -1) { \ + p += ret; \ + remain -= ret; \ + obj_parser = NULL; \ + assert (remain >= 0); \ + } \ + else { \ + ucl_create_err (&parser->err, \ + "cannot parse type %d of len %u", \ + (int)obj_parser->fmt, \ + (unsigned)len); \ + return false; \ + } \ +} while(0) + +#define GET_NEXT_STATE do { \ + container = ucl_msgpack_get_next_container (parser); \ + if (container == NULL) { \ + ucl_create_err (&parser->err, \ + "empty container"); \ + return false; \ + } \ + next_state = container->obj->type == UCL_OBJECT ? \ + read_assoc_key : read_array_value; \ +} while(0) + +static bool +ucl_msgpack_consume (struct ucl_parser *parser) +{ + const unsigned char *p, *end, *key = NULL; + struct ucl_stack *container; + enum e_msgpack_parser_state { + read_type, + start_assoc, + start_array, + read_assoc_key, + read_assoc_value, + finish_assoc_value, + read_array_value, + finish_array_value, + error_state + } state = read_type, next_state = error_state; + struct ucl_msgpack_parser *obj_parser; + uint64_t len; + ssize_t ret, remain, keylen = 0; +#ifdef MSGPACK_DEBUG_PARSER + uint64_t i; + enum e_msgpack_parser_state hist[256]; +#endif + + p = parser->chunks->begin; + remain = parser->chunks->remain; + end = p + remain; + + + while (p < end) { +#ifdef MSGPACK_DEBUG_PARSER + hist[i++ % 256] = state; +#endif + switch (state) { + case read_type: + obj_parser = ucl_msgpack_get_parser_from_type (*p); + + if (obj_parser == NULL) { + ucl_create_err (&parser->err, "unknown msgpack format: %x", + (unsigned int)*p); + + return false; + } + /* Now check length sanity */ + if (obj_parser->flags & MSGPACK_FLAG_FIXED) { + if (obj_parser->len == 0) { + /* We have an embedded size */ + len = *p & ~obj_parser->prefix; + } + else { + if (remain < obj_parser->len) { + ucl_create_err (&parser->err, "not enough data remain to " + "read object's length: %u remain, %u needed", + (unsigned)remain, obj_parser->len); + + return false; + } + + len = obj_parser->len; + } + + if (!(obj_parser->flags & MSGPACK_FLAG_TYPEVALUE)) { + /* We must pass value as the second byte */ + if (remain > 0) { + p ++; + remain --; + } + } + else { + /* Len is irrelevant now */ + len = 0; + } + } + else { + /* Length is not embedded */ + if (remain < obj_parser->len) { + ucl_create_err (&parser->err, "not enough data remain to " + "read object's length: %u remain, %u needed", + (unsigned)remain, obj_parser->len); + + return false; + } + + p ++; + remain --; + + switch (obj_parser->len) { + case 1: + len = *p; + break; + case 2: + len = FROM_BE16 (*(uint16_t *)p); + break; + case 4: + len = FROM_BE32 (*(uint32_t *)p); + break; + case 8: + len = FROM_BE64 (*(uint64_t *)p); + break; + default: + assert (0); + break; + } + + p += obj_parser->len; + remain -= obj_parser->len; + } + + if (obj_parser->flags & MSGPACK_FLAG_ASSOC) { + /* We have just read the new associative map */ + state = start_assoc; + } + else if (obj_parser->flags & MSGPACK_FLAG_CONTAINER){ + state = start_array; + } + else { + state = next_state; + } + + break; + case start_assoc: + parser->cur_obj = ucl_object_new_full (UCL_OBJECT, + parser->chunks->priority); + /* Insert to the previous level container */ + if (parser->stack && !ucl_msgpack_insert_object (parser, + key, keylen, parser->cur_obj)) { + return false; + } + /* Get new container */ + container = ucl_msgpack_get_container (parser, obj_parser, len); + + if (container == NULL) { + return false; + } + + ret = obj_parser->func (parser, container, len, obj_parser->fmt, + p, remain); + CONSUME_RET; + key = NULL; + keylen = 0; + + if (len > 0) { + state = read_type; + next_state = read_assoc_key; + } + else { + /* Empty object */ + state = finish_assoc_value; + } + break; + + case start_array: + parser->cur_obj = ucl_object_new_full (UCL_ARRAY, + parser->chunks->priority); + /* Insert to the previous level container */ + if (parser->stack && !ucl_msgpack_insert_object (parser, + key, keylen, parser->cur_obj)) { + return false; + } + /* Get new container */ + container = ucl_msgpack_get_container (parser, obj_parser, len); + + if (container == NULL) { + return false; + } + + ret = obj_parser->func (parser, container, len, obj_parser->fmt, + p, remain); + CONSUME_RET; + + if (len > 0) { + state = read_type; + next_state = read_array_value; + } + else { + /* Empty array */ + state = finish_array_value; + } + break; + + case read_array_value: + /* + * p is now at the value start, len now contains length read and + * obj_parser contains the corresponding specific parser + */ + container = parser->stack; + + if (container == NULL) { + return false; + } + + ret = obj_parser->func (parser, container, len, obj_parser->fmt, + p, remain); + CONSUME_RET; + + + /* Insert value to the container and check if we have finished array */ + if (!ucl_msgpack_insert_object (parser, NULL, 0, + parser->cur_obj)) { + return false; + } + + if (ucl_msgpack_is_container_finished (container)) { + state = finish_array_value; + } + else { + /* Read more elements */ + state = read_type; + next_state = read_array_value; + } + + break; + + case read_assoc_key: + /* + * Keys must have string type for ucl msgpack + */ + if (!(obj_parser->flags & MSGPACK_FLAG_KEY)) { + ucl_create_err (&parser->err, "bad type for key: %u, expected " + "string", (unsigned)obj_parser->fmt); + + return false; + } + + key = p; + keylen = len; + + if (keylen > remain || keylen == 0) { + ucl_create_err (&parser->err, "too long or empty key"); + return false; + } + + p += len; + remain -= len; + + state = read_type; + next_state = read_assoc_value; + break; + + case read_assoc_value: + /* + * p is now at the value start, len now contains length read and + * obj_parser contains the corresponding specific parser + */ + container = parser->stack; + + if (container == NULL) { + return false; + } + + ret = obj_parser->func (parser, container, len, obj_parser->fmt, + p, remain); + CONSUME_RET; + + assert (key != NULL && keylen > 0); + + if (!ucl_msgpack_insert_object (parser, key, keylen, + parser->cur_obj)) { + return false; + } + + key = NULL; + keylen = 0; + + if (ucl_msgpack_is_container_finished (container)) { + state = finish_assoc_value; + } + else { + /* Read more elements */ + state = read_type; + next_state = read_assoc_key; + } + break; + + case finish_array_value: + case finish_assoc_value: + GET_NEXT_STATE; + state = read_type; + break; + + case error_state: + ucl_create_err (&parser->err, "invalid state machine state"); + + return false; + } + } + + /* Check the finishing state */ + switch (state) { + case start_array: + case start_assoc: + /* Empty container at the end */ + if (len != 0) { + ucl_create_err (&parser->err, "invalid non-empty container at the end"); + + return false; + } + + parser->cur_obj = ucl_object_new_full ( + state == start_array ? UCL_ARRAY : UCL_OBJECT, + parser->chunks->priority); + /* Insert to the previous level container */ + if (!ucl_msgpack_insert_object (parser, + key, keylen, parser->cur_obj)) { + return false; + } + /* Get new container */ + container = ucl_msgpack_get_container (parser, obj_parser, len); + + if (container == NULL) { + return false; + } + + ret = obj_parser->func (parser, container, len, obj_parser->fmt, + p, remain); + break; + + case read_array_value: + case read_assoc_value: + if (len != 0) { + ucl_create_err (&parser->err, "unfinished value at the end"); + + return false; + } + + container = parser->stack; + + if (container == NULL) { + return false; + } + + ret = obj_parser->func (parser, container, len, obj_parser->fmt, + p, remain); + CONSUME_RET; + + + /* Insert value to the container and check if we have finished array */ + if (!ucl_msgpack_insert_object (parser, NULL, 0, + parser->cur_obj)) { + return false; + } + break; + case finish_array_value: + case finish_assoc_value: + case read_type: + /* Valid finishing state */ + break; + default: + /* Invalid finishing state */ + ucl_create_err (&parser->err, "invalid state machine finishing state: %d", + state); + + return false; + } + + /* Rewind to the top level container */ + ucl_msgpack_get_next_container (parser); + assert (parser->stack == NULL || + (parser->stack->level & MSGPACK_CONTAINER_BIT) == 0); + + return true; +} + +bool +ucl_parse_msgpack (struct ucl_parser *parser) +{ + ucl_object_t *container = NULL; + const unsigned char *p; + bool ret; + + assert (parser != NULL); + assert (parser->chunks != NULL); + assert (parser->chunks->begin != NULL); + assert (parser->chunks->remain != 0); + + p = parser->chunks->begin; + + if (parser->stack) { + container = parser->stack->obj; + } + + /* + * When we start parsing message pack chunk, we must ensure that we + * have either a valid container or the top object inside message pack is + * of container type + */ + if (container == NULL) { + if ((*p & 0x80) != 0x80 && !(*p >= 0xdc && *p <= 0xdf)) { + ucl_create_err (&parser->err, "bad top level object for msgpack"); + return false; + } + } + + ret = ucl_msgpack_consume (parser); + + if (ret && parser->top_obj == NULL) { + parser->top_obj = parser->cur_obj; + } + + return ret; +} + +static ssize_t +ucl_msgpack_parse_map (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + container->obj = parser->cur_obj; + + return 0; +} + +static ssize_t +ucl_msgpack_parse_array (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + container->obj = parser->cur_obj; + + return 0; +} + +static ssize_t +ucl_msgpack_parse_string (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + ucl_object_t *obj; + + if (len > remain) { + return -1; + } + + obj = ucl_object_new_full (UCL_STRING, parser->chunks->priority); + obj->value.sv = pos; + obj->len = len; + + if (fmt >= msgpack_bin8 && fmt <= msgpack_bin32) { + obj->flags |= UCL_OBJECT_BINARY; + } + + if (!(parser->flags & UCL_PARSER_ZEROCOPY)) { + if (obj->flags & UCL_OBJECT_BINARY) { + obj->trash_stack[UCL_TRASH_VALUE] = malloc (len); + + if (obj->trash_stack[UCL_TRASH_VALUE] != NULL) { + memcpy (obj->trash_stack[UCL_TRASH_VALUE], pos, len); + } + } + else { + ucl_copy_value_trash (obj); + } + } + + parser->cur_obj = obj; + + return len; +} + +static ssize_t +ucl_msgpack_parse_int (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + ucl_object_t *obj; + + if (len > remain) { + return -1; + } + + obj = ucl_object_new_full (UCL_INT, parser->chunks->priority); + + switch (fmt) { + case msgpack_positive_fixint: + obj->value.iv = (*pos & 0x7f); + len = 1; + break; + case msgpack_negative_fixint: + obj->value.iv = - (*pos & 0x1f); + len = 1; + break; + case msgpack_uint8: + obj->value.iv = (unsigned char)*pos; + len = 1; + break; + case msgpack_int8: + obj->value.iv = (signed char)*pos; + len = 1; + break; + case msgpack_int16: + obj->value.iv = FROM_BE16 (*(int16_t *)pos); + len = 2; + break; + case msgpack_uint16: + obj->value.iv = FROM_BE16 (*(uint16_t *)pos); + len = 2; + break; + case msgpack_int32: + obj->value.iv = FROM_BE32 (*(int32_t *)pos); + len = 4; + break; + case msgpack_uint32: + obj->value.iv = FROM_BE32 (*(uint32_t *)pos); + len = 4; + break; + case msgpack_int64: + obj->value.iv = FROM_BE64 (*(int64_t *)pos); + len = 8; + break; + case msgpack_uint64: + obj->value.iv = FROM_BE64 (*(uint64_t *)pos); + len = 8; + break; + default: + assert (0); + break; + } + + parser->cur_obj = obj; + + return len; +} + +static ssize_t +ucl_msgpack_parse_float (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + ucl_object_t *obj; + union { + uint32_t i; + float f; + } d; + + if (len > remain) { + return -1; + } + + obj = ucl_object_new_full (UCL_FLOAT, parser->chunks->priority); + + switch (fmt) { + case msgpack_float32: + d.i = FROM_BE32 (*(uint32_t *)pos); + /* XXX: can be slow */ + obj->value.dv = d.f; + len = 4; + break; + case msgpack_float64: + obj->value.iv = FROM_BE64 (*(uint64_t *)pos); + len = 8; + break; + default: + assert (0); + break; + } + + parser->cur_obj = obj; + + return len; +} + +static ssize_t +ucl_msgpack_parse_bool (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + ucl_object_t *obj; + + if (len > remain) { + return -1; + } + + obj = ucl_object_new_full (UCL_BOOLEAN, parser->chunks->priority); + + switch (fmt) { + case msgpack_true: + obj->value.iv = true; + break; + case msgpack_false: + obj->value.iv = false; + break; + default: + assert (0); + break; + } + + parser->cur_obj = obj; + + return 1; +} + +static ssize_t +ucl_msgpack_parse_null (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + ucl_object_t *obj; + + if (len > remain) { + return -1; + } + + obj = ucl_object_new_full (UCL_NULL, parser->chunks->priority); + parser->cur_obj = obj; + + return 1; +} + +static ssize_t +ucl_msgpack_parse_ignore (struct ucl_parser *parser, + struct ucl_stack *container, size_t len, enum ucl_msgpack_format fmt, + const unsigned char *pos, size_t remain) +{ + if (len > remain) { + return -1; + } + + switch (fmt) { + case msgpack_fixext1: + len = 2; + break; + case msgpack_fixext2: + len = 3; + break; + case msgpack_fixext4: + len = 5; + break; + case msgpack_fixext8: + len = 9; + break; + case msgpack_fixext16: + len = 17; + break; + case msgpack_ext8: + case msgpack_ext16: + case msgpack_ext32: + len = len + 1; + break; + default: + ucl_create_err (&parser->err, "bad type: %x", (unsigned)fmt); + return -1; + } + + return len; +} diff --git a/contrib/libucl/src/ucl_parser.c b/contrib/libucl/src/ucl_parser.c index 75acba8ecbd3..9bd41391ba36 100644 --- a/contrib/libucl/src/ucl_parser.c +++ b/contrib/libucl/src/ucl_parser.c @@ -67,6 +67,7 @@ ucl_set_err (struct ucl_parser *parser, int code, const char *str, UT_string **e else { filename = ""; } + if (chunk->pos < chunk->end) { if (isgraph (*chunk->pos)) { fmt_string = "error while parsing %s: " @@ -84,6 +85,8 @@ ucl_set_err (struct ucl_parser *parser, int code, const char *str, UT_string **e ucl_create_err (err, "error while parsing %s: at the end of chunk: %s", filename, str); } + + parser->err_code = code; } /** @@ -513,7 +516,7 @@ ucl_copy_or_store_ptr (struct ucl_parser *parser, /* Copy string */ *dst = UCL_ALLOC (in_len + 1); if (*dst == NULL) { - ucl_set_err (parser, 0, "cannot allocate memory for a string", + ucl_set_err (parser, UCL_EINTERNAL, "cannot allocate memory for a string", &parser->err); return false; } @@ -559,7 +562,8 @@ ucl_copy_or_store_ptr (struct ucl_parser *parser, * @return */ static inline ucl_object_t * -ucl_add_parser_stack (ucl_object_t *obj, struct ucl_parser *parser, bool is_array, int level) +ucl_parser_add_container (ucl_object_t *obj, struct ucl_parser *parser, + bool is_array, int level) { struct ucl_stack *st; @@ -570,7 +574,9 @@ ucl_add_parser_stack (ucl_object_t *obj, struct ucl_parser *parser, bool is_arra else { obj->type = UCL_OBJECT; } - obj->value.ov = ucl_hash_create (parser->flags & UCL_PARSER_KEY_LOWERCASE); + if (obj->value.ov == NULL) { + obj->value.ov = ucl_hash_create (parser->flags & UCL_PARSER_KEY_LOWERCASE); + } parser->state = UCL_STATE_KEY; } else { @@ -585,7 +591,7 @@ ucl_add_parser_stack (ucl_object_t *obj, struct ucl_parser *parser, bool is_arra st = UCL_ALLOC (sizeof (struct ucl_stack)); if (st == NULL) { - ucl_set_err (parser, 0, "cannot allocate memory for an object", + ucl_set_err (parser, UCL_EINTERNAL, "cannot allocate memory for an object", &parser->err); ucl_object_unref (obj); return NULL; @@ -834,19 +840,21 @@ ucl_maybe_parse_number (ucl_object_t *obj, *pos = c; return EINVAL; - set_obj: - if (allow_double && (need_double || is_time)) { - if (!is_time) { - obj->type = UCL_FLOAT; +set_obj: + if (obj != NULL) { + if (allow_double && (need_double || is_time)) { + if (!is_time) { + obj->type = UCL_FLOAT; + } + else { + obj->type = UCL_TIME; + } + obj->value.dv = is_neg ? (-dv) : dv; } else { - obj->type = UCL_TIME; + obj->type = UCL_INT; + obj->value.iv = is_neg ? (-lv) : lv; } - obj->value.dv = is_neg ? (-dv) : dv; - } - else { - obj->type = UCL_INT; - obj->value.iv = is_neg ? (-lv) : lv; } *pos = p; return 0; @@ -856,6 +864,7 @@ ucl_maybe_parse_number (ucl_object_t *obj, * Parse possible number * @param parser * @param chunk + * @param obj * @return true if a number has been parsed */ static bool @@ -875,7 +884,8 @@ ucl_lex_number (struct ucl_parser *parser, return true; } else if (ret == ERANGE) { - ucl_set_err (parser, ERANGE, "numeric value out of range", &parser->err); + ucl_set_err (parser, UCL_ESYNTAX, "numeric value out of range", + &parser->err); } return false; @@ -885,6 +895,9 @@ ucl_lex_number (struct ucl_parser *parser, * Parse quoted string with possible escapes * @param parser * @param chunk + * @param need_unescape + * @param ucl_escape + * @param var_expand * @return true if a string has been parsed */ static bool @@ -971,6 +984,7 @@ ucl_parser_append_elt (struct ucl_parser *parser, ucl_hash_t *cont, /* Implicit array */ top->flags |= UCL_OBJECT_MULTIVALUE; DL_APPEND (top, elt); + parser->stack->obj->len ++; } else { if ((top->flags & UCL_OBJECT_MULTIVALUE) != 0) { @@ -979,34 +993,127 @@ ucl_parser_append_elt (struct ucl_parser *parser, ucl_hash_t *cont, } else { /* Convert to an array */ - ucl_hash_delete (cont, top); nobj = ucl_object_typed_new (UCL_ARRAY); nobj->key = top->key; nobj->keylen = top->keylen; nobj->flags |= UCL_OBJECT_MULTIVALUE; ucl_array_append (nobj, top); ucl_array_append (nobj, elt); - ucl_hash_insert (cont, nobj, nobj->key, nobj->keylen); + ucl_hash_replace (cont, top, nobj); } } } +bool +ucl_parser_process_object_element (struct ucl_parser *parser, ucl_object_t *nobj) +{ + ucl_hash_t *container; + ucl_object_t *tobj; + + container = parser->stack->obj->value.ov; + + tobj = __DECONST (ucl_object_t *, ucl_hash_search_obj (container, nobj)); + if (tobj == NULL) { + container = ucl_hash_insert_object (container, nobj, + parser->flags & UCL_PARSER_KEY_LOWERCASE); + nobj->prev = nobj; + nobj->next = NULL; + parser->stack->obj->len ++; + } + else { + unsigned priold = ucl_object_get_priority (tobj), + prinew = ucl_object_get_priority (nobj); + switch (parser->chunks->strategy) { + + case UCL_DUPLICATE_APPEND: + /* + * The logic here is the following: + * + * - if we have two objects with the same priority, then we form an + * implicit or explicit array + * - if a new object has bigger priority, then we overwrite an old one + * - if a new object has lower priority, then we ignore it + */ + + + /* Special case for inherited objects */ + if (tobj->flags & UCL_OBJECT_INHERITED) { + prinew = priold + 1; + } + + if (priold == prinew) { + ucl_parser_append_elt (parser, container, tobj, nobj); + } + else if (priold > prinew) { + /* + * We add this new object to a list of trash objects just to ensure + * that it won't come to any real object + * XXX: rather inefficient approach + */ + DL_APPEND (parser->trash_objs, nobj); + } + else { + ucl_hash_replace (container, tobj, nobj); + ucl_object_unref (tobj); + } + + break; + + case UCL_DUPLICATE_REWRITE: + /* We just rewrite old values regardless of priority */ + ucl_hash_replace (container, tobj, nobj); + ucl_object_unref (tobj); + + break; + + case UCL_DUPLICATE_ERROR: + ucl_create_err (&parser->err, "error while parsing %s: " + "line: %d, column: %d: duplicate element for key '%s' " + "has been found", + parser->cur_file ? parser->cur_file : "", + parser->chunks->line, parser->chunks->column, nobj->key); + return false; + + case UCL_DUPLICATE_MERGE: + /* + * Here we do have some old object so we just push it on top of objects stack + */ + if (tobj->type == UCL_OBJECT || tobj->type == UCL_ARRAY) { + ucl_object_unref (nobj); + nobj = tobj; + } + else { + /* For other types we create implicit array as usual */ + ucl_parser_append_elt (parser, container, tobj, nobj); + } + break; + } + } + + parser->stack->obj->value.ov = container; + parser->cur_obj = nobj; + + return true; +} + /** * Parse a key in an object * @param parser * @param chunk + * @param next_key + * @param end_of_object * @return true if a key has been parsed */ static bool -ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_key, bool *end_of_object) +ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, + bool *next_key, bool *end_of_object) { const unsigned char *p, *c = NULL, *end, *t; const char *key = NULL; bool got_quote = false, got_eq = false, got_semicolon = false, need_unescape = false, ucl_escape = false, var_expand = false, got_content = false, got_sep = false; - ucl_object_t *nobj, *tobj; - ucl_hash_t *container; + ucl_object_t *nobj; ssize_t keylen; p = chunk->pos; @@ -1191,47 +1298,17 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke return false; } - container = parser->stack->obj->value.ov; nobj->key = key; nobj->keylen = keylen; - tobj = __DECONST (ucl_object_t *, ucl_hash_search_obj (container, nobj)); - if (tobj == NULL) { - container = ucl_hash_insert_object (container, nobj, - parser->flags & UCL_PARSER_KEY_LOWERCASE); - nobj->prev = nobj; - nobj->next = NULL; - parser->stack->obj->len ++; - } - else { - /* - * The logic here is the following: - * - * - if we have two objects with the same priority, then we form an - * implicit or explicit array - * - if a new object has bigger priority, then we overwrite an old one - * - if a new object has lower priority, then we ignore it - */ - unsigned priold = ucl_object_get_priority (tobj), - prinew = ucl_object_get_priority (nobj); - if (priold == prinew) { - ucl_parser_append_elt (parser, container, tobj, nobj); - } - else if (priold > prinew) { - ucl_object_unref (nobj); - return true; - } - else { - ucl_hash_replace (container, tobj, nobj); - ucl_object_unref (tobj); - } + + if (!ucl_parser_process_object_element (parser, nobj)) { + return false; } if (ucl_escape) { nobj->flags |= UCL_OBJECT_NEED_KEY_ESCAPE; } - parser->stack->obj->value.ov = container; - parser->cur_obj = nobj; return true; } @@ -1240,6 +1317,8 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, bool *next_ke * Parse a cl string * @param parser * @param chunk + * @param var_expand + * @param need_unescape * @return true if a key has been parsed */ static bool @@ -1309,6 +1388,8 @@ ucl_parse_string_value (struct ucl_parser *parser, * @param chunk * @param term * @param term_len + * @param beg + * @param var_expand * @return size of multiline string or 0 in case of error */ static int @@ -1360,8 +1441,8 @@ ucl_parse_multiline_string (struct ucl_parser *parser, return len; } -static ucl_object_t* -ucl_get_value_object (struct ucl_parser *parser) +static inline ucl_object_t* +ucl_parser_get_container (struct ucl_parser *parser) { ucl_object_t *t, *obj = NULL; @@ -1373,7 +1454,12 @@ ucl_get_value_object (struct ucl_parser *parser) /* Object must be allocated */ obj = ucl_object_new_full (UCL_NULL, parser->chunks->priority); t = parser->stack->obj; - ucl_array_append (t, obj); + + if (!ucl_array_append (t, obj)) { + ucl_object_unref (obj); + return NULL; + } + parser->cur_obj = obj; } else { @@ -1417,42 +1503,51 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) c = p; switch (*p) { case '"': - obj = ucl_get_value_object (parser); ucl_chunk_skipc (chunk, p); - if (!ucl_lex_json_string (parser, chunk, &need_unescape, &ucl_escape, &var_expand)) { + + if (!ucl_lex_json_string (parser, chunk, &need_unescape, &ucl_escape, + &var_expand)) { return false; } + + obj = ucl_parser_get_container (parser); str_len = chunk->pos - c - 2; obj->type = UCL_STRING; - if ((str_len = ucl_copy_or_store_ptr (parser, c + 1, &obj->trash_stack[UCL_TRASH_VALUE], - &obj->value.sv, str_len, need_unescape, false, var_expand)) == -1) { + if ((str_len = ucl_copy_or_store_ptr (parser, c + 1, + &obj->trash_stack[UCL_TRASH_VALUE], + &obj->value.sv, str_len, need_unescape, false, + var_expand)) == -1) { return false; } obj->len = str_len; + parser->state = UCL_STATE_AFTER_VALUE; p = chunk->pos; + return true; break; case '{': - obj = ucl_get_value_object (parser); + obj = ucl_parser_get_container (parser); /* We have a new object */ - obj = ucl_add_parser_stack (obj, parser, false, parser->stack->level); + obj = ucl_parser_add_container (obj, parser, false, parser->stack->level); if (obj == NULL) { return false; } ucl_chunk_skipc (chunk, p); + return true; break; case '[': - obj = ucl_get_value_object (parser); + obj = ucl_parser_get_container (parser); /* We have a new array */ - obj = ucl_add_parser_stack (obj, parser, true, parser->stack->level); + obj = ucl_parser_add_container (obj, parser, true, parser->stack->level); if (obj == NULL) { return false; } ucl_chunk_skipc (chunk, p); + return true; break; case ']': @@ -1466,7 +1561,7 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) } break; case '<': - obj = ucl_get_value_object (parser); + obj = ucl_parser_get_container (parser); /* We have something like multiline value, which must be <<[A-Z]+\n */ if (chunk->end - p > 3) { if (memcmp (p, "<<", 2) == 0) { @@ -1488,13 +1583,19 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) "unterminated multiline value", &parser->err); return false; } + obj->type = UCL_STRING; - if ((str_len = ucl_copy_or_store_ptr (parser, c, &obj->trash_stack[UCL_TRASH_VALUE], - &obj->value.sv, str_len - 1, false, false, var_expand)) == -1) { + obj->flags |= UCL_OBJECT_MULTILINE; + if ((str_len = ucl_copy_or_store_ptr (parser, c, + &obj->trash_stack[UCL_TRASH_VALUE], + &obj->value.sv, str_len - 1, false, + false, var_expand)) == -1) { return false; } obj->len = str_len; + parser->state = UCL_STATE_AFTER_VALUE; + return true; } } @@ -1503,8 +1604,9 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) default: parse_string: if (obj == NULL) { - obj = ucl_get_value_object (parser); + obj = ucl_parser_get_container (parser); } + /* Parse atom */ if (ucl_test_character (*p, UCL_CHARACTER_VALUE_DIGIT_START)) { if (!ucl_lex_number (parser, chunk, obj)) { @@ -1519,7 +1621,8 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) /* Fallback to normal string */ } - if (!ucl_parse_string_value (parser, chunk, &var_expand, &need_unescape)) { + if (!ucl_parse_string_value (parser, chunk, &var_expand, + &need_unescape)) { return false; } /* Cut trailing spaces */ @@ -1530,7 +1633,7 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) } str_len = chunk->pos - c - stripped_spaces; if (str_len <= 0) { - ucl_set_err (parser, 0, "string value must not be empty", + ucl_set_err (parser, UCL_ESYNTAX, "string value must not be empty", &parser->err); return false; } @@ -1540,7 +1643,8 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) } else if (!ucl_maybe_parse_boolean (obj, c, str_len)) { obj->type = UCL_STRING; - if ((str_len = ucl_copy_or_store_ptr (parser, c, &obj->trash_stack[UCL_TRASH_VALUE], + if ((str_len = ucl_copy_or_store_ptr (parser, c, + &obj->trash_stack[UCL_TRASH_VALUE], &obj->value.sv, str_len, need_unescape, false, var_expand)) == -1) { return false; @@ -1652,6 +1756,9 @@ ucl_parse_after_value (struct ucl_parser *parser, struct ucl_chunk *chunk) * Handle macro data * @param parser * @param chunk + * @param marco + * @param macro_start + * @param macro_len * @return */ static bool @@ -1790,6 +1897,7 @@ ucl_parse_macro_arguments (struct ucl_parser *parser, if (chunk->remain == 0) { goto restore_chunk; } + args_len ++; ucl_chunk_skipc (chunk, p); break; case 99: @@ -1842,8 +1950,6 @@ ucl_parse_macro_arguments (struct ucl_parser *parser, /** * Handle the main states of rcl parser * @param parser parser structure - * @param data the pointer to the beginning of a chunk - * @param len the length of a chunk * @return true if chunk has been parsed and false in case of error */ static bool @@ -1858,17 +1964,6 @@ ucl_state_machine (struct ucl_parser *parser) bool next_key = false, end_of_object = false, ret; if (parser->top_obj == NULL) { - if (*chunk->pos == '[') { - obj = ucl_add_parser_stack (NULL, parser, true, 0); - } - else { - obj = ucl_add_parser_stack (NULL, parser, false, 0); - } - if (obj == NULL) { - return false; - } - parser->top_obj = obj; - parser->cur_obj = obj; parser->state = UCL_STATE_INIT; } @@ -1892,7 +1987,9 @@ ucl_state_machine (struct ucl_parser *parser) UCL_CHARACTER_WHITESPACE_UNSAFE)) { ucl_chunk_skipc (chunk, p); } + p = chunk->pos; + if (*p == '[') { parser->state = UCL_STATE_VALUE; ucl_chunk_skipc (chunk, p); @@ -1903,6 +2000,23 @@ ucl_state_machine (struct ucl_parser *parser) ucl_chunk_skipc (chunk, p); } } + + if (parser->top_obj == NULL) { + if (parser->state == UCL_STATE_VALUE) { + obj = ucl_parser_add_container (NULL, parser, true, 0); + } + else { + obj = ucl_parser_add_container (NULL, parser, false, 0); + } + + if (obj == NULL) { + return false; + } + + parser->top_obj = obj; + parser->cur_obj = obj; + } + } break; case UCL_STATE_KEY: @@ -1936,7 +2050,7 @@ ucl_state_machine (struct ucl_parser *parser) else if (parser->state != UCL_STATE_MACRO_NAME) { if (next_key && parser->stack->obj->type == UCL_OBJECT) { /* Parse more keys and nest objects accordingly */ - obj = ucl_add_parser_stack (parser->cur_obj, parser, false, + obj = ucl_parser_add_container (parser->cur_obj, parser, false, parser->stack->level + 1); if (obj == NULL) { return false; @@ -1967,6 +2081,7 @@ ucl_state_machine (struct ucl_parser *parser) parser->state = UCL_STATE_ERROR; return false; } + if (parser->stack != NULL) { if (parser->stack->obj->type == UCL_OBJECT) { parser->state = UCL_STATE_KEY; @@ -1987,20 +2102,36 @@ ucl_state_machine (struct ucl_parser *parser) *p != '(') { ucl_chunk_skipc (chunk, p); } - else if (p - c > 0) { - /* We got macro name */ - macro_len = (size_t)(p - c); - HASH_FIND (hh, parser->macroes, c, macro_len, macro); - if (macro == NULL) { - ucl_create_err (&parser->err, "error on line %d at column %d: " - "unknown macro: '%.*s', character: '%c'", - chunk->line, chunk->column, (int)(p - c), c, *chunk->pos); + else { + if (p - c > 0) { + /* We got macro name */ + macro_len = (size_t) (p - c); + HASH_FIND (hh, parser->macroes, c, macro_len, macro); + if (macro == NULL) { + ucl_create_err (&parser->err, + "error on line %d at column %d: " + "unknown macro: '%.*s', character: '%c'", + chunk->line, + chunk->column, + (int) (p - c), + c, + *chunk->pos); + parser->state = UCL_STATE_ERROR; + return false; + } + /* Now we need to skip all spaces */ + SKIP_SPACES_COMMENTS(parser, chunk, p); + parser->state = UCL_STATE_MACRO; + } + else { + /* We have invalid macro name */ + ucl_create_err (&parser->err, + "error on line %d at column %d: invalid macro name", + chunk->line, + chunk->column); parser->state = UCL_STATE_ERROR; return false; } - /* Now we need to skip all spaces */ - SKIP_SPACES_COMMENTS(parser, chunk, p); - parser->state = UCL_STATE_MACRO; } break; case UCL_STATE_MACRO: @@ -2024,14 +2155,36 @@ ucl_state_machine (struct ucl_parser *parser) macro_start, macro_len); parser->state = parser->prev_state; if (macro_escaped == NULL) { - ret = macro->handler (macro_start, macro_len, macro_args, - macro->ud); + if (macro->is_context) { + ret = macro->h.context_handler (macro_start, macro_len, + macro_args, + parser->top_obj, + macro->ud); + } + else { + ret = macro->h.handler (macro_start, macro_len, macro_args, + macro->ud); + } } else { - ret = macro->handler (macro_escaped, macro_len, macro_args, + if (macro->is_context) { + ret = macro->h.context_handler (macro_escaped, macro_len, + macro_args, + parser->top_obj, + macro->ud); + } + else { + ret = macro->h.handler (macro_escaped, macro_len, macro_args, macro->ud); + } + UCL_FREE (macro_len + 1, macro_escaped); } + + /* + * Chunk can be modified within macro handler + */ + chunk = parser->chunks; p = chunk->pos; if (macro_args) { ucl_object_unref (macro_args); @@ -2061,13 +2214,18 @@ ucl_parser_new (int flags) if (new == NULL) { return NULL; } + memset (new, 0, sizeof (struct ucl_parser)); ucl_parser_register_macro (new, "include", ucl_include_handler, new); ucl_parser_register_macro (new, "try_include", ucl_try_include_handler, new); ucl_parser_register_macro (new, "includes", ucl_includes_handler, new); + ucl_parser_register_macro (new, "priority", ucl_priority_handler, new); + ucl_parser_register_macro (new, "load", ucl_load_handler, new); + ucl_parser_register_context_macro (new, "inherit", ucl_inherit_handler, new); new->flags = flags; + new->includepaths = NULL; /* Initial assumption about filevars */ ucl_parser_set_filevars (new, NULL, false); @@ -2075,6 +2233,17 @@ ucl_parser_new (int flags) return new; } +bool +ucl_parser_set_default_priority (struct ucl_parser *parser, unsigned prio) +{ + if (parser == NULL) { + return false; + } + + parser->default_priority = prio; + + return true; +} void ucl_parser_register_macro (struct ucl_parser *parser, const char *macro, @@ -2085,17 +2254,42 @@ ucl_parser_register_macro (struct ucl_parser *parser, const char *macro, if (macro == NULL || handler == NULL) { return; } + new = UCL_ALLOC (sizeof (struct ucl_macro)); if (new == NULL) { return; } + memset (new, 0, sizeof (struct ucl_macro)); - new->handler = handler; + new->h.handler = handler; new->name = strdup (macro); new->ud = ud; HASH_ADD_KEYPTR (hh, parser->macroes, new->name, strlen (new->name), new); } +void +ucl_parser_register_context_macro (struct ucl_parser *parser, const char *macro, + ucl_context_macro_handler handler, void* ud) +{ + struct ucl_macro *new; + + if (macro == NULL || handler == NULL) { + return; + } + + new = UCL_ALLOC (sizeof (struct ucl_macro)); + if (new == NULL) { + return; + } + + memset (new, 0, sizeof (struct ucl_macro)); + new->h.context_handler = handler; + new->name = strdup (macro); + new->ud = ud; + new->is_context = true; + HASH_ADD_KEYPTR (hh, parser->macroes, new->name, strlen (new->name), new); +} + void ucl_parser_register_variable (struct ucl_parser *parser, const char *var, const char *value) @@ -2159,11 +2353,16 @@ ucl_parser_set_variables_handler (struct ucl_parser *parser, } bool -ucl_parser_add_chunk_priority (struct ucl_parser *parser, const unsigned char *data, - size_t len, unsigned priority) +ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data, + size_t len, unsigned priority, enum ucl_duplicate_strategy strat, + enum ucl_parse_type parse_type) { struct ucl_chunk *chunk; + if (parser == NULL) { + return false; + } + if (data == NULL) { ucl_create_err (&parser->err, "invalid chunk added"); return false; @@ -2185,14 +2384,24 @@ ucl_parser_add_chunk_priority (struct ucl_parser *parser, const unsigned char *d chunk->line = 1; chunk->column = 0; chunk->priority = priority; + chunk->strategy = strat; + chunk->parse_type = parse_type; LL_PREPEND (parser->chunks, chunk); parser->recursion ++; + if (parser->recursion > UCL_MAX_RECURSION) { ucl_create_err (&parser->err, "maximum include nesting limit is reached: %d", parser->recursion); return false; } - return ucl_state_machine (parser); + + switch (parse_type) { + default: + case UCL_PARSE_UCL: + return ucl_state_machine (parser); + case UCL_PARSE_MSGPACK: + return ucl_parse_msgpack (parser); + } } ucl_create_err (&parser->err, "a parser is in an invalid state"); @@ -2201,15 +2410,33 @@ ucl_parser_add_chunk_priority (struct ucl_parser *parser, const unsigned char *d } bool -ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, - size_t len) +ucl_parser_add_chunk_priority (struct ucl_parser *parser, + const unsigned char *data, size_t len, unsigned priority) { - return ucl_parser_add_chunk_priority (parser, data, len, 0); + /* We dereference parser, so this check is essential */ + if (parser == NULL) { + return false; + } + + return ucl_parser_add_chunk_full (parser, data, len, + priority, UCL_DUPLICATE_APPEND, UCL_PARSE_UCL); } bool -ucl_parser_add_string (struct ucl_parser *parser, const char *data, +ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, size_t len) +{ + if (parser == NULL) { + return false; + } + + return ucl_parser_add_chunk_full (parser, data, len, + parser->default_priority, UCL_DUPLICATE_APPEND, UCL_PARSE_UCL); +} + +bool +ucl_parser_add_string_priority (struct ucl_parser *parser, const char *data, + size_t len, unsigned priority) { if (data == NULL) { ucl_create_err (&parser->err, "invalid string added"); @@ -2219,5 +2446,40 @@ ucl_parser_add_string (struct ucl_parser *parser, const char *data, len = strlen (data); } - return ucl_parser_add_chunk (parser, (const unsigned char *)data, len); + return ucl_parser_add_chunk_priority (parser, + (const unsigned char *)data, len, priority); +} + +bool +ucl_parser_add_string (struct ucl_parser *parser, const char *data, + size_t len) +{ + if (parser == NULL) { + return false; + } + + return ucl_parser_add_string_priority (parser, + (const unsigned char *)data, len, parser->default_priority); +} + +bool +ucl_set_include_path (struct ucl_parser *parser, ucl_object_t *paths) +{ + if (parser == NULL || paths == NULL) { + return false; + } + + if (parser->includepaths == NULL) { + parser->includepaths = ucl_object_copy (paths); + } + else { + ucl_object_unref (parser->includepaths); + parser->includepaths = ucl_object_copy (paths); + } + + if (parser->includepaths == NULL) { + return false; + } + + return true; } diff --git a/contrib/libucl/src/ucl_sexp.c b/contrib/libucl/src/ucl_sexp.c new file mode 100644 index 000000000000..3ca7eb102925 --- /dev/null +++ b/contrib/libucl/src/ucl_sexp.c @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2015, Vsevolod Stakhov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "ucl.h" +#include "ucl_internal.h" +#include "utlist.h" + +#define NEXT_STATE do { \ +if (p >= end) { \ + if (state != read_ebrace) { \ + ucl_create_err (&parser->err,\ + "extra data");\ + state = parse_err; \ + } \ +} \ +else { \ +switch (*p) { \ + case '(': \ + state = read_obrace; \ + break; \ + case ')': \ + state = read_ebrace; \ + break; \ + default: \ + len = 0; \ + mult = 1; \ + state = read_length; \ + break; \ + } \ +} \ +} while(0) + +bool +ucl_parse_csexp (struct ucl_parser *parser) +{ + const unsigned char *p, *end; + ucl_object_t *obj; + struct ucl_stack *st; + uint64_t len = 0, mult = 1; + enum { + start_parse, + read_obrace, + read_length, + read_value, + read_ebrace, + parse_err + } state = start_parse; + + assert (parser != NULL); + assert (parser->chunks != NULL); + assert (parser->chunks->begin != NULL); + assert (parser->chunks->remain != 0); + + p = parser->chunks->begin; + end = p + parser->chunks->remain; + + while (p < end) { + switch (state) { + case start_parse: + /* At this point we expect open brace */ + if (*p == '(') { + state = read_obrace; + } + else { + ucl_create_err (&parser->err, "bad starting character for " + "sexp block: %x", (int)*p); + state = parse_err; + } + break; + + case read_obrace: + st = calloc (1, sizeof (*st)); + + if (st == NULL) { + ucl_create_err (&parser->err, "no memory"); + state = parse_err; + continue; + } + + st->obj = ucl_object_typed_new (UCL_ARRAY); + + if (st->obj == NULL) { + ucl_create_err (&parser->err, "no memory"); + state = parse_err; + continue; + } + + if (parser->stack == NULL) { + /* We have no stack */ + parser->stack = st; + + if (parser->top_obj == NULL) { + parser->top_obj = st->obj; + } + } + else { + /* Prepend new element to the stack */ + LL_PREPEND (parser->stack, st); + } + + p ++; + NEXT_STATE; + + break; + + case read_length: + if (*p == ':') { + if (len == 0) { + ucl_create_err (&parser->err, "zero length element"); + state = parse_err; + continue; + } + + state = read_value; + } + else if (*p >= '0' && *p <= '9') { + len += (*p - '0') * mult; + mult *= 10; + + if (len > UINT32_MAX) { + ucl_create_err (&parser->err, "too big length of an " + "element"); + state = parse_err; + continue; + } + } + else { + ucl_create_err (&parser->err, "bad length character: %x", + (int)*p); + state = parse_err; + continue; + } + + p ++; + break; + + case read_value: + if ((uint64_t)(end - p) > len || len == 0) { + ucl_create_err (&parser->err, "invalid length: %llu, %ld " + "remain", (long long unsigned)len, (long)(end - p)); + state = parse_err; + continue; + } + obj = ucl_object_typed_new (UCL_STRING); + + obj->value.sv = (const char*)p; + obj->len = len; + obj->flags |= UCL_OBJECT_BINARY; + + if (!(parser->flags & UCL_PARSER_ZEROCOPY)) { + ucl_copy_value_trash (obj); + } + + ucl_array_append (parser->stack->obj, obj); + p += len; + NEXT_STATE; + break; + + case read_ebrace: + if (parser->stack == NULL) { + /* We have an extra end brace */ + ucl_create_err (&parser->err, "invalid length: %llu, %ld " + "remain", (long long unsigned)len, (long)(end - p)); + state = parse_err; + continue; + } + /* Pop the container */ + st = parser->stack; + parser->stack = st->next; + + if (parser->stack->obj->type == UCL_ARRAY) { + ucl_array_append (parser->stack->obj, st->obj); + } + else { + ucl_create_err (&parser->err, "bad container object, array " + "expected"); + state = parse_err; + continue; + } + + free (st); + p++; + NEXT_STATE; + break; + + case parse_err: + default: + return false; + } + } + + if (state != read_ebrace) { + ucl_create_err (&parser->err, "invalid finishing state: %d", state); + return false; + } + + return true; +} \ No newline at end of file diff --git a/contrib/libucl/src/ucl_util.c b/contrib/libucl/src/ucl_util.c index 41e012bf15bb..730a5c4afd57 100644 --- a/contrib/libucl/src/ucl_util.c +++ b/contrib/libucl/src/ucl_util.c @@ -1,4 +1,5 @@ /* Copyright (c) 2013, Vsevolod Stakhov + * Copyright (c) 2015 Allan Jude * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,6 +26,7 @@ #include "ucl_internal.h" #include "ucl_chartable.h" #include "kvec.h" +#include #ifndef _WIN32 #include @@ -230,11 +232,13 @@ ucl_object_free_internal (ucl_object_t *obj, bool allow_rec, ucl_object_dtor dto kv_destroy (*vec); UCL_FREE (sizeof (*vec), vec); } + obj->value.av = NULL; } else if (obj->type == UCL_OBJECT) { if (obj->value.ov != NULL) { ucl_hash_destroy (obj->value.ov, (ucl_hash_free_func *)dtor); } + obj->value.ov = NULL; } tmp = obj->next; dtor (obj); @@ -266,6 +270,17 @@ ucl_unescape_json_string (char *str, size_t len) while (len) { if (*h == '\\') { h ++; + + if (len == 1) { + /* + * If \ is last, then do not try to go further + * Issue: #74 + */ + len --; + *t++ = '\\'; + continue; + } + switch (*h) { case 'n': *t++ = '\n'; @@ -350,7 +365,10 @@ ucl_unescape_json_string (char *str, size_t len) else { *t++ = *h++; } - len --; + + if (len > 0) { + len --; + } } *t = '\0'; @@ -392,11 +410,24 @@ ucl_copy_value_trash (const ucl_object_t *obj) if (obj->type == UCL_STRING) { /* Special case for strings */ - deconst->trash_stack[UCL_TRASH_VALUE] = malloc (obj->len + 1); - if (deconst->trash_stack[UCL_TRASH_VALUE] != NULL) { - memcpy (deconst->trash_stack[UCL_TRASH_VALUE], obj->value.sv, obj->len); - deconst->trash_stack[UCL_TRASH_VALUE][obj->len] = '\0'; - deconst->value.sv = obj->trash_stack[UCL_TRASH_VALUE]; + if (obj->flags & UCL_OBJECT_BINARY) { + deconst->trash_stack[UCL_TRASH_VALUE] = malloc (obj->len); + if (deconst->trash_stack[UCL_TRASH_VALUE] != NULL) { + memcpy (deconst->trash_stack[UCL_TRASH_VALUE], + obj->value.sv, + obj->len); + deconst->value.sv = obj->trash_stack[UCL_TRASH_VALUE]; + } + } + else { + deconst->trash_stack[UCL_TRASH_VALUE] = malloc (obj->len + 1); + if (deconst->trash_stack[UCL_TRASH_VALUE] != NULL) { + memcpy (deconst->trash_stack[UCL_TRASH_VALUE], + obj->value.sv, + obj->len); + deconst->trash_stack[UCL_TRASH_VALUE][obj->len] = '\0'; + deconst->value.sv = obj->trash_stack[UCL_TRASH_VALUE]; + } } } else { @@ -406,10 +437,11 @@ ucl_copy_value_trash (const ucl_object_t *obj) } deconst->flags |= UCL_OBJECT_ALLOCATED_VALUE; } + return obj->trash_stack[UCL_TRASH_VALUE]; } -UCL_EXTERN ucl_object_t* +ucl_object_t* ucl_parser_get_object (struct ucl_parser *parser) { if (parser->state != UCL_STATE_ERROR && parser->top_obj != NULL) { @@ -419,7 +451,7 @@ ucl_parser_get_object (struct ucl_parser *parser) return NULL; } -UCL_EXTERN void +void ucl_parser_free (struct ucl_parser *parser) { struct ucl_stack *stack, *stmp; @@ -427,6 +459,7 @@ ucl_parser_free (struct ucl_parser *parser) struct ucl_chunk *chunk, *ctmp; struct ucl_pubkey *key, *ktmp; struct ucl_variable *var, *vtmp; + ucl_object_t *tr, *trtmp; if (parser == NULL) { return; @@ -436,6 +469,10 @@ ucl_parser_free (struct ucl_parser *parser) ucl_object_unref (parser->top_obj); } + if (parser->includepaths != NULL) { + ucl_object_unref (parser->includepaths); + } + LL_FOREACH_SAFE (parser->stack, stack, stmp) { free (stack); } @@ -455,6 +492,9 @@ ucl_parser_free (struct ucl_parser *parser) free (var->var); UCL_FREE (sizeof (struct ucl_variable), var); } + LL_FOREACH_SAFE (parser->trash_objs, tr, trtmp) { + ucl_object_free_internal (tr, false, ucl_object_dtor_free); + } if (parser->err != NULL) { utstring_free (parser->err); @@ -467,29 +507,61 @@ ucl_parser_free (struct ucl_parser *parser) UCL_FREE (sizeof (struct ucl_parser), parser); } -UCL_EXTERN const char * +const char * ucl_parser_get_error(struct ucl_parser *parser) { if (parser == NULL) { return NULL; } - if (parser->err == NULL) + if (parser->err == NULL) { return NULL; + } - return utstring_body(parser->err); + return utstring_body (parser->err); } -UCL_EXTERN void +int +ucl_parser_get_error_code(struct ucl_parser *parser) +{ + if (parser == NULL) { + return 0; + } + + return parser->err_code; +} + +unsigned +ucl_parser_get_column(struct ucl_parser *parser) +{ + if (parser == NULL || parser->chunks == NULL) { + return 0; + } + + return parser->chunks->column; +} + +unsigned +ucl_parser_get_linenum(struct ucl_parser *parser) +{ + if (parser == NULL || parser->chunks == NULL) { + return 0; + } + + return parser->chunks->line; +} + +void ucl_parser_clear_error(struct ucl_parser *parser) { if (parser != NULL && parser->err != NULL) { utstring_free(parser->err); parser->err = NULL; + parser->err_code = 0; } } -UCL_EXTERN bool +bool ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t len) { #ifndef HAVE_OPENSSL @@ -738,6 +810,20 @@ ucl_sig_check (const unsigned char *data, size_t datalen, } #endif +struct ucl_include_params { + bool check_signature; + bool must_exist; + bool use_glob; + bool use_prefix; + bool soft_fail; + bool allow_glob; + unsigned priority; + enum ucl_duplicate_strategy strat; + enum ucl_parse_type parse_type; + const char *prefix; + const char *target; +}; + /** * Include an url to configuration * @param data @@ -748,8 +834,8 @@ ucl_sig_check (const unsigned char *data, size_t datalen, */ static bool ucl_include_url (const unsigned char *data, size_t len, - struct ucl_parser *parser, bool check_signature, bool must_exist, - unsigned priority) + struct ucl_parser *parser, + struct ucl_include_params *params) { bool res; @@ -761,11 +847,11 @@ ucl_include_url (const unsigned char *data, size_t len, snprintf (urlbuf, sizeof (urlbuf), "%.*s", (int)len, data); - if (!ucl_fetch_url (urlbuf, &buf, &buflen, &parser->err, must_exist)) { - return (!must_exist || false); + if (!ucl_fetch_url (urlbuf, &buf, &buflen, &parser->err, params->must_exist)) { + return (!params->must_exist || false); } - if (check_signature) { + if (params->check_signature) { #if (defined(HAVE_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10000000L) unsigned char *sigbuf = NULL; size_t siglen = 0; @@ -792,7 +878,8 @@ ucl_include_url (const unsigned char *data, size_t len, prev_state = parser->state; parser->state = UCL_STATE_INIT; - res = ucl_parser_add_chunk_priority (parser, buf, buflen, priority); + res = ucl_parser_add_chunk_full (parser, buf, buflen, params->priority, + params->strat, params->parse_type); if (res == true) { /* Remove chunk from the stack */ chunk = parser->chunks; @@ -821,22 +908,27 @@ ucl_include_url (const unsigned char *data, size_t len, */ static bool ucl_include_file_single (const unsigned char *data, size_t len, - struct ucl_parser *parser, bool check_signature, bool must_exist, - unsigned priority) + struct ucl_parser *parser, struct ucl_include_params *params) { bool res; struct ucl_chunk *chunk; unsigned char *buf = NULL; - char *old_curfile; - size_t buflen; + char *old_curfile, *ext; + size_t buflen = 0; char filebuf[PATH_MAX], realbuf[PATH_MAX]; int prev_state; struct ucl_variable *cur_var, *tmp_var, *old_curdir = NULL, *old_filename = NULL; + ucl_object_t *nest_obj = NULL, *old_obj = NULL, *new_obj = NULL; + ucl_hash_t *container = NULL; + struct ucl_stack *st = NULL; snprintf (filebuf, sizeof (filebuf), "%.*s", (int)len, data); if (ucl_realpath (filebuf, realbuf) == NULL) { - if (!must_exist) { + if (params->soft_fail) { + return false; + } + if (!params->must_exist) { return true; } ucl_create_err (&parser->err, "cannot open file %s: %s", @@ -847,16 +939,23 @@ ucl_include_file_single (const unsigned char *data, size_t len, if (parser->cur_file && strcmp (realbuf, parser->cur_file) == 0) { /* We are likely including the file itself */ + if (params->soft_fail) { + return false; + } + ucl_create_err (&parser->err, "trying to include the file %s from itself", realbuf); return false; } - if (!ucl_fetch_file (realbuf, &buf, &buflen, &parser->err, must_exist)) { - return (!must_exist || false); + if (!ucl_fetch_file (realbuf, &buf, &buflen, &parser->err, params->must_exist)) { + if (params->soft_fail) { + return false; + } + return (!params->must_exist || false); } - if (check_signature) { + if (params->check_signature) { #if (defined(HAVE_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10000000L) unsigned char *sigbuf = NULL; size_t siglen = 0; @@ -900,14 +999,128 @@ ucl_include_file_single (const unsigned char *data, size_t len, prev_state = parser->state; parser->state = UCL_STATE_INIT; - res = ucl_parser_add_chunk_priority (parser, buf, buflen, priority); - if (!res && !must_exist) { + if (params->use_prefix && params->prefix == NULL) { + /* Auto generate a key name based on the included filename */ + params->prefix = basename (realbuf); + ext = strrchr (params->prefix, '.'); + if (ext != NULL && (strcmp (ext, ".conf") == 0 || strcmp (ext, ".ucl") == 0)) { + /* Strip off .conf or .ucl */ + *ext = '\0'; + } + } + if (params->prefix != NULL) { + /* This is a prefixed include */ + container = parser->stack->obj->value.ov; + + old_obj = __DECONST (ucl_object_t *, ucl_hash_search (container, + params->prefix, strlen (params->prefix))); + + if (strcasecmp (params->target, "array") == 0 && old_obj == NULL) { + /* Create an array with key: prefix */ + old_obj = ucl_object_new_full (UCL_ARRAY, params->priority); + old_obj->key = params->prefix; + old_obj->keylen = strlen (params->prefix); + ucl_copy_key_trash(old_obj); + old_obj->prev = old_obj; + old_obj->next = NULL; + + container = ucl_hash_insert_object (container, old_obj, + parser->flags & UCL_PARSER_KEY_LOWERCASE); + parser->stack->obj->len ++; + + nest_obj = ucl_object_new_full (UCL_OBJECT, params->priority); + nest_obj->prev = nest_obj; + nest_obj->next = NULL; + + ucl_array_append (old_obj, nest_obj); + } + else if (old_obj == NULL) { + /* Create an object with key: prefix */ + nest_obj = ucl_object_new_full (UCL_OBJECT, params->priority); + nest_obj->key = params->prefix; + nest_obj->keylen = strlen (params->prefix); + ucl_copy_key_trash(nest_obj); + nest_obj->prev = nest_obj; + nest_obj->next = NULL; + + container = ucl_hash_insert_object (container, nest_obj, + parser->flags & UCL_PARSER_KEY_LOWERCASE); + parser->stack->obj->len ++; + } + else if (strcasecmp (params->target, "array") == 0 || + ucl_object_type(old_obj) == UCL_ARRAY) { + if (ucl_object_type(old_obj) == UCL_ARRAY) { + /* Append to the existing array */ + nest_obj = ucl_object_new_full (UCL_OBJECT, params->priority); + nest_obj->prev = nest_obj; + nest_obj->next = NULL; + + ucl_array_append (old_obj, nest_obj); + } + else { + /* Convert the object to an array */ + new_obj = ucl_object_typed_new (UCL_ARRAY); + new_obj->key = old_obj->key; + new_obj->keylen = old_obj->keylen; + new_obj->flags |= UCL_OBJECT_MULTIVALUE; + new_obj->prev = new_obj; + new_obj->next = NULL; + + nest_obj = ucl_object_new_full (UCL_OBJECT, params->priority); + nest_obj->prev = nest_obj; + nest_obj->next = NULL; + + ucl_array_append (new_obj, old_obj); + ucl_array_append (new_obj, nest_obj); + ucl_hash_replace (container, old_obj, new_obj); + } + } + else { + if (ucl_object_type (old_obj) == UCL_OBJECT) { + /* Append to existing Object*/ + nest_obj = old_obj; + } + else { + /* The key is not an object */ + ucl_create_err (&parser->err, + "Conflicting type for key: %s", + params->prefix); + return false; + } + } + + /* Put all of the content of the include inside that object */ + parser->stack->obj->value.ov = container; + + if (nest_obj != NULL) { + st = UCL_ALLOC (sizeof (struct ucl_stack)); + if (st == NULL) { + ucl_create_err (&parser->err, "cannot allocate memory for an object"); + ucl_object_unref (nest_obj); + return NULL; + } + st->obj = nest_obj; + st->level = parser->stack->level; + LL_PREPEND (parser->stack, st); + parser->cur_obj = nest_obj; + } + } + + res = ucl_parser_add_chunk_full (parser, buf, buflen, params->priority, + params->strat, params->parse_type); + if (!res && !params->must_exist) { /* Free error */ utstring_free (parser->err); parser->err = NULL; parser->state = UCL_STATE_AFTER_VALUE; } + /* Stop nesting the include, take 1 level off the stack */ + if (params->prefix != NULL && nest_obj != NULL) { + parser->stack = st->next; + UCL_FREE (sizeof (struct ucl_stack), st); + } + /* Remove chunk from the stack */ chunk = parser->chunks; if (chunk != NULL) { @@ -917,6 +1130,10 @@ ucl_include_file_single (const unsigned char *data, size_t len, } /* Restore old file vars */ + if (parser->cur_file) { + free (parser->cur_file); + } + parser->cur_file = old_curfile; DL_FOREACH_SAFE (parser->variables, cur_var, tmp_var) { if (strcmp (cur_var->var, "CURDIR") == 0 && old_curdir) { @@ -938,9 +1155,6 @@ ucl_include_file_single (const unsigned char *data, size_t len, if (old_curdir) { DL_APPEND (parser->variables, old_curdir); } - if (old_curfile) { - free (old_curfile); - } parser->state = prev_state; @@ -961,8 +1175,7 @@ ucl_include_file_single (const unsigned char *data, size_t len, */ static bool ucl_include_file (const unsigned char *data, size_t len, - struct ucl_parser *parser, bool check_signature, bool must_exist, - bool allow_glob, unsigned priority) + struct ucl_parser *parser, struct ucl_include_params *params) { const unsigned char *p = data, *end = data + len; bool need_glob = false; @@ -971,9 +1184,8 @@ ucl_include_file (const unsigned char *data, size_t len, size_t i; #ifndef _WIN32 - if (!allow_glob) { - return ucl_include_file_single (data, len, parser, check_signature, - must_exist, priority); + if (!params->allow_glob) { + return ucl_include_file_single (data, len, parser, params); } else { /* Check for special symbols in a filename */ @@ -987,14 +1199,17 @@ ucl_include_file (const unsigned char *data, size_t len, if (need_glob) { glob_t globbuf; memset (&globbuf, 0, sizeof (globbuf)); - ucl_strlcpy (glob_pattern, (const char *)data, sizeof (glob_pattern)); + ucl_strlcpy (glob_pattern, (const char *)data, + (len + 1 < sizeof (glob_pattern) ? len + 1 : sizeof (glob_pattern))); if (glob (glob_pattern, 0, NULL, &globbuf) != 0) { - return (!must_exist || false); + return (!params->must_exist || false); } for (i = 0; i < globbuf.gl_pathc; i ++) { if (!ucl_include_file_single ((unsigned char *)globbuf.gl_pathv[i], - strlen (globbuf.gl_pathv[i]), parser, check_signature, - must_exist, priority)) { + strlen (globbuf.gl_pathv[i]), parser, params)) { + if (params->soft_fail) { + continue; + } globfree (&globbuf); return false; } @@ -1002,22 +1217,20 @@ ucl_include_file (const unsigned char *data, size_t len, } globfree (&globbuf); - if (cnt == 0 && must_exist) { + if (cnt == 0 && params->must_exist) { ucl_create_err (&parser->err, "cannot match any files for pattern %s", glob_pattern); return false; } } else { - return ucl_include_file_single (data, len, parser, check_signature, - must_exist, priority); + return ucl_include_file_single (data, len, parser, params); } } #else /* Win32 compilers do not support globbing. Therefore, for Win32, treat allow_glob/need_glob as a NOOP and just return */ - return ucl_include_file_single (data, len, parser, check_signature, - must_exist, priority); + return ucl_include_file_single (data, len, parser, params); #endif return true; @@ -1039,52 +1252,123 @@ ucl_include_common (const unsigned char *data, size_t len, bool default_try, bool default_sign) { - bool try_load, allow_glob, allow_url, need_sign; - unsigned priority; + bool allow_url, search; + const char *duplicate; const ucl_object_t *param; - ucl_object_iter_t it = NULL; + ucl_object_iter_t it = NULL, ip = NULL; + char ipath[PATH_MAX]; + struct ucl_include_params params; /* Default values */ - try_load = default_try; - allow_glob = false; - allow_url = true; - need_sign = default_sign; - priority = 0; + params.soft_fail = default_try; + params.allow_glob = false; + params.check_signature = default_sign; + params.use_prefix = false; + params.target = "object"; + params.prefix = NULL; + params.priority = 0; + params.parse_type = UCL_PARSE_UCL; + params.strat = UCL_DUPLICATE_APPEND; + params.must_exist = !default_try; + + search = false; /* Process arguments */ if (args != NULL && args->type == UCL_OBJECT) { while ((param = ucl_iterate_object (args, &it, true)) != NULL) { if (param->type == UCL_BOOLEAN) { - if (strcmp (param->key, "try") == 0) { - try_load = ucl_object_toboolean (param); + if (strncmp (param->key, "try", param->keylen) == 0) { + params.must_exist = !ucl_object_toboolean (param); } - else if (strcmp (param->key, "sign") == 0) { - need_sign = ucl_object_toboolean (param); + else if (strncmp (param->key, "sign", param->keylen) == 0) { + params.check_signature = ucl_object_toboolean (param); } - else if (strcmp (param->key, "glob") == 0) { - allow_glob = ucl_object_toboolean (param); + else if (strncmp (param->key, "glob", param->keylen) == 0) { + params.allow_glob = ucl_object_toboolean (param); } - else if (strcmp (param->key, "url") == 0) { - allow_url = ucl_object_toboolean (param); + else if (strncmp (param->key, "url", param->keylen) == 0) { + allow_url = ucl_object_toboolean (param); + } + else if (strncmp (param->key, "prefix", param->keylen) == 0) { + params.use_prefix = ucl_object_toboolean (param); + } + } + else if (param->type == UCL_STRING) { + if (strncmp (param->key, "key", param->keylen) == 0) { + params.prefix = ucl_object_tostring (param); + } + else if (strncmp (param->key, "target", param->keylen) == 0) { + params.target = ucl_object_tostring (param); + } + else if (strncmp (param->key, "duplicate", param->keylen) == 0) { + duplicate = ucl_object_tostring (param); + + if (strcmp (duplicate, "append") == 0) { + params.strat = UCL_DUPLICATE_APPEND; + } + else if (strcmp (duplicate, "merge") == 0) { + params.strat = UCL_DUPLICATE_MERGE; + } + else if (strcmp (duplicate, "rewrite") == 0) { + params.strat = UCL_DUPLICATE_REWRITE; + } + else if (strcmp (duplicate, "error") == 0) { + params.strat = UCL_DUPLICATE_ERROR; + } + } + } + else if (param->type == UCL_ARRAY) { + if (strncmp (param->key, "path", param->keylen) == 0) { + ucl_set_include_path (parser, __DECONST(ucl_object_t *, param)); } } else if (param->type == UCL_INT) { - if (strcmp (param->key, "priority") == 0) { - priority = ucl_object_toint (param); + if (strncmp (param->key, "priority", param->keylen) == 0) { + params.priority = ucl_object_toint (param); } } } } - if (*data == '/' || *data == '.') { - /* Try to load a file */ - return ucl_include_file (data, len, parser, need_sign, !try_load, - allow_glob, priority); + if (parser->includepaths == NULL) { + if (allow_url && ucl_strnstr (data, "://", len) != NULL) { + /* Globbing is not used for URL's */ + return ucl_include_url (data, len, parser, ¶ms); + } + else if (data != NULL) { + /* Try to load a file */ + return ucl_include_file (data, len, parser, ¶ms); + } } - else if (allow_url) { - /* Globbing is not used for URL's */ - return ucl_include_url (data, len, parser, need_sign, !try_load, - priority); + else { + if (allow_url && ucl_strnstr (data, "://", len) != NULL) { + /* Globbing is not used for URL's */ + return ucl_include_url (data, len, parser, ¶ms); + } + + ip = ucl_object_iterate_new (parser->includepaths); + while ((param = ucl_object_iterate_safe (ip, true)) != NULL) { + if (ucl_object_type(param) == UCL_STRING) { + snprintf (ipath, sizeof (ipath), "%s/%.*s", ucl_object_tostring(param), + (int)len, data); + if ((search = ucl_include_file (ipath, strlen (ipath), + parser, ¶ms))) { + if (!params.allow_glob) { + break; + } + } + } + } + ucl_object_iterate_free (ip); + if (search == true) { + return true; + } + else { + ucl_create_err (&parser->err, + "cannot find file: %.*s in search path", + (int)len, data); + return false; + } } return false; @@ -1094,11 +1378,11 @@ ucl_include_common (const unsigned char *data, size_t len, * Handle include macro * @param data include data * @param len length of data + * @param args UCL object representing arguments to the macro * @param ud user data - * @param err error ptr * @return */ -UCL_EXTERN bool +bool ucl_include_handler (const unsigned char *data, size_t len, const ucl_object_t *args, void* ud) { @@ -1111,11 +1395,11 @@ ucl_include_handler (const unsigned char *data, size_t len, * Handle includes macro * @param data include data * @param len length of data + * @param args UCL object representing arguments to the macro * @param ud user data - * @param err error ptr * @return */ -UCL_EXTERN bool +bool ucl_includes_handler (const unsigned char *data, size_t len, const ucl_object_t *args, void* ud) { @@ -1124,8 +1408,15 @@ ucl_includes_handler (const unsigned char *data, size_t len, return ucl_include_common (data, len, args, parser, false, true); } - -UCL_EXTERN bool +/** + * Handle tryinclude macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ud user data + * @return + */ +bool ucl_try_include_handler (const unsigned char *data, size_t len, const ucl_object_t *args, void* ud) { @@ -1134,7 +1425,251 @@ ucl_try_include_handler (const unsigned char *data, size_t len, return ucl_include_common (data, len, args, parser, true, false); } -UCL_EXTERN bool +/** + * Handle priority macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ud user data + * @return + */ +bool +ucl_priority_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud) +{ + struct ucl_parser *parser = ud; + unsigned priority = 255; + const ucl_object_t *param; + bool found = false; + char *value = NULL, *leftover = NULL; + ucl_object_iter_t it = NULL; + + if (parser == NULL) { + return false; + } + + /* Process arguments */ + if (args != NULL && args->type == UCL_OBJECT) { + while ((param = ucl_iterate_object (args, &it, true)) != NULL) { + if (param->type == UCL_INT) { + if (strncmp (param->key, "priority", param->keylen) == 0) { + priority = ucl_object_toint (param); + found = true; + } + } + } + } + + if (len > 0) { + value = malloc(len + 1); + ucl_strlcpy(value, (const char *)data, len + 1); + priority = strtol(value, &leftover, 10); + if (*leftover != '\0') { + ucl_create_err (&parser->err, "Invalid priority value in macro: %s", + value); + free(value); + return false; + } + free(value); + found = true; + } + + if (found == true) { + parser->chunks->priority = priority; + return true; + } + + ucl_create_err (&parser->err, "Unable to parse priority macro"); + return false; +} + +/** + * Handle load macro + * @param data include data + * @param len length of data + * @param args UCL object representing arguments to the macro + * @param ud user data + * @return + */ +bool +ucl_load_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, void* ud) +{ + struct ucl_parser *parser = ud; + const ucl_object_t *param; + ucl_object_t *obj, *old_obj; + ucl_object_iter_t it = NULL; + bool try_load, multiline, test; + const char *target, *prefix; + char *load_file, *tmp; + unsigned char *buf; + size_t buflen; + unsigned priority; + int64_t iv; + ucl_hash_t *container = NULL; + enum ucl_string_flags flags; + + /* Default values */ + try_load = false; + multiline = false; + test = false; + target = "string"; + prefix = NULL; + load_file = NULL; + buf = NULL; + buflen = 0; + priority = 0; + obj = NULL; + old_obj = NULL; + flags = 0; + + if (parser == NULL) { + return false; + } + + /* Process arguments */ + if (args != NULL && args->type == UCL_OBJECT) { + while ((param = ucl_iterate_object (args, &it, true)) != NULL) { + if (param->type == UCL_BOOLEAN) { + if (strncmp (param->key, "try", param->keylen) == 0) { + try_load = ucl_object_toboolean (param); + } + else if (strncmp (param->key, "multiline", param->keylen) == 0) { + multiline = ucl_object_toboolean (param); + } + else if (strncmp (param->key, "escape", param->keylen) == 0) { + test = ucl_object_toboolean (param); + if (test) { + flags |= UCL_STRING_ESCAPE; + } + } + else if (strncmp (param->key, "trim", param->keylen) == 0) { + test = ucl_object_toboolean (param); + if (test) { + flags |= UCL_STRING_TRIM; + } + } + } + else if (param->type == UCL_STRING) { + if (strncmp (param->key, "key", param->keylen) == 0) { + prefix = ucl_object_tostring (param); + } + else if (strncmp (param->key, "target", param->keylen) == 0) { + target = ucl_object_tostring (param); + } + } + else if (param->type == UCL_INT) { + if (strncmp (param->key, "priority", param->keylen) == 0) { + priority = ucl_object_toint (param); + } + } + } + } + + if (prefix == NULL || strlen(prefix) == 0) { + ucl_create_err (&parser->err, "No Key specified in load macro"); + return false; + } + + if (len > 0) { + asprintf (&load_file, "%.*s", (int)len, data); + if (!ucl_fetch_file (load_file, &buf, &buflen, &parser->err, !try_load)) { + return (try_load || false); + } + + container = parser->stack->obj->value.ov; + old_obj = __DECONST (ucl_object_t *, ucl_hash_search (container, prefix, strlen (prefix))); + if (old_obj != NULL) { + ucl_create_err (&parser->err, "Key %s already exists", prefix); + return false; + } + + if (strcasecmp (target, "string") == 0) { + obj = ucl_object_fromstring_common (buf, buflen, flags); + ucl_copy_value_trash (obj); + if (multiline) { + obj->flags |= UCL_OBJECT_MULTILINE; + } + } + else if (strcasecmp (target, "int") == 0) { + asprintf(&tmp, "%.*s", (int)buflen, buf); + iv = strtoll(tmp, NULL, 10); + obj = ucl_object_fromint(iv); + } + + if (buflen > 0) { + ucl_munmap (buf, buflen); + } + + if (obj != NULL) { + obj->key = prefix; + obj->keylen = strlen (prefix); + ucl_copy_key_trash(obj); + obj->prev = obj; + obj->next = NULL; + ucl_object_set_priority (obj, priority); + container = ucl_hash_insert_object (container, obj, + parser->flags & UCL_PARSER_KEY_LOWERCASE); + parser->stack->obj->value.ov = container; + } + return true; + } + + ucl_create_err (&parser->err, "Unable to parse load macro"); + return false; +} + +bool +ucl_inherit_handler (const unsigned char *data, size_t len, + const ucl_object_t *args, const ucl_object_t *ctx, void* ud) +{ + const ucl_object_t *parent, *cur; + ucl_object_t *target, *copy; + ucl_object_iter_t it = NULL; + bool replace = false; + struct ucl_parser *parser = ud; + + parent = ucl_object_find_keyl (ctx, data, len); + + /* Some sanity checks */ + if (parent == NULL || ucl_object_type (parent) != UCL_OBJECT) { + ucl_create_err (&parser->err, "Unable to find inherited object %*.s", + (int)len, data); + return false; + } + + if (parser->stack == NULL || parser->stack->obj == NULL || + ucl_object_type (parser->stack->obj) != UCL_OBJECT) { + ucl_create_err (&parser->err, "Invalid inherit context"); + return false; + } + + target = parser->stack->obj; + + if (args && (cur = ucl_object_find_key (args, "replace")) != NULL) { + replace = ucl_object_toboolean (cur); + } + + while ((cur = ucl_iterate_object (parent, &it, true))) { + /* We do not replace existing keys */ + if (!replace && ucl_object_find_keyl (target, cur->key, cur->keylen)) { + continue; + } + + copy = ucl_object_copy (cur); + + if (!replace) { + copy->flags |= UCL_OBJECT_INHERITED; + } + + ucl_object_insert_key (target, copy, copy->key, + copy->keylen, false); + } + + return true; +} + +bool ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename, bool need_expand) { char realbuf[PATH_MAX], *curdir; @@ -1164,8 +1699,9 @@ ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename, bool n return true; } -UCL_EXTERN bool -ucl_parser_add_file (struct ucl_parser *parser, const char *filename) +bool +ucl_parser_add_file_priority (struct ucl_parser *parser, const char *filename, + unsigned priority) { unsigned char *buf; size_t len; @@ -1188,7 +1724,7 @@ ucl_parser_add_file (struct ucl_parser *parser, const char *filename) } parser->cur_file = strdup (realbuf); ucl_parser_set_filevars (parser, realbuf, false); - ret = ucl_parser_add_chunk (parser, buf, len); + ret = ucl_parser_add_chunk_priority (parser, buf, len, priority); if (len > 0) { ucl_munmap (buf, len); @@ -1197,8 +1733,20 @@ ucl_parser_add_file (struct ucl_parser *parser, const char *filename) return ret; } -UCL_EXTERN bool -ucl_parser_add_fd (struct ucl_parser *parser, int fd) +bool +ucl_parser_add_file (struct ucl_parser *parser, const char *filename) +{ + if (parser == NULL) { + return false; + } + + return ucl_parser_add_file_priority(parser, filename, + parser->default_priority); +} + +bool +ucl_parser_add_fd_priority (struct ucl_parser *parser, int fd, + unsigned priority) { unsigned char *buf; size_t len; @@ -1221,7 +1769,7 @@ ucl_parser_add_fd (struct ucl_parser *parser, int fd) } parser->cur_file = NULL; len = st.st_size; - ret = ucl_parser_add_chunk (parser, buf, len); + ret = ucl_parser_add_chunk_priority (parser, buf, len, priority); if (len > 0) { ucl_munmap (buf, len); @@ -1230,6 +1778,16 @@ ucl_parser_add_fd (struct ucl_parser *parser, int fd) return ret; } +bool +ucl_parser_add_fd (struct ucl_parser *parser, int fd) +{ + if (parser == NULL) { + return false; + } + + return ucl_parser_add_fd_priority(parser, fd, parser->default_priority); +} + size_t ucl_strlcpy (char *dst, const char *src, size_t siz) { @@ -1285,6 +1843,51 @@ ucl_strlcpy_tolower (char *dst, const char *src, size_t siz) return (s - src); /* count does not include NUL */ } +/* + * Find the first occurrence of find in s + */ +char * +ucl_strnstr (const char *s, const char *find, int len) +{ + char c, sc; + int mlen; + + if ((c = *find++) != 0) { + mlen = strlen (find); + do { + do { + if ((sc = *s++) == 0 || len-- == 0) + return (NULL); + } while (sc != c); + } while (strncmp (s, find, mlen) != 0); + s--; + } + return ((char *)s); +} + +/* + * Find the first occurrence of find in s, ignore case. + */ +char * +ucl_strncasestr (const char *s, const char *find, int len) +{ + char c, sc; + int mlen; + + if ((c = *find++) != 0) { + c = tolower (c); + mlen = strlen (find); + do { + do { + if ((sc = *s++) == 0 || len-- == 0) + return (NULL); + } while (tolower (sc) != c); + } while (strncasecmp (s, find, mlen) != 0); + s--; + } + return ((char *)s); +} + ucl_object_t * ucl_object_fromstring_common (const char *str, size_t len, enum ucl_string_flags flags) { @@ -1539,7 +2142,7 @@ ucl_object_delete_keyl (ucl_object_t *top, const char *key, size_t keylen) bool ucl_object_delete_key (ucl_object_t *top, const char *key) { - return ucl_object_delete_keyl (top, key, strlen(key)); + return ucl_object_delete_keyl (top, key, strlen (key)); } ucl_object_t* @@ -1564,7 +2167,7 @@ ucl_object_pop_keyl (ucl_object_t *top, const char *key, size_t keylen) ucl_object_t* ucl_object_pop_key (ucl_object_t *top, const char *key) { - return ucl_object_pop_keyl (top, key, strlen(key)); + return ucl_object_pop_keyl (top, key, strlen (key)); } bool @@ -1642,10 +2245,45 @@ ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen) const ucl_object_t * ucl_object_find_key (const ucl_object_t *obj, const char *key) { - if (key == NULL) + if (key == NULL) { return NULL; + } - return ucl_object_find_keyl (obj, key, strlen(key)); + return ucl_object_find_keyl (obj, key, strlen (key)); +} + +const ucl_object_t* +ucl_object_find_any_key (const ucl_object_t *obj, + const char *key, ...) +{ + va_list ap; + const ucl_object_t *ret = NULL; + const char *nk = NULL; + + if (obj == NULL || key == NULL) { + return NULL; + } + + ret = ucl_object_find_keyl (obj, key, strlen (key)); + + if (ret == NULL) { + va_start (ap, key); + + while (ret == NULL) { + nk = va_arg (ap, const char *); + + if (nk == NULL) { + break; + } + else { + ret = ucl_object_find_keyl (obj, nk, strlen (nk)); + } + } + + va_end (ap); + } + + return ret; } const ucl_object_t* @@ -1792,6 +2430,12 @@ ucl_object_iterate_free (ucl_object_iter_t it) const ucl_object_t * ucl_lookup_path (const ucl_object_t *top, const char *path_in) { + return ucl_lookup_path_char (top, path_in, '.'); +} + + +const ucl_object_t * +ucl_lookup_path_char (const ucl_object_t *top, const char *path_in, const char sep) { const ucl_object_t *o = NULL, *found; const char *p, *c; char *err_str; @@ -1805,20 +2449,20 @@ ucl_lookup_path (const ucl_object_t *top, const char *path_in) { p = path_in; /* Skip leading dots */ - while (*p == '.') { + while (*p == sep) { p ++; } c = p; while (*p != '\0') { p ++; - if (*p == '.' || *p == '\0') { + if (*p == sep || *p == '\0') { if (p > c) { switch (top->type) { case UCL_ARRAY: /* Key should be an int */ index = strtoul (c, &err_str, 10); - if (err_str != NULL && (*err_str != '.' && *err_str != '\0')) { + if (err_str != NULL && (*err_str != sep && *err_str != '\0')) { return NULL; } o = ucl_array_find_index (top, index); @@ -1913,6 +2557,10 @@ ucl_object_new_userdata (ucl_userdata_dtor dtor, ucl_userdata_emitter emitter) ucl_type_t ucl_object_type (const ucl_object_t *obj) { + if (obj == NULL) { + return UCL_NULL; + } + return obj->type; } @@ -1981,6 +2629,11 @@ ucl_array_append (ucl_object_t *top, ucl_object_t *elt) if (vec == NULL) { vec = UCL_ALLOC (sizeof (*vec)); + + if (vec == NULL) { + return false; + } + kv_init (*vec); top->value.av = (void *)vec; } @@ -2021,14 +2674,23 @@ bool ucl_array_merge (ucl_object_t *top, ucl_object_t *elt, bool copy) { unsigned i; + ucl_object_t *cp = NULL; ucl_object_t **obj; - UCL_ARRAY_GET (v1, top); - UCL_ARRAY_GET (v2, elt); if (elt == NULL || top == NULL || top->type != UCL_ARRAY || elt->type != UCL_ARRAY) { return false; } + if (copy) { + cp = ucl_object_copy (elt); + } + else { + cp = ucl_object_ref (elt); + } + + UCL_ARRAY_GET (v1, top); + UCL_ARRAY_GET (v2, cp); + kv_concat (ucl_object_t *, *v1, *v2); for (i = v2->n; i < v1->n; i ++) { @@ -2036,14 +2698,7 @@ ucl_array_merge (ucl_object_t *top, ucl_object_t *elt, bool copy) if (*obj == NULL) { continue; } - top->len ++; - if (copy) { - *obj = ucl_object_copy (*obj); - } - else { - ucl_object_ref (*obj); - } } return true; @@ -2056,6 +2711,10 @@ ucl_array_delete (ucl_object_t *top, ucl_object_t *elt) ucl_object_t *ret = NULL; unsigned i; + if (vec == NULL) { + return NULL; + } + for (i = 0; i < vec->n; i ++) { if (kv_A (*vec, i) == elt) { kv_del (ucl_object_t *, *vec, i); @@ -2073,7 +2732,8 @@ ucl_array_head (const ucl_object_t *top) { UCL_ARRAY_GET (vec, top); - if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) { + if (vec == NULL || top == NULL || top->type != UCL_ARRAY || + top->value.av == NULL) { return NULL; } @@ -2136,6 +2796,25 @@ ucl_array_find_index (const ucl_object_t *top, unsigned int index) return NULL; } +unsigned int +ucl_array_index_of (ucl_object_t *top, ucl_object_t *elt) +{ + UCL_ARRAY_GET (vec, top); + unsigned i; + + if (vec == NULL) { + return (unsigned int)(-1); + } + + for (i = 0; i < vec->n; i ++) { + if (kv_A (*vec, i) == elt) { + return i; + } + } + + return (unsigned int)(-1); +} + ucl_object_t * ucl_array_replace_index (ucl_object_t *top, ucl_object_t *elt, unsigned int index) @@ -2265,7 +2944,9 @@ ucl_object_tostring_safe (const ucl_object_t *obj, const char **target) switch (obj->type) { case UCL_STRING: - *target = ucl_copy_value_trash (obj); + if (!(obj->flags & UCL_OBJECT_BINARY)) { + *target = ucl_copy_value_trash (obj); + } break; default: return false; @@ -2286,7 +2967,12 @@ ucl_object_tostring (const ucl_object_t *obj) const char * ucl_object_tostring_forced (const ucl_object_t *obj) { - return ucl_copy_value_trash (obj); + /* TODO: For binary strings we might encode string here */ + if (!(obj->flags & UCL_OBJECT_BINARY)) { + return ucl_copy_value_trash (obj); + } + + return NULL; } bool @@ -2533,7 +3219,7 @@ ucl_object_compare (const ucl_object_t *o1, const ucl_object_t *o2) void ucl_object_array_sort (ucl_object_t *ar, - int (*cmp)(const ucl_object_t *o1, const ucl_object_t *o2)) + int (*cmp)(const ucl_object_t **o1, const ucl_object_t **o2)) { UCL_ARRAY_GET (vec, ar); @@ -2563,6 +3249,9 @@ ucl_object_set_priority (ucl_object_t *obj, { if (obj != NULL) { priority &= (0x1 << PRIOBITS) - 1; - obj->flags |= priority << ((sizeof (obj->flags) * NBBY) - PRIOBITS); + priority <<= ((sizeof (obj->flags) * NBBY) - PRIOBITS); + priority |= obj->flags & ((1 << ((sizeof (obj->flags) * NBBY) - + PRIOBITS)) - 1); + obj->flags = priority; } } diff --git a/contrib/libucl/src/xxhash.c b/contrib/libucl/src/xxhash.c index fc4463395c5e..3473eb46a3b0 100644 --- a/contrib/libucl/src/xxhash.c +++ b/contrib/libucl/src/xxhash.c @@ -1,6 +1,6 @@ /* xxHash - Fast Hash algorithm -Copyright (C) 2012-2013, Yann Collet. +Copyright (C) 2012-2014, Yann Collet. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) Redistribution and use in source and binary forms, with or without @@ -28,6 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. You can contact the author at : - xxHash source repository : http://code.google.com/p/xxhash/ +- public discussion board : https://groups.google.com/forum/#!forum/lz4c */ @@ -47,7 +48,7 @@ You can contact the author at : // When this option is enabled, xxHash output for null input pointers will be the same as a null-length input. // This option has a very small performance cost (only measurable on small inputs). // By default, this option is disabled. To enable it, uncomment below define : -//#define XXH_ACCEPT_NULL_INPUT_POINTER 1 +// #define XXH_ACCEPT_NULL_INPUT_POINTER 1 // XXH_FORCE_NATIVE_FORMAT : // By default, xxHash library provides endian-independant Hash values, based on little-endian convention. @@ -58,7 +59,6 @@ You can contact the author at : // This option has no impact on Little_Endian CPU. #define XXH_FORCE_NATIVE_FORMAT 0 - //************************************** // Compiler Specific Options //************************************** @@ -68,28 +68,30 @@ You can contact the author at : #endif #ifdef _MSC_VER // Visual Studio -# define forceinline static __forceinline -#else +# define FORCE_INLINE static __forceinline +#else # ifdef __GNUC__ -# define forceinline static inline __attribute__((always_inline)) +# define FORCE_INLINE static inline __attribute__((always_inline)) # else -# define forceinline static inline +# define FORCE_INLINE static inline # endif #endif - //************************************** // Includes & Memory related functions //************************************** #include "xxhash.h" -// Modify the local functions below should you wish to use some other memory related routines +// Modify the local functions below should you wish to use some other memory routines // for malloc(), free() #include -forceinline void* XXH_malloc(size_t s) { return malloc(s); } -forceinline void XXH_free (void* p) { free(p); } +static void* XXH_malloc(size_t s) { return malloc(s); } +static void XXH_free (void* p) { free(p); } // for memcpy() #include -forceinline void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); } +static void* XXH_memcpy(void* dest, const void* src, size_t size) +{ + return memcpy(dest,src,size); +} //************************************** @@ -97,17 +99,17 @@ forceinline void* XXH_memcpy(void* dest, const void* src, size_t size) { return //************************************** #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L // C99 # include - typedef uint8_t BYTE; - typedef uint16_t U16; - typedef uint32_t U32; - typedef int32_t S32; - typedef uint64_t U64; +typedef uint8_t BYTE; +typedef uint16_t U16; +typedef uint32_t U32; +typedef int32_t S32; +typedef uint64_t U64; #else - typedef unsigned char BYTE; - typedef unsigned short U16; - typedef unsigned int U32; - typedef signed int S32; - typedef unsigned long long U64; +typedef unsigned char BYTE; +typedef unsigned short U16; +typedef unsigned int U32; +typedef signed int S32; +typedef uint64_t U64; #endif #if defined(__GNUC__) && !defined(XXH_USE_UNALIGNED_ACCESS) @@ -124,13 +126,21 @@ forceinline void* XXH_memcpy(void* dest, const void* src, size_t size) { return # endif #endif -typedef struct _U32_S { U32 v; } _PACKED U32_S; +typedef struct _U32_S +{ + U32 v; +} _PACKED U32_S; +typedef struct _U64_S +{ + U64 v; +} _PACKED U64_S; #if !defined(XXH_USE_UNALIGNED_ACCESS) && !defined(__GNUC__) # pragma pack(pop) #endif #define A32(x) (((U32_S *)(x))->v) +#define A64(x) (((U64_S *)(x))->v) //*************************************** @@ -141,20 +151,37 @@ typedef struct _U32_S { U32 v; } _PACKED U32_S; // Note : although _rotl exists for minGW (GCC under windows), performance seems poor #if defined(_MSC_VER) # define XXH_rotl32(x,r) _rotl(x,r) +# define XXH_rotl64(x,r) _rotl64(x,r) #else # define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r))) +# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r))) #endif #if defined(_MSC_VER) // Visual Studio # define XXH_swap32 _byteswap_ulong -#elif GCC_VERSION >= 403 +# define XXH_swap64 _byteswap_uint64 +#elif GCC_VERSION >= 403 || defined(__clang__) # define XXH_swap32 __builtin_bswap32 +# define XXH_swap64 __builtin_bswap64 #else -static inline U32 XXH_swap32 (U32 x) { +static inline U32 XXH_swap32 (U32 x) +{ return ((x << 24) & 0xff000000 ) | - ((x << 8) & 0x00ff0000 ) | - ((x >> 8) & 0x0000ff00 ) | - ((x >> 24) & 0x000000ff );} + ((x << 8) & 0x00ff0000 ) | + ((x >> 8) & 0x0000ff00 ) | + ((x >> 24) & 0x000000ff ); +} +static inline U64 XXH_swap64 (U64 x) +{ + return ((x << 56) & 0xff00000000000000ULL) | + ((x << 40) & 0x00ff000000000000ULL) | + ((x << 24) & 0x0000ff0000000000ULL) | + ((x << 8) & 0x000000ff00000000ULL) | + ((x >> 8) & 0x00000000ff000000ULL) | + ((x >> 24) & 0x0000000000ff0000ULL) | + ((x >> 40) & 0x000000000000ff00ULL) | + ((x >> 56) & 0x00000000000000ffULL); +} #endif @@ -167,13 +194,18 @@ static inline U32 XXH_swap32 (U32 x) { #define PRIME32_4 668265263U #define PRIME32_5 374761393U +#define PRIME64_1 11400714785074694791ULL +#define PRIME64_2 14029467366897019727ULL +#define PRIME64_3 1609587929392839161ULL +#define PRIME64_4 9650029242287828579ULL +#define PRIME64_5 2870177450012600261ULL //************************************** // Architecture Macros //************************************** typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; #ifndef XXH_CPU_LITTLE_ENDIAN // It is possible to define XXH_CPU_LITTLE_ENDIAN externally, for example using a compiler switch - static const int one = 1; +static const int one = 1; # define XXH_CPU_LITTLE_ENDIAN (*(char*)(&one)) #endif @@ -189,28 +221,49 @@ typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; //**************************** typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment; -forceinline U32 XXH_readLE32_align(const U32* ptr, XXH_endianess endian, XXH_alignment align) -{ +FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +{ if (align==XXH_unaligned) - return endian==XXH_littleEndian ? A32(ptr) : XXH_swap32(A32(ptr)); + return endian==XXH_littleEndian ? A32(ptr) : XXH_swap32(A32(ptr)); else - return endian==XXH_littleEndian ? *ptr : XXH_swap32(*ptr); + return endian==XXH_littleEndian ? *(U32*)ptr : XXH_swap32(*(U32*)ptr); } -forceinline U32 XXH_readLE32(const U32* ptr, XXH_endianess endian) { return XXH_readLE32_align(ptr, endian, XXH_unaligned); } +FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianess endian) +{ + return XXH_readLE32_align(ptr, endian, XXH_unaligned); +} + +FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +{ + if (align==XXH_unaligned) + return endian==XXH_littleEndian ? A64(ptr) : XXH_swap64(A64(ptr)); + else + return endian==XXH_littleEndian ? *(U64*)ptr : XXH_swap64(*(U64*)ptr); +} + +FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian) +{ + return XXH_readLE64_align(ptr, endian, XXH_unaligned); +} //**************************** // Simple Hash Functions //**************************** -forceinline U32 XXH32_endian_align(const void* input, int len, U32 seed, XXH_endianess endian, XXH_alignment align) +FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align) { const BYTE* p = (const BYTE*)input; - const BYTE* const bEnd = p + len; + const BYTE* bEnd = p + len; U32 h32; +#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align) #ifdef XXH_ACCEPT_NULL_INPUT_POINTER - if (p==NULL) { len=0; p=(const BYTE*)(size_t)16; } + if (p==NULL) + { + len=0; + bEnd=p=(const BYTE*)(size_t)16; + } #endif if (len>=16) @@ -223,11 +276,24 @@ forceinline U32 XXH32_endian_align(const void* input, int len, U32 seed, XXH_end do { - v1 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v1 = XXH_rotl32(v1, 13); v1 *= PRIME32_1; p+=4; - v2 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v2 = XXH_rotl32(v2, 13); v2 *= PRIME32_1; p+=4; - v3 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v3 = XXH_rotl32(v3, 13); v3 *= PRIME32_1; p+=4; - v4 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v4 = XXH_rotl32(v4, 13); v4 *= PRIME32_1; p+=4; - } while (p<=limit); + v1 += XXH_get32bits(p) * PRIME32_2; + v1 = XXH_rotl32(v1, 13); + v1 *= PRIME32_1; + p+=4; + v2 += XXH_get32bits(p) * PRIME32_2; + v2 = XXH_rotl32(v2, 13); + v2 *= PRIME32_1; + p+=4; + v3 += XXH_get32bits(p) * PRIME32_2; + v3 = XXH_rotl32(v3, 13); + v3 *= PRIME32_1; + p+=4; + v4 += XXH_get32bits(p) * PRIME32_2; + v4 = XXH_rotl32(v4, 13); + v4 *= PRIME32_1; + p+=4; + } + while (p<=limit); h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18); } @@ -238,9 +304,9 @@ forceinline U32 XXH32_endian_align(const void* input, int len, U32 seed, XXH_end h32 += (U32) len; - while (p<=bEnd-4) + while (p+4<=bEnd) { - h32 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_3; + h32 += XXH_get32bits(p) * PRIME32_3; h32 = XXH_rotl32(h32, 17) * PRIME32_4 ; p+=4; } @@ -262,18 +328,19 @@ forceinline U32 XXH32_endian_align(const void* input, int len, U32 seed, XXH_end } -U32 XXH32(const void* input, int len, U32 seed) +unsigned int XXH32 (const void* input, size_t len, unsigned seed) { #if 0 // Simple version, good for code maintenance, but unfortunately slow for small inputs - void* state = XXH32_init(seed); - XXH32_update(state, input, len); - return XXH32_digest(state); + XXH32_state_t state; + XXH32_reset(&state, seed); + XXH32_update(&state, input, len); + return XXH32_digest(&state); #else XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; # if !defined(XXH_USE_UNALIGNED_ACCESS) - if (!(((size_t)input) & 3)) // Input is aligned, let's leverage the speed advantage + if ((((size_t)input) & 3) == 0) // Input is aligned, let's leverage the speed advantage { if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); @@ -289,12 +356,152 @@ U32 XXH32(const void* input, int len, U32 seed) #endif } +FORCE_INLINE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* bEnd = p + len; + U64 h64; +#define XXH_get64bits(p) XXH_readLE64_align(p, endian, align) -//**************************** -// Advanced Hash Functions -//**************************** +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (p==NULL) + { + len=0; + bEnd=p=(const BYTE*)(size_t)32; + } +#endif -struct XXH_state32_t + if (len>=32) + { + const BYTE* const limit = bEnd - 32; + U64 v1 = seed + PRIME64_1 + PRIME64_2; + U64 v2 = seed + PRIME64_2; + U64 v3 = seed + 0; + U64 v4 = seed - PRIME64_1; + + do + { + v1 += XXH_get64bits(p) * PRIME64_2; + p+=8; + v1 = XXH_rotl64(v1, 31); + v1 *= PRIME64_1; + v2 += XXH_get64bits(p) * PRIME64_2; + p+=8; + v2 = XXH_rotl64(v2, 31); + v2 *= PRIME64_1; + v3 += XXH_get64bits(p) * PRIME64_2; + p+=8; + v3 = XXH_rotl64(v3, 31); + v3 *= PRIME64_1; + v4 += XXH_get64bits(p) * PRIME64_2; + p+=8; + v4 = XXH_rotl64(v4, 31); + v4 *= PRIME64_1; + } + while (p<=limit); + + h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); + + v1 *= PRIME64_2; + v1 = XXH_rotl64(v1, 31); + v1 *= PRIME64_1; + h64 ^= v1; + h64 = h64 * PRIME64_1 + PRIME64_4; + + v2 *= PRIME64_2; + v2 = XXH_rotl64(v2, 31); + v2 *= PRIME64_1; + h64 ^= v2; + h64 = h64 * PRIME64_1 + PRIME64_4; + + v3 *= PRIME64_2; + v3 = XXH_rotl64(v3, 31); + v3 *= PRIME64_1; + h64 ^= v3; + h64 = h64 * PRIME64_1 + PRIME64_4; + + v4 *= PRIME64_2; + v4 = XXH_rotl64(v4, 31); + v4 *= PRIME64_1; + h64 ^= v4; + h64 = h64 * PRIME64_1 + PRIME64_4; + } + else + { + h64 = seed + PRIME64_5; + } + + h64 += (U64) len; + + while (p+8<=bEnd) + { + U64 k1 = XXH_get64bits(p); + k1 *= PRIME64_2; + k1 = XXH_rotl64(k1,31); + k1 *= PRIME64_1; + h64 ^= k1; + h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; + p+=8; + } + + if (p+4<=bEnd) + { + h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1; + h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; + p+=4; + } + + while (p> 33; + h64 *= PRIME64_2; + h64 ^= h64 >> 29; + h64 *= PRIME64_3; + h64 ^= h64 >> 32; + + return h64; +} + + +uint64_t XXH64 (const void* input, size_t len, uint64_t seed) +{ +#if 0 + // Simple version, good for code maintenance, but unfortunately slow for small inputs + XXH64_state_t state; + XXH64_reset(&state, seed); + XXH64_update(&state, input, len); + return XXH64_digest(&state); +#else + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + +# if !defined(XXH_USE_UNALIGNED_ACCESS) + if ((((size_t)input) & 7)==0) // Input is aligned, let's leverage the speed advantage + { + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); + else + return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned); + } +# endif + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned); + else + return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned); +#endif +} + +/**************************************************** + * Advanced Hash Functions +****************************************************/ + +/*** Allocation ***/ +typedef struct { U64 total_len; U32 seed; @@ -302,21 +509,60 @@ struct XXH_state32_t U32 v2; U32 v3; U32 v4; - int memsize; - char memory[16]; + U32 mem32[4]; /* defined as U32 for alignment */ + U32 memsize; +} XXH_istate32_t; + +typedef struct +{ + U64 total_len; + U64 seed; + U64 v1; + U64 v2; + U64 v3; + U64 v4; + U64 mem64[4]; /* defined as U64 for alignment */ + U32 memsize; +} XXH_istate64_t; + + +XXH32_state_t* XXH32_createState(void) +{ + XXH_STATIC_ASSERT(sizeof(XXH32_state_t) >= sizeof(XXH_istate32_t)); // A compilation error here means XXH32_state_t is not large enough + return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t)); +} + +void* XXH32_init (unsigned seed) +{ + XXH32_state_t *st = XXH32_createState(); + XXH32_reset(st, seed); + + return st; +} + +XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr) +{ + XXH_free(statePtr); + return XXH_OK; +}; + +XXH64_state_t* XXH64_createState(void) +{ + XXH_STATIC_ASSERT(sizeof(XXH64_state_t) >= sizeof(XXH_istate64_t)); // A compilation error here means XXH64_state_t is not large enough + return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t)); +} +XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr) +{ + XXH_free(statePtr); + return XXH_OK; }; -int XXH32_sizeofState(void) +/*** Hash feed ***/ + +XXH_errorcode XXH32_reset(XXH32_state_t* state_in, U32 seed) { - XXH_STATIC_ASSERT(XXH32_SIZEOFSTATE >= sizeof(struct XXH_state32_t)); // A compilation error here means XXH32_SIZEOFSTATE is not large enough - return sizeof(struct XXH_state32_t); -} - - -XXH_errorcode XXH32_resetState(void* state_in, U32 seed) -{ - struct XXH_state32_t * state = (struct XXH_state32_t *) state_in; + XXH_istate32_t* state = (XXH_istate32_t*) state_in; state->seed = seed; state->v1 = seed + PRIME32_1 + PRIME32_2; state->v2 = seed + PRIME32_2; @@ -327,18 +573,23 @@ XXH_errorcode XXH32_resetState(void* state_in, U32 seed) return XXH_OK; } - -void* XXH32_init (U32 seed) +XXH_errorcode XXH64_reset(XXH64_state_t* state_in, uint64_t seed) { - void* state = XXH_malloc (sizeof(struct XXH_state32_t)); - XXH32_resetState(state, seed); - return state; + XXH_istate64_t* state = (XXH_istate64_t*) state_in; + state->seed = seed; + state->v1 = seed + PRIME64_1 + PRIME64_2; + state->v2 = seed + PRIME64_2; + state->v3 = seed + 0; + state->v4 = seed - PRIME64_1; + state->total_len = 0; + state->memsize = 0; + return XXH_OK; } -forceinline XXH_errorcode XXH32_update_endian (void* state_in, const void* input, int len, XXH_endianess endian) +FORCE_INLINE XXH_errorcode XXH32_update_endian (XXH32_state_t* state_in, const void* input, size_t len, XXH_endianess endian) { - struct XXH_state32_t * state = (struct XXH_state32_t *) state_in; + XXH_istate32_t* state = (XXH_istate32_t *) state_in; const BYTE* p = (const BYTE*)input; const BYTE* const bEnd = p + len; @@ -350,20 +601,32 @@ forceinline XXH_errorcode XXH32_update_endian (void* state_in, const void* input if (state->memsize + len < 16) // fill in tmp buffer { - XXH_memcpy(state->memory + state->memsize, input, len); - state->memsize += len; + XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len); + state->memsize += (U32)len; return XXH_OK; } if (state->memsize) // some data left from previous update { - XXH_memcpy(state->memory + state->memsize, input, 16-state->memsize); + XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize); { - const U32* p32 = (const U32*)state->memory; - state->v1 += XXH_readLE32(p32, endian) * PRIME32_2; state->v1 = XXH_rotl32(state->v1, 13); state->v1 *= PRIME32_1; p32++; - state->v2 += XXH_readLE32(p32, endian) * PRIME32_2; state->v2 = XXH_rotl32(state->v2, 13); state->v2 *= PRIME32_1; p32++; - state->v3 += XXH_readLE32(p32, endian) * PRIME32_2; state->v3 = XXH_rotl32(state->v3, 13); state->v3 *= PRIME32_1; p32++; - state->v4 += XXH_readLE32(p32, endian) * PRIME32_2; state->v4 = XXH_rotl32(state->v4, 13); state->v4 *= PRIME32_1; p32++; + const U32* p32 = state->mem32; + state->v1 += XXH_readLE32(p32, endian) * PRIME32_2; + state->v1 = XXH_rotl32(state->v1, 13); + state->v1 *= PRIME32_1; + p32++; + state->v2 += XXH_readLE32(p32, endian) * PRIME32_2; + state->v2 = XXH_rotl32(state->v2, 13); + state->v2 *= PRIME32_1; + p32++; + state->v3 += XXH_readLE32(p32, endian) * PRIME32_2; + state->v3 = XXH_rotl32(state->v3, 13); + state->v3 *= PRIME32_1; + p32++; + state->v4 += XXH_readLE32(p32, endian) * PRIME32_2; + state->v4 = XXH_rotl32(state->v4, 13); + state->v4 *= PRIME32_1; + p32++; } p += 16-state->memsize; state->memsize = 0; @@ -379,11 +642,24 @@ forceinline XXH_errorcode XXH32_update_endian (void* state_in, const void* input do { - v1 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v1 = XXH_rotl32(v1, 13); v1 *= PRIME32_1; p+=4; - v2 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v2 = XXH_rotl32(v2, 13); v2 *= PRIME32_1; p+=4; - v3 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v3 = XXH_rotl32(v3, 13); v3 *= PRIME32_1; p+=4; - v4 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v4 = XXH_rotl32(v4, 13); v4 *= PRIME32_1; p+=4; - } while (p<=limit); + v1 += XXH_readLE32(p, endian) * PRIME32_2; + v1 = XXH_rotl32(v1, 13); + v1 *= PRIME32_1; + p+=4; + v2 += XXH_readLE32(p, endian) * PRIME32_2; + v2 = XXH_rotl32(v2, 13); + v2 *= PRIME32_1; + p+=4; + v3 += XXH_readLE32(p, endian) * PRIME32_2; + v3 = XXH_rotl32(v3, 13); + v3 *= PRIME32_1; + p+=4; + v4 += XXH_readLE32(p, endian) * PRIME32_2; + v4 = XXH_rotl32(v4, 13); + v4 *= PRIME32_1; + p+=4; + } + while (p<=limit); state->v1 = v1; state->v2 = v2; @@ -393,17 +669,17 @@ forceinline XXH_errorcode XXH32_update_endian (void* state_in, const void* input if (p < bEnd) { - XXH_memcpy(state->memory, p, bEnd-p); + XXH_memcpy(state->mem32, p, bEnd-p); state->memsize = (int)(bEnd-p); } return XXH_OK; } -XXH_errorcode XXH32_update (void* state_in, const void* input, int len) +XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* input, size_t len) { XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; - + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) return XXH32_update_endian(state_in, input, len, XXH_littleEndian); else @@ -412,11 +688,11 @@ XXH_errorcode XXH32_update (void* state_in, const void* input, int len) -forceinline U32 XXH32_intermediateDigest_endian (void* state_in, XXH_endianess endian) +FORCE_INLINE U32 XXH32_digest_endian (const XXH32_state_t* state_in, XXH_endianess endian) { - struct XXH_state32_t * state = (struct XXH_state32_t *) state_in; - const BYTE * p = (const BYTE*)state->memory; - BYTE* bEnd = (BYTE*)state->memory + state->memsize; + XXH_istate32_t* state = (XXH_istate32_t*) state_in; + const BYTE * p = (const BYTE*)state->mem32; + BYTE* bEnd = (BYTE*)(state->mem32) + state->memsize; U32 h32; if (state->total_len >= 16) @@ -430,9 +706,9 @@ forceinline U32 XXH32_intermediateDigest_endian (void* state_in, XXH_endianess e h32 += (U32) state->total_len; - while (p<=bEnd-4) + while (p+4<=bEnd) { - h32 += XXH_readLE32((const U32*)p, endian) * PRIME32_3; + h32 += XXH_readLE32(p, endian) * PRIME32_3; h32 = XXH_rotl32(h32, 17) * PRIME32_4; p+=4; } @@ -449,27 +725,217 @@ forceinline U32 XXH32_intermediateDigest_endian (void* state_in, XXH_endianess e h32 ^= h32 >> 13; h32 *= PRIME32_3; h32 ^= h32 >> 16; - +#if 0 + XXH32_freeState((XXH32_state_t *)state_in); +#endif return h32; } -U32 XXH32_intermediateDigest (void* state_in) +U32 XXH32_digest (const XXH32_state_t* state_in) { XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; - + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) - return XXH32_intermediateDigest_endian(state_in, XXH_littleEndian); + return XXH32_digest_endian(state_in, XXH_littleEndian); else - return XXH32_intermediateDigest_endian(state_in, XXH_bigEndian); + return XXH32_digest_endian(state_in, XXH_bigEndian); } -U32 XXH32_digest (void* state_in) +FORCE_INLINE XXH_errorcode XXH64_update_endian (XXH64_state_t* state_in, const void* input, size_t len, XXH_endianess endian) { - U32 h32 = XXH32_intermediateDigest(state_in); + XXH_istate64_t * state = (XXH_istate64_t *) state_in; + const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; - XXH_free(state_in); +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (input==NULL) return XXH_ERROR; +#endif - return h32; + state->total_len += len; + + if (state->memsize + len < 32) // fill in tmp buffer + { + XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len); + state->memsize += (U32)len; + return XXH_OK; + } + + if (state->memsize) // some data left from previous update + { + XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, 32-state->memsize); + { + const U64* p64 = state->mem64; + state->v1 += XXH_readLE64(p64, endian) * PRIME64_2; + state->v1 = XXH_rotl64(state->v1, 31); + state->v1 *= PRIME64_1; + p64++; + state->v2 += XXH_readLE64(p64, endian) * PRIME64_2; + state->v2 = XXH_rotl64(state->v2, 31); + state->v2 *= PRIME64_1; + p64++; + state->v3 += XXH_readLE64(p64, endian) * PRIME64_2; + state->v3 = XXH_rotl64(state->v3, 31); + state->v3 *= PRIME64_1; + p64++; + state->v4 += XXH_readLE64(p64, endian) * PRIME64_2; + state->v4 = XXH_rotl64(state->v4, 31); + state->v4 *= PRIME64_1; + p64++; + } + p += 32-state->memsize; + state->memsize = 0; + } + + if (p+32 <= bEnd) + { + const BYTE* const limit = bEnd - 32; + U64 v1 = state->v1; + U64 v2 = state->v2; + U64 v3 = state->v3; + U64 v4 = state->v4; + + do + { + v1 += XXH_readLE64(p, endian) * PRIME64_2; + v1 = XXH_rotl64(v1, 31); + v1 *= PRIME64_1; + p+=8; + v2 += XXH_readLE64(p, endian) * PRIME64_2; + v2 = XXH_rotl64(v2, 31); + v2 *= PRIME64_1; + p+=8; + v3 += XXH_readLE64(p, endian) * PRIME64_2; + v3 = XXH_rotl64(v3, 31); + v3 *= PRIME64_1; + p+=8; + v4 += XXH_readLE64(p, endian) * PRIME64_2; + v4 = XXH_rotl64(v4, 31); + v4 *= PRIME64_1; + p+=8; + } + while (p<=limit); + + state->v1 = v1; + state->v2 = v2; + state->v3 = v3; + state->v4 = v4; + } + + if (p < bEnd) + { + XXH_memcpy(state->mem64, p, bEnd-p); + state->memsize = (int)(bEnd-p); + } + + return XXH_OK; } + +XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* input, size_t len) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_update_endian(state_in, input, len, XXH_littleEndian); + else + return XXH64_update_endian(state_in, input, len, XXH_bigEndian); +} + + + +FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state_in, XXH_endianess endian) +{ + XXH_istate64_t * state = (XXH_istate64_t *) state_in; + const BYTE * p = (const BYTE*)state->mem64; + BYTE* bEnd = (BYTE*)state->mem64 + state->memsize; + U64 h64; + + if (state->total_len >= 32) + { + U64 v1 = state->v1; + U64 v2 = state->v2; + U64 v3 = state->v3; + U64 v4 = state->v4; + + h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); + + v1 *= PRIME64_2; + v1 = XXH_rotl64(v1, 31); + v1 *= PRIME64_1; + h64 ^= v1; + h64 = h64*PRIME64_1 + PRIME64_4; + + v2 *= PRIME64_2; + v2 = XXH_rotl64(v2, 31); + v2 *= PRIME64_1; + h64 ^= v2; + h64 = h64*PRIME64_1 + PRIME64_4; + + v3 *= PRIME64_2; + v3 = XXH_rotl64(v3, 31); + v3 *= PRIME64_1; + h64 ^= v3; + h64 = h64*PRIME64_1 + PRIME64_4; + + v4 *= PRIME64_2; + v4 = XXH_rotl64(v4, 31); + v4 *= PRIME64_1; + h64 ^= v4; + h64 = h64*PRIME64_1 + PRIME64_4; + } + else + { + h64 = state->seed + PRIME64_5; + } + + h64 += (U64) state->total_len; + + while (p+8<=bEnd) + { + U64 k1 = XXH_readLE64(p, endian); + k1 *= PRIME64_2; + k1 = XXH_rotl64(k1,31); + k1 *= PRIME64_1; + h64 ^= k1; + h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; + p+=8; + } + + if (p+4<=bEnd) + { + h64 ^= (U64)(XXH_readLE32(p, endian)) * PRIME64_1; + h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; + p+=4; + } + + while (p> 33; + h64 *= PRIME64_2; + h64 ^= h64 >> 29; + h64 *= PRIME64_3; + h64 ^= h64 >> 32; +#if 0 + XXH64_freeState((XXH64_state_t *)state_in); +#endif + return h64; +} + + +uint64_t XXH64_digest (const XXH64_state_t* state_in) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_digest_endian(state_in, XXH_littleEndian); + else + return XXH64_digest_endian(state_in, XXH_bigEndian); +} + + diff --git a/contrib/libucl/src/xxhash.h b/contrib/libucl/src/xxhash.h index b89238883e23..49b0239071e3 100644 --- a/contrib/libucl/src/xxhash.h +++ b/contrib/libucl/src/xxhash.h @@ -1,20 +1,20 @@ /* - xxHash - Fast Hash algorithm + xxHash - Extremely Fast Hash algorithm Header File - Copyright (C) 2012-2013, Yann Collet. + Copyright (C) 2012-2014, Yann Collet. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -52,113 +52,114 @@ CRC32 0.43 GB/s 9 MD5-32 0.33 GB/s 10 Ronald L. Rivest SHA1-32 0.28 GB/s 10 -Q.Score is a measure of quality of the hash function. -It depends on successfully passing SMHasher test set. +Q.Score is a measure of quality of the hash function. +It depends on successfully passing SMHasher test set. 10 is a perfect score. */ - -#pragma once +#ifndef LIBUCL_XXHASH_H +#define LIBUCL_XXHASH_H #if defined (__cplusplus) extern "C" { #endif -//**************************** -// Type -//**************************** +/***************************** + Includes +*****************************/ +#include /* size_t */ +#include + + +/***************************** + Type +*****************************/ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; -//**************************** -// Simple Hash Functions -//**************************** +/***************************** + Simple Hash Functions +*****************************/ -unsigned int XXH32 (const void* input, int len, unsigned int seed); +unsigned int XXH32 (const void* input, size_t length, unsigned seed); +uint64_t XXH64 (const void* input, size_t length, uint64_t seed); /* XXH32() : - Calculate the 32-bits hash of sequence of length "len" stored at memory address "input". - The memory between input & input+len must be valid (allocated and read-accessible). + Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input". + The memory between input & input+length must be valid (allocated and read-accessible). "seed" can be used to alter the result predictably. This function successfully passes all SMHasher tests. Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s - Note that "len" is type "int", which means it is limited to 2^31-1. - If your data is larger, use the advanced functions below. +XXH64() : + Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". */ -//**************************** -// Advanced Hash Functions -//**************************** - -void* XXH32_init (unsigned int seed); -XXH_errorcode XXH32_update (void* state, const void* input, int len); -unsigned int XXH32_digest (void* state); +/***************************** + Advanced Hash Functions +*****************************/ +typedef struct { int64_t ll[ 6]; } XXH32_state_t; +typedef struct { int64_t ll[11]; } XXH64_state_t; /* -These functions calculate the xxhash of an input provided in several small packets, +These structures allow static allocation of XXH states. +States must then be initialized using XXHnn_reset() before first use. + +If you prefer dynamic allocation, please refer to functions below. +*/ + +/* + * !!! + * Rspamd specific: we use the legacy method to free state when digest is obtained + * !!! + */ +void * XXH32_init (unsigned seed); +XXH32_state_t* XXH32_createState(void); +XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr); + +XXH64_state_t* XXH64_createState(void); +XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); + +/* +These functions create and release memory for XXH state. +States must then be initialized using XXHnn_reset() before first use. +*/ + + +XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned seed); +XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length); +unsigned int XXH32_digest (const XXH32_state_t* statePtr); + +XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, uint64_t seed); +XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); +uint64_t XXH64_digest (const XXH64_state_t* statePtr); + +/* +These functions calculate the xxHash of an input provided in multiple smaller packets, as opposed to an input provided as a single block. -It must be started with : -void* XXH32_init() -The function returns a pointer which holds the state of calculation. +XXH state space must first be allocated, using either static or dynamic method provided above. -This pointer must be provided as "void* state" parameter for XXH32_update(). -XXH32_update() can be called as many times as necessary. -The user must provide a valid (allocated) input. +Start a new hash by initializing state with a seed, using XXHnn_reset(). + +Then, feed the hash state by calling XXHnn_update() as many times as necessary. +Obviously, input must be valid, meaning allocated and read accessible. The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. -Note that "len" is type "int", which means it is limited to 2^31-1. -If your data is larger, it is recommended to chunk your data into blocks -of size for example 2^30 (1GB) to avoid any "int" overflow issue. -Finally, you can end the calculation anytime, by using XXH32_digest(). -This function returns the final 32-bits hash. -You must provide the same "void* state" parameter created by XXH32_init(). -Memory will be freed by XXH32_digest(). +Finally, you can produce a hash anytime, by using XXHnn_digest(). +This function returns the final nn-bits hash. +You can nonetheless continue feeding the hash state with more input, +and therefore get some new hashes, by calling again XXHnn_digest(). + +When you are done, don't forget to free XXH state space, using typically XXHnn_freeState(). */ -int XXH32_sizeofState(void); -XXH_errorcode XXH32_resetState(void* state, unsigned int seed); - -#define XXH32_SIZEOFSTATE 48 -typedef struct { long long ll[(XXH32_SIZEOFSTATE+(sizeof(long long)-1))/sizeof(long long)]; } XXH32_stateSpace_t; -/* -These functions allow user application to make its own allocation for state. - -XXH32_sizeofState() is used to know how much space must be allocated for the xxHash 32-bits state. -Note that the state must be aligned to access 'long long' fields. Memory must be allocated and referenced by a pointer. -This pointer must then be provided as 'state' into XXH32_resetState(), which initializes the state. - -For static allocation purposes (such as allocation on stack, or freestanding systems without malloc()), -use the structure XXH32_stateSpace_t, which will ensure that memory space is large enough and correctly aligned to access 'long long' fields. -*/ - - -unsigned int XXH32_intermediateDigest (void* state); -/* -This function does the same as XXH32_digest(), generating a 32-bit hash, -but preserve memory context. -This way, it becomes possible to generate intermediate hashes, and then continue feeding data with XXH32_update(). -To free memory context, use XXH32_digest(), or free(). -*/ - - - -//**************************** -// Deprecated function names -//**************************** -// The following translations are provided to ease code transition -// You are encouraged to no longer this function names -#define XXH32_feed XXH32_update -#define XXH32_result XXH32_digest -#define XXH32_getIntermediateResult XXH32_intermediateDigest - - - #if defined (__cplusplus) } #endif + +#endif diff --git a/contrib/libucl/tests/Makefile.am b/contrib/libucl/tests/Makefile.am index 5b17e1fb252e..055eb8bd85b0 100644 --- a/contrib/libucl/tests/Makefile.am +++ b/contrib/libucl/tests/Makefile.am @@ -1,10 +1,12 @@ -EXTRA_DIST = $(TESTS) basic schema generate.res streamline.res rcl_test.json.xz +EXTRA_DIST = $(TESTS) basic schema generate.res \ + streamline.res rcl_test.json.xz TESTS = basic.test \ generate.test \ schema.test \ + msgpack.test \ speed.test \ - streamline.test + msgpack.test TESTS_ENVIRONMENT = $(SH) \ TEST_DIR=$(top_srcdir)/tests \ TEST_OUT_DIR=$(top_builddir)/tests \ @@ -35,4 +37,9 @@ test_streamline_SOURCES = test_streamline.c test_streamline_LDADD = $(common_test_ldadd) test_streamline_CFLAGS = $(common_test_cflags) -check_PROGRAMS = test_basic test_speed test_generate test_schema test_streamline \ No newline at end of file +test_msgpack_SOURCES = test_msgpack.c +test_msgpack_LDADD = $(common_test_ldadd) +test_msgpack_CFLAGS = $(common_test_cflags) + +check_PROGRAMS = test_basic test_speed test_generate test_schema test_streamline \ + test_msgpack \ No newline at end of file diff --git a/contrib/libucl/tests/basic/13.in b/contrib/libucl/tests/basic/13.in index 81f03a61d286..6e31e9c4b17f 100644 --- a/contrib/libucl/tests/basic/13.in +++ b/contrib/libucl/tests/basic/13.in @@ -1,7 +1,7 @@ key = value_orig; # test glob -.include(glob=true) "${CURDIR}/include_dir/test*.conf" +.include(glob=true,something="test") "${CURDIR}/include_dir/test*.conf" .include(priority=1) "${CURDIR}/include_dir/pri1.conf" .include(priority=2) "${CURDIR}/include_dir/pri2.conf" diff --git a/contrib/libucl/tests/basic/15.in b/contrib/libucl/tests/basic/15.in new file mode 100644 index 000000000000..1329b8c7c130 --- /dev/null +++ b/contrib/libucl/tests/basic/15.in @@ -0,0 +1,24 @@ +# In this test we test include override bug + +.include(priority = 1) "${CURDIR}/15.inc" + +section = { + value = "test"; +} + +overrided = { + value = "not-to-be-shown"; +} + +/* + BUGGED UCL: + overrided { + key = "overrided"; + } + !!! So overrided has actually rewritten the previous key + section { + value { + value = "not-to-be-shown"; + } + } +*/ diff --git a/contrib/libucl/tests/basic/15.inc b/contrib/libucl/tests/basic/15.inc new file mode 100644 index 000000000000..a9ab027351e6 --- /dev/null +++ b/contrib/libucl/tests/basic/15.inc @@ -0,0 +1,3 @@ +overrided { + key = "overrided"; +} diff --git a/contrib/libucl/tests/basic/15.res b/contrib/libucl/tests/basic/15.res new file mode 100644 index 000000000000..b6b4e2656d6d --- /dev/null +++ b/contrib/libucl/tests/basic/15.res @@ -0,0 +1,7 @@ +overrided { + key = "overrided"; +} +section { + value = "test"; +} + diff --git a/contrib/libucl/tests/basic/16.in b/contrib/libucl/tests/basic/16.in new file mode 100644 index 000000000000..07122528a32e --- /dev/null +++ b/contrib/libucl/tests/basic/16.in @@ -0,0 +1,12 @@ +.include(priority = 1) "${CURDIR}/16.inc" + +section = { + value = "test"; +} + +overrided = { + value = "not-to-be-shown"; +} +overrided = { + value2 = "implicit-array"; +} diff --git a/contrib/libucl/tests/basic/16.inc b/contrib/libucl/tests/basic/16.inc new file mode 100644 index 000000000000..34b6085c3fac --- /dev/null +++ b/contrib/libucl/tests/basic/16.inc @@ -0,0 +1,3 @@ +overrided { + key = "overrided"; +} diff --git a/contrib/libucl/tests/basic/16.res b/contrib/libucl/tests/basic/16.res new file mode 100644 index 000000000000..b6b4e2656d6d --- /dev/null +++ b/contrib/libucl/tests/basic/16.res @@ -0,0 +1,7 @@ +overrided { + key = "overrided"; +} +section { + value = "test"; +} + diff --git a/contrib/libucl/tests/basic/17.in b/contrib/libucl/tests/basic/17.in new file mode 100644 index 000000000000..bae66fb32eca --- /dev/null +++ b/contrib/libucl/tests/basic/17.in @@ -0,0 +1,2 @@ +# issue 74 +string that ends in slash\ \ No newline at end of file diff --git a/contrib/libucl/tests/basic/17.res b/contrib/libucl/tests/basic/17.res new file mode 100644 index 000000000000..9870b04035a9 --- /dev/null +++ b/contrib/libucl/tests/basic/17.res @@ -0,0 +1,2 @@ +string = "that ends in slash\\"; + diff --git a/contrib/libucl/tests/basic/18.in b/contrib/libucl/tests/basic/18.in new file mode 100644 index 000000000000..bd12c019859a --- /dev/null +++ b/contrib/libucl/tests/basic/18.in @@ -0,0 +1,10 @@ +defaults { + key = "val" + foo = "bar" + many = "values here" +} + +mything { + .inherit "defaults" + key = "newval" +} diff --git a/contrib/libucl/tests/basic/18.res b/contrib/libucl/tests/basic/18.res new file mode 100644 index 000000000000..a6272d508ac5 --- /dev/null +++ b/contrib/libucl/tests/basic/18.res @@ -0,0 +1,11 @@ +defaults { + key = "val"; + foo = "bar"; + many = "values here"; +} +mything { + key = "newval"; + foo = "bar"; + many = "values here"; +} + diff --git a/contrib/libucl/tests/basic/19-append.inc b/contrib/libucl/tests/basic/19-append.inc new file mode 100644 index 000000000000..909dfceb951c --- /dev/null +++ b/contrib/libucl/tests/basic/19-append.inc @@ -0,0 +1,8 @@ +okey_append = { + key = value1; + key1 = value2 +} + +akey_append = ["value3"]; + +skey_append = "value4"; diff --git a/contrib/libucl/tests/basic/19-merge.inc b/contrib/libucl/tests/basic/19-merge.inc new file mode 100644 index 000000000000..46deccbf7254 --- /dev/null +++ b/contrib/libucl/tests/basic/19-merge.inc @@ -0,0 +1,8 @@ +okey_merge = { + key = value1; + key1 = value2; +} + +akey_merge = ["value3"]; + +skey_merge = "value4"; diff --git a/contrib/libucl/tests/basic/19-rewrite.inc b/contrib/libucl/tests/basic/19-rewrite.inc new file mode 100644 index 000000000000..5a7094b0592d --- /dev/null +++ b/contrib/libucl/tests/basic/19-rewrite.inc @@ -0,0 +1,8 @@ +okey_rewrite = { + key = value1; + key1 = value2; +} + +akey_rewrite = ["value3"]; + +skey_rewrite = "value4"; diff --git a/contrib/libucl/tests/basic/19.in b/contrib/libucl/tests/basic/19.in new file mode 100644 index 000000000000..717aed819262 --- /dev/null +++ b/contrib/libucl/tests/basic/19.in @@ -0,0 +1,28 @@ +okey_append = { + key = value; +} + +akey_append = ["value"]; + +skey_append = "value"; + +okey_merge = { + key = value; + source = original; +} + +akey_merge = ["value"]; + +skey_merge = "value"; + +okey_rewrite = { + key = value; +} + +akey_rewrite = ["value"]; + +skey_rewrite = "value"; + +.include(duplicate="append") "${CURDIR}/19-append.inc" +.include(duplicate="merge") "${CURDIR}/19-merge.inc" +.include(duplicate="rewrite") "${CURDIR}/19-rewrite.inc" diff --git a/contrib/libucl/tests/basic/19.res b/contrib/libucl/tests/basic/19.res new file mode 100644 index 000000000000..ca7bc4106115 --- /dev/null +++ b/contrib/libucl/tests/basic/19.res @@ -0,0 +1,36 @@ +okey_append { + key = "value"; +} +okey_append { + key = "value1"; + key1 = "value2"; +} +akey_append [ + "value", +] +akey_append [ + "value3", +] +skey_append = "value"; +skey_append = "value4"; +okey_merge { + key = "value"; + key = "value1"; + source = "original"; + key1 = "value2"; +} +akey_merge [ + "value", + "value3", +] +skey_merge = "value"; +skey_merge = "value4"; +okey_rewrite { + key = "value1"; + key1 = "value2"; +} +akey_rewrite [ + "value3", +] +skey_rewrite = "value4"; + diff --git a/contrib/libucl/tests/basic/20.in b/contrib/libucl/tests/basic/20.in new file mode 100644 index 000000000000..f9d4088fc20c --- /dev/null +++ b/contrib/libucl/tests/basic/20.in @@ -0,0 +1,2 @@ +# issue 112 +[[0 \ No newline at end of file diff --git a/contrib/libucl/tests/basic/20.res b/contrib/libucl/tests/basic/20.res new file mode 100644 index 000000000000..abfbbf02cfe6 --- /dev/null +++ b/contrib/libucl/tests/basic/20.res @@ -0,0 +1,5 @@ +[ + [ + 0, + ] +] diff --git a/contrib/libucl/tests/basic/21.in b/contrib/libucl/tests/basic/21.in new file mode 100644 index 000000000000..8f4b328548bb --- /dev/null +++ b/contrib/libucl/tests/basic/21.in @@ -0,0 +1,2 @@ + [9 +{0 [[0 \ No newline at end of file diff --git a/contrib/libucl/tests/basic/21.res b/contrib/libucl/tests/basic/21.res new file mode 100644 index 000000000000..db091ce39354 --- /dev/null +++ b/contrib/libucl/tests/basic/21.res @@ -0,0 +1,10 @@ +[ + 9, + { + 0 [ + [ + 0, + ] + ] + } +] diff --git a/contrib/libucl/tests/basic/22.in b/contrib/libucl/tests/basic/22.in new file mode 100644 index 000000000000..244cea0b0c73 --- /dev/null +++ b/contrib/libucl/tests/basic/22.in @@ -0,0 +1,2 @@ +# issue 113 +ÿ=1 \ No newline at end of file diff --git a/contrib/libucl/tests/basic/22.res b/contrib/libucl/tests/basic/22.res new file mode 100644 index 000000000000..d4bf94d896a1 --- /dev/null +++ b/contrib/libucl/tests/basic/22.res @@ -0,0 +1,2 @@ +ÿ = 1; + diff --git a/contrib/libucl/tests/msgpack.test b/contrib/libucl/tests/msgpack.test new file mode 100755 index 000000000000..67a3c9359b1b --- /dev/null +++ b/contrib/libucl/tests/msgpack.test @@ -0,0 +1,3 @@ +#!/bin/sh + +${TEST_BINARY_DIR}/test_msgpack \ No newline at end of file diff --git a/contrib/libucl/tests/test_basic.c b/contrib/libucl/tests/test_basic.c index 5859c0ba6eb7..45a9c8b2bc6a 100644 --- a/contrib/libucl/tests/test_basic.c +++ b/contrib/libucl/tests/test_basic.c @@ -27,13 +27,14 @@ int main (int argc, char **argv) { - char inbuf[8192], *test_in = NULL; + char *inbuf; struct ucl_parser *parser = NULL, *parser2 = NULL; ucl_object_t *obj; + ssize_t bufsize, r; FILE *in, *out; unsigned char *emitted = NULL; const char *fname_in = NULL, *fname_out = NULL; - int ret = 0, inlen, opt, json = 0, compact = 0, yaml = 0; + int ret = 0, opt, json = 0, compact = 0, yaml = 0; while ((opt = getopt(argc, argv, "jcy")) != -1) { switch (opt) { @@ -82,16 +83,28 @@ main (int argc, char **argv) ucl_parser_set_filevars (parser, fname_in, true); } - while (!feof (in)) { - memset (inbuf, 0, sizeof (inbuf)); - if (fread (inbuf, 1, sizeof (inbuf) - 1, in) == 0) { - break; + inbuf = malloc (BUFSIZ); + bufsize = BUFSIZ; + r = 0; + + while (!feof (in) && !ferror (in)) { + if (r == bufsize) { + inbuf = realloc (inbuf, bufsize * 2); + bufsize *= 2; + if (inbuf == NULL) { + perror ("realloc"); + exit (EXIT_FAILURE); + } } - inlen = strlen (inbuf); - test_in = malloc (inlen); - memcpy (test_in, inbuf, inlen); - ucl_parser_add_chunk (parser, (const unsigned char *)test_in, inlen); + r += fread (inbuf + r, 1, bufsize - r, in); } + + if (ferror (in)) { + fprintf (stderr, "Failed to read the input file.\n"); + exit (EXIT_FAILURE); + } + + ucl_parser_add_chunk (parser, (const unsigned char *)inbuf, r); fclose (in); if (fname_out != NULL) { @@ -103,12 +116,15 @@ main (int argc, char **argv) else { out = stdout; } + if (ucl_parser_get_error (parser) != NULL) { fprintf (out, "Error occurred: %s\n", ucl_parser_get_error(parser)); ret = 1; goto end; } + obj = ucl_parser_get_object (parser); + if (json) { if (compact) { emitted = ucl_object_emit (obj, UCL_EMIT_JSON_COMPACT); @@ -123,6 +139,7 @@ main (int argc, char **argv) else { emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG); } + ucl_parser_free (parser); ucl_object_unref (obj); parser2 = ucl_parser_new (UCL_PARSER_KEY_LOWERCASE); @@ -134,9 +151,11 @@ main (int argc, char **argv) ret = 1; goto end; } + if (emitted != NULL) { free (emitted); } + obj = ucl_parser_get_object (parser2); if (json) { if (compact) { @@ -163,8 +182,8 @@ main (int argc, char **argv) if (parser2 != NULL) { ucl_parser_free (parser2); } - if (test_in != NULL) { - free (test_in); + if (inbuf != NULL) { + free (inbuf); } fclose (out); diff --git a/contrib/libucl/tests/test_msgpack.c b/contrib/libucl/tests/test_msgpack.c new file mode 100644 index 000000000000..dd5860e9828b --- /dev/null +++ b/contrib/libucl/tests/test_msgpack.c @@ -0,0 +1,340 @@ +/* + * Copyright (c) 2015, Vsevolod Stakhov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ucl.h" +#include "ucl_internal.h" +#include + +static const int niter = 1000; +static const int ntests = 100; +static const int nelt = 10; + +static int recursion = 0; + +typedef ucl_object_t* (*ucl_msgpack_test)(void); + +static ucl_object_t* ucl_test_integer (void); +static ucl_object_t* ucl_test_string (void); +static ucl_object_t* ucl_test_boolean (void); +static ucl_object_t* ucl_test_map (void); +static ucl_object_t* ucl_test_array (void); + +ucl_msgpack_test tests[] = { + ucl_test_integer, + ucl_test_string, + ucl_test_boolean, + ucl_test_map, + ucl_test_array, +}; + +#define NTESTS (sizeof(tests) / sizeof(tests[0])) + +typedef struct +{ + uint64_t state; + uint64_t inc; +} pcg32_random_t; + +pcg32_random_t rng; + +/* + * From http://www.pcg-random.org/ + */ +static uint32_t +pcg32_random (void) +{ + uint64_t oldstate = rng.state; + + rng.state = oldstate * 6364136223846793005ULL + (rng.inc | 1); + uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u; + uint32_t rot = oldstate >> 59u; + return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); +} + +static const char * +random_key (size_t *lenptr) +{ + static char keybuf[512]; + int keylen, i; + char c; + + keylen = pcg32_random () % (sizeof (keybuf) - 1) + 1; + + for (i = 0; i < keylen; i ++) { + do { + c = pcg32_random () & 0xFF; + } while (!isgraph (c)); + + keybuf[i] = c; + } + + *lenptr = keylen; + return keybuf; +} + +int +main (int argc, char **argv) +{ + int fd, i, j; + uint32_t sel; + ucl_object_t *obj, *elt; + struct ucl_parser *parser; + size_t klen, elen, elen2; + const char *key; + unsigned char *emitted, *emitted2; + FILE *out; + const char *fname_out = NULL; + + switch (argc) { + case 2: + fname_out = argv[1]; + break; + } + + /* Seed prng */ + fd = open ("/dev/urandom", O_RDONLY); + assert (fd != -1); + assert (read (fd, &rng, sizeof (rng)) == sizeof (rng)); + close (fd); + + for (i = 0; i < niter; i ++) { + if (fname_out != NULL) { + out = fopen (fname_out, "w"); + if (out == NULL) { + exit (-errno); + } + } + else { + out = NULL; + } + + /* Generate phase */ + obj = ucl_object_typed_new (UCL_OBJECT); + + for (j = 0; j < ntests; j ++) { + sel = pcg32_random () % NTESTS; + + key = random_key (&klen); + recursion = 0; + elt = tests[sel](); + assert (elt != NULL); + assert (klen != 0); + + ucl_object_insert_key (obj, elt, key, klen, true); + } + + emitted = ucl_object_emit_len (obj, UCL_EMIT_MSGPACK, &elen); + + assert (emitted != NULL); + + if (out) { + fprintf (out, "%*.s\n", (int)elen, emitted); + + fclose (out); + } + ucl_object_unref (obj); + + parser = ucl_parser_new (0); + + if (!ucl_parser_add_chunk_full (parser, emitted, elen, 0, + UCL_DUPLICATE_APPEND, UCL_PARSE_MSGPACK)) { + fprintf (stderr, "error parsing input: %s", + ucl_parser_get_error (parser)); + assert (0); + } + + obj = ucl_parser_get_object (parser); + assert (obj != NULL); + + emitted2 = ucl_object_emit_len (obj, UCL_EMIT_MSGPACK, &elen2); + + assert (emitted2 != NULL); + assert (elen2 == elen); + assert (memcmp (emitted, emitted2, elen) == 0); + + ucl_parser_free (parser); + ucl_object_unref (obj); + free (emitted); + free (emitted2); + } + + return 0; +} + + +static ucl_object_t* +ucl_test_integer (void) +{ + ucl_object_t *res; + int count, i; + uint64_t cur; + + res = ucl_object_typed_new (UCL_ARRAY); + count = pcg32_random () % nelt; + + for (i = 0; i < count; i ++) { + cur = ((uint64_t)pcg32_random ()) << 32 | pcg32_random (); + ucl_array_append (res, ucl_object_fromint (cur % 128)); + cur = ((uint64_t)pcg32_random ()) << 32 | pcg32_random (); + ucl_array_append (res, ucl_object_fromint (-cur % 128)); + cur = ((uint64_t)pcg32_random ()) << 32 | pcg32_random (); + ucl_array_append (res, ucl_object_fromint (cur % 65536)); + cur = ((uint64_t)pcg32_random ()) << 32 | pcg32_random (); + ucl_array_append (res, ucl_object_fromint (cur % INT32_MAX)); + cur = ((uint64_t)pcg32_random ()) << 32 | pcg32_random (); + ucl_array_append (res, ucl_object_fromint (cur)); + } + + return res; +} + +static ucl_object_t* +ucl_test_string (void) +{ + ucl_object_t *res, *elt; + int count, i; + uint32_t cur_len; + char *str; + + res = ucl_object_typed_new (UCL_ARRAY); + count = pcg32_random () % nelt; + + for (i = 0; i < count; i ++) { + while ((cur_len = pcg32_random ()) % 128 == 0); + + str = malloc (cur_len % 128); + ucl_array_append (res, ucl_object_fromstring_common (str, cur_len % 128, + UCL_STRING_RAW)); + free (str); + + while ((cur_len = pcg32_random ()) % 512 == 0); + str = malloc (cur_len % 512); + ucl_array_append (res, ucl_object_fromstring_common (str, cur_len % 512, + UCL_STRING_RAW)); + free (str); + + while ((cur_len = pcg32_random ()) % 128 == 0); + str = malloc (cur_len % 128); + elt = ucl_object_fromstring_common (str, cur_len % 128, + UCL_STRING_RAW); + elt->flags |= UCL_OBJECT_BINARY; + ucl_array_append (res, elt); + free (str); + + while ((cur_len = pcg32_random ()) % 512 == 0); + str = malloc (cur_len % 512); + elt = ucl_object_fromstring_common (str, cur_len % 512, + UCL_STRING_RAW); + elt->flags |= UCL_OBJECT_BINARY; + ucl_array_append (res, elt); + free (str); + } + + return res; +} + +static ucl_object_t* +ucl_test_boolean (void) +{ + ucl_object_t *res; + int count, i; + + res = ucl_object_typed_new (UCL_ARRAY); + count = pcg32_random () % nelt; + + for (i = 0; i < count; i ++) { + ucl_array_append (res, ucl_object_frombool (pcg32_random () % 2)); + } + + return res; +} + +static ucl_object_t* +ucl_test_map (void) +{ + ucl_object_t *res, *cur; + int count, i; + uint32_t cur_len, sel; + size_t klen; + const char *key; + + res = ucl_object_typed_new (UCL_OBJECT); + count = pcg32_random () % nelt; + + recursion ++; + + for (i = 0; i < count; i ++) { + + if (recursion > 10) { + sel = pcg32_random () % (NTESTS - 2); + } + else { + sel = pcg32_random () % NTESTS; + } + + key = random_key (&klen); + cur = tests[sel](); + assert (cur != NULL); + assert (klen != 0); + + ucl_object_insert_key (res, cur, key, klen, true); + + /* Multi value key */ + cur = tests[sel](); + assert (cur != NULL); + + ucl_object_insert_key (res, cur, key, klen, true); + } + + return res; +} + +static ucl_object_t* +ucl_test_array (void) +{ + ucl_object_t *res, *cur; + int count, i; + uint32_t cur_len, sel; + + res = ucl_object_typed_new (UCL_ARRAY); + count = pcg32_random () % nelt; + + recursion ++; + + for (i = 0; i < count; i ++) { + if (recursion > 10) { + sel = pcg32_random () % (NTESTS - 2); + } + else { + sel = pcg32_random () % NTESTS; + } + + cur = tests[sel](); + assert (cur != NULL); + + ucl_array_append (res, cur); + } + + return res; +} diff --git a/contrib/libucl/tests/test_schema.c b/contrib/libucl/tests/test_schema.c index 4f075dae8d68..39eb7f399125 100644 --- a/contrib/libucl/tests/test_schema.c +++ b/contrib/libucl/tests/test_schema.c @@ -40,20 +40,24 @@ read_stdin (char **buf) p = *buf; remain = size; - while ((ret = read (STDIN_FILENO, p, remain)) > 0) { + while ((ret = read (STDIN_FILENO, p, remain - 1)) > 0) { remain -= ret; p += ret; - if (remain == 0) { + + if (remain <= 1) { *buf = realloc (*buf, size * 2); if (*buf == NULL) { return -1; } - p = *buf + size; - remain = size; + + p = *buf + size - 1; + remain = size + 1; size *= 2; } } + *p = '\0'; + return ret; } diff --git a/contrib/libucl/utils/Makefile.am b/contrib/libucl/utils/Makefile.am index 23eeeac8032b..ec85aaa5e372 100644 --- a/contrib/libucl/utils/Makefile.am +++ b/contrib/libucl/utils/Makefile.am @@ -11,8 +11,12 @@ ucl_objdump_SOURCES = objdump.c ucl_objdump_LDADD = $(common_utils_ldadd) ucl_objdump_CFLAGS = $(common_utils_cflags) +ucl_tool_SOURCES = ucl-tool.c +ucl_tool_LDADD = $(common_utils_ldadd) +ucl_tool_CFLAGS = $(common_utils_cflags) + if UTILS -UTL = ucl_chargen ucl_objdump +UTL = ucl_chargen ucl_objdump ucl_tool else UTL = endif diff --git a/contrib/libucl/utils/chargen.c b/contrib/libucl/utils/chargen.c index d6fa86a20bd2..398134054c21 100644 --- a/contrib/libucl/utils/chargen.c +++ b/contrib/libucl/utils/chargen.c @@ -54,9 +54,9 @@ main (int argc, char **argv) name = argv[1]; } - printf ("static const unsigned int %s[255] = {\n", name); + printf ("static const unsigned int %s[256] = {\n", name); - for (i = 0; i < 255; i ++) { + for (i = 0; i < 256; i ++) { need_or = false; r = 0; /* UCL_CHARACTER_VALUE_END */ @@ -110,7 +110,7 @@ main (int argc, char **argv) if (isprint (i)) { r += sprintf (valbuf + r, " /* %c */", i); } - if (i != 254) { + if (i != 255) { r += sprintf (valbuf + r, ", "); } col += r; diff --git a/contrib/libucl/utils/objdump.c b/contrib/libucl/utils/objdump.c index 74581baafddb..6fde2f4c890e 100644 --- a/contrib/libucl/utils/objdump.c +++ b/contrib/libucl/utils/objdump.c @@ -99,9 +99,10 @@ int main(int argc, char **argv) { const char *fn = NULL; - unsigned char inbuf[8192]; + unsigned char *inbuf; struct ucl_parser *parser; int k, ret = 0, r = 0; + ssize_t bufsize; ucl_object_t *obj = NULL; const ucl_object_t *par; FILE *in; @@ -121,9 +122,27 @@ main(int argc, char **argv) } parser = ucl_parser_new (0); - while (!feof (in) && r < (int)sizeof (inbuf)) { - r += fread (inbuf + r, 1, sizeof (inbuf) - r, in); + inbuf = malloc (BUFSIZ); + bufsize = BUFSIZ; + r = 0; + + while (!feof (in) && !ferror (in)) { + if (r == bufsize) { + inbuf = realloc (inbuf, bufsize * 2); + bufsize *= 2; + if (inbuf == NULL) { + perror ("realloc"); + exit (EXIT_FAILURE); + } + } + r += fread (inbuf + r, 1, bufsize - r, in); } + + if (ferror (in)) { + fprintf (stderr, "Failed to read the input file.\n"); + exit (EXIT_FAILURE); + } + ucl_parser_add_chunk (parser, inbuf, r); fclose (in); if (ucl_parser_get_error(parser)) { diff --git a/contrib/libucl/utils/ucl-tool.c b/contrib/libucl/utils/ucl-tool.c new file mode 100644 index 000000000000..feea9c2070d5 --- /dev/null +++ b/contrib/libucl/utils/ucl-tool.c @@ -0,0 +1,168 @@ +/* Copyright (c) 2015, Cesanta Software + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include "ucl.h" + +static struct option opts[] = { + {"help", no_argument, NULL, 'h'}, + {"in", required_argument, NULL, 'i' }, + {"out", required_argument, NULL, 'o' }, + {"schema", required_argument, NULL, 's'}, + {"format", required_argument, NULL, 'f'}, + {0, 0, 0, 0} +}; + +void usage(const char *name, FILE *out) { + fprintf(out, "Usage: %s [--help] [-i|--in file] [-o|--out file]\n", name); + fprintf(out, " [-s|--schema file] [-f|--format format]\n\n"); + fprintf(out, " --help - print this message and exit\n"); + fprintf(out, " --in - specify input filename " + "(default: standard input)\n"); + fprintf(out, " --out - specify output filename " + "(default: standard output)\n"); + fprintf(out, " --schema - specify schema file for validation\n"); + fprintf(out, " --format - output format. Options: ucl (default), " + "json, compact_json, yaml, msgpack\n"); +} + +int main(int argc, char **argv) { + char ch; + FILE *in = stdin, *out = stdout; + const char *schema = NULL; + unsigned char *buf = NULL; + size_t size = 0, r = 0; + struct ucl_parser *parser = NULL; + ucl_object_t *obj = NULL; + ucl_emitter_t emitter = UCL_EMIT_CONFIG; + + while((ch = getopt_long(argc, argv, "hi:o:s:f:", opts, NULL)) != -1) { + switch (ch) { + case 'i': + in = fopen(optarg, "r"); + if (in == NULL) { + perror("fopen on input file"); + exit(EXIT_FAILURE); + } + break; + case 'o': + out = fopen(optarg, "w"); + if (out == NULL) { + perror("fopen on output file"); + exit(EXIT_FAILURE); + } + break; + case 's': + schema = optarg; + break; + case 'f': + if (strcmp(optarg, "ucl") == 0) { + emitter = UCL_EMIT_CONFIG; + } else if (strcmp(optarg, "json") == 0) { + emitter = UCL_EMIT_JSON; + } else if (strcmp(optarg, "yaml") == 0) { + emitter = UCL_EMIT_YAML; + } else if (strcmp(optarg, "compact_json") == 0) { + emitter = UCL_EMIT_JSON_COMPACT; + } else if (strcmp(optarg, "msgpack") == 0) { + emitter = UCL_EMIT_MSGPACK; + } else { + fprintf(stderr, "Unknown output format: %s\n", optarg); + exit(EXIT_FAILURE); + } + break; + case 'h': + usage(argv[0], stdout); + exit(0); + default: + usage(argv[0], stderr); + exit(EXIT_FAILURE); + break; + } + } + + parser = ucl_parser_new(0); + buf = malloc(BUFSIZ); + size = BUFSIZ; + while(!feof(in) && !ferror(in)) { + if (r == size) { + buf = realloc(buf, size*2); + size *= 2; + if (buf == NULL) { + perror("realloc"); + exit(EXIT_FAILURE); + } + } + r += fread(buf + r, 1, size - r, in); + } + if (ferror(in)) { + fprintf(stderr, "Failed to read the input file.\n"); + exit(EXIT_FAILURE); + } + fclose(in); + if (!ucl_parser_add_chunk(parser, buf, r)) { + fprintf(stderr, "Failed to parse input file: %s\n", + ucl_parser_get_error(parser)); + exit(EXIT_FAILURE); + } + if ((obj = ucl_parser_get_object(parser)) == NULL) { + fprintf(stderr, "Failed to get root object: %s\n", + ucl_parser_get_error(parser)); + exit(EXIT_FAILURE); + } + if (schema != NULL) { + struct ucl_parser *schema_parser = ucl_parser_new(0); + ucl_object_t *schema_obj = NULL; + struct ucl_schema_error error; + + if (!ucl_parser_add_file(schema_parser, schema)) { + fprintf(stderr, "Failed to parse schema file: %s\n", + ucl_parser_get_error(schema_parser)); + exit(EXIT_FAILURE); + } + if ((schema_obj = ucl_parser_get_object(schema_parser)) == NULL) { + fprintf(stderr, "Failed to get root object: %s\n", + ucl_parser_get_error(schema_parser)); + exit(EXIT_FAILURE); + } + if (!ucl_object_validate(schema_obj, obj, &error)) { + fprintf(stderr, "Validation failed: %s\n", error.msg); + exit(EXIT_FAILURE); + } + } + + if (emitter != UCL_EMIT_MSGPACK) { + fprintf(out, "%s\n", ucl_object_emit(obj, emitter)); + } + else { + size_t len; + unsigned char *res; + + res = ucl_object_emit_len(obj, emitter, &len); + fwrite(res, 1, len, out); + } + + return 0; +} diff --git a/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/POSIXThread.cpp b/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/POSIXThread.cpp index 854796fb7448..7d95e9664b39 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/POSIXThread.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/POSIXThread.cpp @@ -36,6 +36,7 @@ #include "RegisterContextPOSIXProcessMonitor_powerpc.h" #include "RegisterContextPOSIXProcessMonitor_x86.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h" +#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h" @@ -160,6 +161,9 @@ POSIXThread::GetRegisterContext() case llvm::Triple::FreeBSD: switch (target_arch.GetMachine()) { + case llvm::Triple::aarch64: + reg_interface = new RegisterContextFreeBSD_arm64(target_arch); + break; case llvm::Triple::arm: reg_interface = new RegisterContextFreeBSD_arm(target_arch); break; diff --git a/contrib/mdocml/lib.in b/contrib/mdocml/lib.in index a1ce062f75fc..d69a6542f38d 100644 --- a/contrib/mdocml/lib.in +++ b/contrib/mdocml/lib.in @@ -57,7 +57,6 @@ LINE("libfsid", "Filesystem Identification Library (libfsid, \\-lfsid)") LINE("libftpio", "FTP Connection Management Library (libftpio, \\-lftpio)") LINE("libform", "Curses Form Library (libform, \\-lform)") LINE("libgeom", "Userland API Library for Kernel GEOM subsystem (libgeom, \\-lgeom)") -LINE("libgpib", "General-Purpose Instrument Bus (GPIB) library (libgpib, \\-lgpib)") LINE("libgpio", "General-Purpose Input Output (GPIO) library (libgpio, \\-lgpio)") LINE("libhammer", "HAMMER Filesystem Userland Library (libhammer, \\-lhammer)") LINE("libi386", "i386 Architecture Library (libi386, \\-li386)") diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c b/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c index 7e8bff6de888..30e9c1e799b5 100644 --- a/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c +++ b/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c @@ -46,7 +46,6 @@ main(int argc, char *argv[]) { #ifdef __FreeBSD__ char b[512], *sl; - int n; size_t len = atoi(argv[1]); sl = malloc(len); memset(sl, 'a', len); @@ -54,7 +53,7 @@ main(int argc, char *argv[]) unlink("symlink"); if (symlink(sl, "symlink") == -1) err(1, "symlink()"); - n = readlink("symlink", b, len); + (void)readlink("symlink", b, len); unlink("symlink"); #else char b[MAXPATHLEN]; diff --git a/contrib/ntp/ChangeLog b/contrib/ntp/ChangeLog index 738ae225867d..5d8346b310b0 100644 --- a/contrib/ntp/ChangeLog +++ b/contrib/ntp/ChangeLog @@ -1,4 +1,159 @@ --- +(4.2.8p4) 2015/10/21 Released by Harlan Stenn +(4.2.8p4-RC1) 2015/10/06 Released by Harlan Stenn + +* [Sec 2899] CVE-2014-9297 perlinger@ntp.org +* [Sec 2901] Drop invalid packet before checking KoD. Check for all KoD's. + Danny Mayer. Log incoming packets that fail TEST2. Harlan Stenn. +* [Sec 2902] configuration directives "pidfile" and "driftfile" + should be local-only. perlinger@ntp.org (patch by Miroslav Lichvar) +* [Sec 2909] added missing call to 'free()' in ntp_crypto.c. perlinger@ntp.org +* [Sec 2913] TALOS-CAN-0052: crash by loop counter underrun. perlinger@ntp.org +* [Sec 2916] TALOS-CAN-0054: memory corruption in password store. JPerlinger +* [Sec 2917] TALOS-CAN-0055: Infinite loop if extended logging enabled and + the logfile and keyfile are the same. perlinger@ntp.org +* [Sec 1918] TALOS-CAN-0062: prevent directory traversal for VMS, too, when + using 'saveconfig' command. perlinger@ntp.org +* [Bug 2919] TALOS-CAN-0063: avoid buffer overrun in ntpq. perlinger@ntp.org +* [Sec 2020] TALOS-CAN-0064: signed/unsiged clash could lead to buffer overun + and memory corruption. perlinger@ntp.org +* [Sec 2921] TALOS-CAN-0065: password length memory corruption. JPerlinger. +* [Sec 2922] decodenetnum() will ASSERT botch instead of returning FAIL + on some bogus values. Harlan Stenn. +* [Sec 2941] NAK to the Future: Symmetric association authentication + bypass via crypto-NAK. Patch applied. perlinger@ntp.org +* [Bug 2332] (reopened) Exercise thread cancellation once before dropping + privileges and limiting resources in NTPD removes the need to link + forcefully against 'libgcc_s' which does not always work. J.Perlinger +* [Bug 2595] ntpdate man page quirks. Hal Murray, Harlan Stenn. +* [Bug 2625] Deprecate flag1 in local refclock. Hal Murray, Harlan Stenn. +* [Bug 2817] Stop locking ntpd into memory by default under Linux. H.Stenn. +* [Bug 2821] minor build issues: fixed refclock_gpsdjson.c. perlinger@ntp.org +* [Bug 2823] ntpsweep with recursive peers option doesn't work. H.Stenn. +* [Bug 2849] Systems with more than one default route may never + synchronize. Brian Utterback. Note that this patch might need to + be reverted once Bug 2043 has been fixed. +* [Bug 2864] 4.2.8p3 fails to compile on Windows. Juergen Perlinger +* [Bug 2866] segmentation fault at initgroups(). Harlan Stenn. +* [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv'. J.Perlinger +* [Bug 2873] libevent should not include .deps/ in the tarball. H.Stenn +* [Bug 2874] Don't distribute generated sntp/tests/fileHandlingTest.h. H.Stenn +* [Bug 2875] sntp/Makefile.am: Get rid of DIST_SUBDIRS. libevent must + be configured for the distribution targets. Harlan Stenn. +* [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. +* [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org +* [Bug 2888] streamline calendar functions. perlinger@ntp.org +* [Bug 2889] ntp-dev-4.3.67 does not build on Windows. perlinger@ntp.org +* [Bug 2890] Ignore ENOBUFS on routing netlink socket. Konstantin Khlebnikov. +* [Bug 2906] make check needs better support for pthreads. Harlan Stenn. +* [Bug 2907] dist* build targets require our libevent/ to be enabled. HStenn. +* [Bug 2912] no munlockall() under Windows. David Taylor, Harlan Stenn. +* libntp/emalloc.c: Remove explicit include of stdint.h. Harlan Stenn. +* Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. +* tests/ntpd/g_leapsec.cpp typo fix. Harlan Stenn. +* Phase 1 deprecation of google test in sntp/tests/. Harlan Stenn. +* On some versions of HP-UX, inttypes.h does not include stdint.h. H.Stenn. +* top_srcdir can change based on ntp v. sntp. Harlan Stenn. +* sntp/tests/ function parameter list cleanup. Damir Tomić. +* tests/libntp/ function parameter list cleanup. Damir Tomić. +* tests/ntpd/ function parameter list cleanup. Damir Tomić. +* sntp/unity/unity_config.h: handle stdint.h. Harlan Stenn. +* sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris. H.Stenn. +* tests/libntp/timevalops.c and timespecops.c fixed error printing. D.Tomić. +* tests/libntp/ improvements in code and fixed error printing. Damir Tomić. +* tests/libntp: a_md5encrypt.c, authkeys.c, buftvtots.c, calendar.c, caljulian.c, + caltontp.c, clocktime.c, humandate.c, hextolfp.c, decodenetnum.c - fixed + formatting; first declaration, then code (C90); deleted unnecessary comments; + changed from sprintf to snprintf; fixed order of includes. Tomasz Flendrich +* tests/libntp/lfpfunc.c remove unnecessary include, remove old comments, + fix formatting, cleanup. Tomasz Flendrich +* tests/libntp/lfptostr.c remove unnecessary include, add consts, fix formatting. + Tomasz Flendrich +* tests/libntp/statestr.c remove empty functions, remove unnecessary include, + fix formatting. Tomasz Flendrich +* tests/libntp/modetoa.c fixed formatting. Tomasz Flendrich +* tests/libntp/msyslog.c fixed formatting. Tomasz Flendrich +* tests/libntp/numtoa.c deleted unnecessary empty functions, fixed formatting. + Tomasz Flendrich +* tests/libntp/numtohost.c added const, fixed formatting. Tomasz Flendrich +* tests/libntp/refnumtoa.c fixed formatting. Tomasz Flendrich +* tests/libntp/ssl_init.c fixed formatting. Tomasz Flendrich +* tests/libntp/tvtots.c fixed a bug, fixed formatting. Tomasz Flendrich +* tests/libntp/uglydate.c removed an unnecessary include. Tomasz Flendrich +* tests/libntp/vi64ops.c removed an unnecessary comment, fixed formatting. +* tests/libntp/ymd3yd.c removed an empty function and an unnecessary include, +fixed formatting. Tomasz Flendrich +* tests/libntp/timespecops.c fixed formatting, fixed the order of includes, + removed unnecessary comments, cleanup. Tomasz Flendrich +* tests/libntp/timevalops.c fixed the order of includes, deleted unnecessary + comments, cleanup. Tomasz Flendrich +* tests/libntp/sockaddrtest.h making it agree to NTP's conventions of formatting. + Tomasz Flendrich +* tests/libntp/lfptest.h cleanup. Tomasz Flendrich +* tests/libntp/test-libntp.c fix formatting. Tomasz Flendrich +* sntp/tests/crypto.c is now using proper Unity's assertions, fixed formatting. + Tomasz Flendrich +* sntp/tests/kodDatabase.c added consts, deleted empty function, + fixed formatting. Tomasz Flendrich +* sntp/tests/kodFile.c cleanup, fixed formatting. Tomasz Flendrich +* sntp/tests/packetHandling.c is now using proper Unity's assertions, + fixed formatting, deleted unused variable. Tomasz Flendrich +* sntp/tests/keyFile.c is now using proper Unity's assertions, fixed formatting. + Tomasz Flendrich +* sntp/tests/packetProcessing.c changed from sprintf to snprintf, + fixed formatting. Tomasz Flendrich +* sntp/tests/utilities.c is now using proper Unity's assertions, changed + the order of includes, fixed formatting, removed unnecessary comments. + Tomasz Flendrich +* sntp/tests/sntptest.h fixed formatting. Tomasz Flendrich +* sntp/tests/fileHandlingTest.h.in fixed a possible buffer overflow problem, + made one function do its job, deleted unnecessary prints, fixed formatting. + Tomasz Flendrich +* sntp/unity/Makefile.am added a missing header. Tomasz Flendrich +* sntp/unity/unity_config.h: Distribute it. Harlan Stenn. +* sntp/libevent/evconfig-private.h: remove generated filefrom SCM. H.Stenn. +* sntp/unity/Makefile.am: fix some broken paths. Harlan Stenn. +* sntp/unity/unity.c: Clean up a printf(). Harlan Stenn. +* Phase 1 deprecation of google test in tests/libntp/. Harlan Stenn. +* Don't build sntp/libevent/sample/. Harlan Stenn. +* tests/libntp/test_caltontp needs -lpthread. Harlan Stenn. +* br-flock: --enable-local-libevent. Harlan Stenn. +* Wrote tests for ntpd/ntp_prio_q.c. Tomasz Flendrich +* scripts/lib/NTP/Util.pm: stratum output is version-dependent. Harlan Stenn. +* Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. +* Code cleanup. Harlan Stenn. +* libntp/icom.c: Typo fix. Harlan Stenn. +* util/ntptime.c: initialization nit. Harlan Stenn. +* ntpd/ntp_peer.c:newpeer(): added a DEBUG_REQUIRE(srcadr). Harlan Stenn. +* Add std_unity_tests to various Makefile.am files. Harlan Stenn. +* ntpd/ntp_restrict.c: added a few assertions, created tests for this file. + Tomasz Flendrich +* Changed progname to be const in many files - now it's consistent. Tomasz + Flendrich +* Typo fix for GCC warning suppression. Harlan Stenn. +* Added tests/ntpd/ntp_scanner.c test. Damir Tomić. +* Added declarations to all Unity tests, and did minor fixes to them. + Reduced the number of warnings by half. Damir Tomić. +* Updated generate_test_runner.rb and updated the sntp/unity/auto directory + with the latest Unity updates from Mark. Damir Tomić. +* Retire google test - phase I. Harlan Stenn. +* Unity test cleanup: move declaration of 'initializing'. Harlan Stenn. +* Update the NEWS file. Harlan Stenn. +* Autoconf cleanup. Harlan Stenn. +* Unit test dist cleanup. Harlan Stenn. +* Cleanup various test Makefile.am files. Harlan Stenn. +* Pthread autoconf macro cleanup. Harlan Stenn. +* Fix progname definition in unity runner scripts. Harlan Stenn. +* Clean trailing whitespace in tests/ntpd/Makefile.am. Harlan Stenn. +* Update the patch for bug 2817. Harlan Stenn. +* More updates for bug 2817. Harlan Stenn. +* Fix bugs in tests/ntpd/ntp_prio_q.c. Harlan Stenn. +* gcc on older HPUX may need +allowdups. Harlan Stenn. +* Adding missing MCAST protection. Harlan Stenn. +* Disable certain test programs on certain platforms. Harlan Stenn. +* Implement --enable-problem-tests (on by default). Harlan Stenn. +* build system tweaks. Harlan Stenn. +--- (4.2.8p3) 2015/06/29 Released by Harlan Stenn * [Sec 2853] Crafted remote config packet can crash some versions of diff --git a/contrib/ntp/CommitLog b/contrib/ntp/CommitLog index b1f2a30ffe14..3366f2ff17e8 100644 --- a/contrib/ntp/CommitLog +++ b/contrib/ntp/CommitLog @@ -1,3 +1,4916 @@ +ChangeSet@1.3577, 2015-10-21 12:42:02-04:00, stenn@deacon.udel.edu + NTP_4_2_8P4 + TAG: NTP_4_2_8P4 + + ChangeLog@1.1757 +1 -0 + NTP_4_2_8P4 + + ntpd/invoke-ntp.conf.texi@1.193 +1 -1 + NTP_4_2_8P4 + + ntpd/invoke-ntp.keys.texi@1.185 +1 -1 + NTP_4_2_8P4 + + ntpd/invoke-ntpd.texi@1.502 +2 -2 + NTP_4_2_8P4 + + ntpd/ntp.conf.5man@1.227 +3 -3 + NTP_4_2_8P4 + + ntpd/ntp.conf.5mdoc@1.227 +2 -2 + NTP_4_2_8P4 + + ntpd/ntp.conf.html@1.181 +94 -107 + NTP_4_2_8P4 + + ntpd/ntp.conf.man.in@1.227 +3 -3 + NTP_4_2_8P4 + + ntpd/ntp.conf.mdoc.in@1.227 +2 -2 + NTP_4_2_8P4 + + ntpd/ntp.keys.5man@1.219 +2 -2 + NTP_4_2_8P4 + + ntpd/ntp.keys.5mdoc@1.219 +3 -3 + NTP_4_2_8P4 + + ntpd/ntp.keys.html@1.181 +21 -33 + NTP_4_2_8P4 + + ntpd/ntp.keys.man.in@1.219 +2 -2 + NTP_4_2_8P4 + + ntpd/ntp.keys.mdoc.in@1.219 +3 -3 + NTP_4_2_8P4 + + ntpd/ntpd-opts.c@1.524 +245 -245 + NTP_4_2_8P4 + + ntpd/ntpd-opts.h@1.523 +3 -3 + NTP_4_2_8P4 + + ntpd/ntpd.1ntpdman@1.331 +3 -3 + NTP_4_2_8P4 + + ntpd/ntpd.1ntpdmdoc@1.331 +2 -2 + NTP_4_2_8P4 + + ntpd/ntpd.html@1.175 +142 -186 + NTP_4_2_8P4 + + ntpd/ntpd.man.in@1.331 +3 -3 + NTP_4_2_8P4 + + ntpd/ntpd.mdoc.in@1.331 +2 -2 + NTP_4_2_8P4 + + ntpdc/invoke-ntpdc.texi@1.499 +2 -2 + NTP_4_2_8P4 + + ntpdc/ntpdc-opts.c@1.517 +107 -107 + NTP_4_2_8P4 + + ntpdc/ntpdc-opts.h@1.516 +3 -3 + NTP_4_2_8P4 + + ntpdc/ntpdc.1ntpdcman@1.330 +3 -3 + NTP_4_2_8P4 + + ntpdc/ntpdc.1ntpdcmdoc@1.330 +2 -2 + NTP_4_2_8P4 + + ntpdc/ntpdc.html@1.343 +75 -95 + NTP_4_2_8P4 + + ntpdc/ntpdc.man.in@1.330 +3 -3 + NTP_4_2_8P4 + + ntpdc/ntpdc.mdoc.in@1.330 +2 -2 + NTP_4_2_8P4 + + ntpq/invoke-ntpq.texi@1.506 +2 -2 + NTP_4_2_8P4 + + ntpq/ntpq-opts.c@1.523 +106 -106 + NTP_4_2_8P4 + + ntpq/ntpq-opts.h@1.521 +3 -3 + NTP_4_2_8P4 + + ntpq/ntpq.1ntpqman@1.334 +3 -3 + NTP_4_2_8P4 + + ntpq/ntpq.1ntpqmdoc@1.334 +2 -2 + NTP_4_2_8P4 + + ntpq/ntpq.html@1.172 +132 -155 + NTP_4_2_8P4 + + ntpq/ntpq.man.in@1.334 +3 -3 + NTP_4_2_8P4 + + ntpq/ntpq.mdoc.in@1.334 +2 -2 + NTP_4_2_8P4 + + ntpsnmpd/invoke-ntpsnmpd.texi@1.501 +2 -2 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd-opts.c@1.519 +68 -68 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd-opts.h@1.518 +3 -3 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.330 +3 -3 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.330 +2 -2 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd.html@1.170 +10 -14 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd.man.in@1.330 +3 -3 + NTP_4_2_8P4 + + ntpsnmpd/ntpsnmpd.mdoc.in@1.330 +2 -2 + NTP_4_2_8P4 + + packageinfo.sh@1.520 +3 -3 + NTP_4_2_8P4 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.91 +3 -3 + NTP_4_2_8P4 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.92 +2 -2 + NTP_4_2_8P4 + + scripts/calc_tickadj/calc_tickadj.html@1.93 +30 -42 + NTP_4_2_8P4 + + scripts/calc_tickadj/calc_tickadj.man.in@1.90 +3 -3 + NTP_4_2_8P4 + + scripts/calc_tickadj/calc_tickadj.mdoc.in@1.92 +2 -2 + NTP_4_2_8P4 + + scripts/calc_tickadj/invoke-calc_tickadj.texi@1.95 +1 -1 + NTP_4_2_8P4 + + scripts/invoke-plot_summary.texi@1.112 +2 -2 + NTP_4_2_8P4 + + scripts/invoke-summary.texi@1.112 +2 -2 + NTP_4_2_8P4 + + scripts/ntp-wait/invoke-ntp-wait.texi@1.322 +2 -2 + NTP_4_2_8P4 + + scripts/ntp-wait/ntp-wait-opts@1.58 +2 -2 + NTP_4_2_8P4 + + scripts/ntp-wait/ntp-wait.1ntp-waitman@1.319 +3 -3 + NTP_4_2_8P4 + + scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.320 +2 -2 + NTP_4_2_8P4 + + scripts/ntp-wait/ntp-wait.html@1.339 +41 -59 + NTP_4_2_8P4 + + scripts/ntp-wait/ntp-wait.man.in@1.319 +3 -3 + NTP_4_2_8P4 + + scripts/ntp-wait/ntp-wait.mdoc.in@1.320 +2 -2 + NTP_4_2_8P4 + + scripts/ntpsweep/invoke-ntpsweep.texi@1.110 +2 -2 + NTP_4_2_8P4 + + scripts/ntpsweep/ntpsweep-opts@1.60 +2 -2 + NTP_4_2_8P4 + + scripts/ntpsweep/ntpsweep.1ntpsweepman@1.98 +3 -3 + NTP_4_2_8P4 + + scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.98 +2 -2 + NTP_4_2_8P4 + + scripts/ntpsweep/ntpsweep.html@1.111 +46 -57 + NTP_4_2_8P4 + + scripts/ntpsweep/ntpsweep.man.in@1.98 +3 -3 + NTP_4_2_8P4 + + scripts/ntpsweep/ntpsweep.mdoc.in@1.99 +2 -2 + NTP_4_2_8P4 + + scripts/ntptrace/invoke-ntptrace.texi@1.111 +2 -2 + NTP_4_2_8P4 + + scripts/ntptrace/ntptrace-opts@1.60 +2 -2 + NTP_4_2_8P4 + + scripts/ntptrace/ntptrace.1ntptraceman@1.98 +3 -3 + NTP_4_2_8P4 + + scripts/ntptrace/ntptrace.1ntptracemdoc@1.99 +2 -2 + NTP_4_2_8P4 + + scripts/ntptrace/ntptrace.html@1.112 +38 -47 + NTP_4_2_8P4 + + scripts/ntptrace/ntptrace.man.in@1.98 +3 -3 + NTP_4_2_8P4 + + scripts/ntptrace/ntptrace.mdoc.in@1.100 +2 -2 + NTP_4_2_8P4 + + scripts/plot_summary-opts@1.60 +2 -2 + NTP_4_2_8P4 + + scripts/plot_summary.1plot_summaryman@1.110 +3 -3 + NTP_4_2_8P4 + + scripts/plot_summary.1plot_summarymdoc@1.110 +2 -2 + NTP_4_2_8P4 + + scripts/plot_summary.html@1.113 +40 -58 + NTP_4_2_8P4 + + scripts/plot_summary.man.in@1.110 +3 -3 + NTP_4_2_8P4 + + scripts/plot_summary.mdoc.in@1.110 +2 -2 + NTP_4_2_8P4 + + scripts/summary-opts@1.60 +2 -2 + NTP_4_2_8P4 + + scripts/summary.1summaryman@1.110 +3 -3 + NTP_4_2_8P4 + + scripts/summary.1summarymdoc@1.110 +2 -2 + NTP_4_2_8P4 + + scripts/summary.html@1.113 +37 -49 + NTP_4_2_8P4 + + scripts/summary.man.in@1.110 +3 -3 + NTP_4_2_8P4 + + scripts/summary.mdoc.in@1.110 +2 -2 + NTP_4_2_8P4 + + scripts/update-leap/invoke-update-leap.texi@1.11 +1 -1 + NTP_4_2_8P4 + + scripts/update-leap/update-leap-opts@1.11 +2 -2 + NTP_4_2_8P4 + + scripts/update-leap/update-leap.1update-leapman@1.11 +3 -3 + NTP_4_2_8P4 + + scripts/update-leap/update-leap.1update-leapmdoc@1.11 +2 -2 + NTP_4_2_8P4 + + scripts/update-leap/update-leap.html@1.11 +48 -72 + NTP_4_2_8P4 + + scripts/update-leap/update-leap.man.in@1.11 +3 -3 + NTP_4_2_8P4 + + scripts/update-leap/update-leap.mdoc.in@1.11 +2 -2 + NTP_4_2_8P4 + + sntp/invoke-sntp.texi@1.499 +2 -2 + NTP_4_2_8P4 + + sntp/sntp-opts.c@1.518 +159 -159 + NTP_4_2_8P4 + + sntp/sntp-opts.h@1.516 +3 -3 + NTP_4_2_8P4 + + sntp/sntp.1sntpman@1.334 +3 -3 + NTP_4_2_8P4 + + sntp/sntp.1sntpmdoc@1.334 +2 -2 + NTP_4_2_8P4 + + sntp/sntp.html@1.514 +111 -135 + NTP_4_2_8P4 + + sntp/sntp.man.in@1.334 +3 -3 + NTP_4_2_8P4 + + sntp/sntp.mdoc.in@1.334 +2 -2 + NTP_4_2_8P4 + + util/invoke-ntp-keygen.texi@1.502 +2 -2 + NTP_4_2_8P4 + + util/ntp-keygen-opts.c@1.520 +173 -173 + NTP_4_2_8P4 + + util/ntp-keygen-opts.h@1.518 +3 -3 + NTP_4_2_8P4 + + util/ntp-keygen.1ntp-keygenman@1.330 +3 -3 + NTP_4_2_8P4 + + util/ntp-keygen.1ntp-keygenmdoc@1.330 +2 -2 + NTP_4_2_8P4 + + util/ntp-keygen.html@1.176 +157 -216 + NTP_4_2_8P4 + + util/ntp-keygen.man.in@1.330 +3 -3 + NTP_4_2_8P4 + + util/ntp-keygen.mdoc.in@1.330 +2 -2 + NTP_4_2_8P4 + +ChangeSet@1.3576, 2015-10-21 11:58:26-04:00, stenn@deacon.udel.edu + 4.2.8p4 + + packageinfo.sh@1.519 +1 -1 + 4.2.8p4 + +ChangeSet@1.3575, 2015-10-21 15:35:31+00:00, stenn@psp-deb1.ntp.org + Update severity information + + NEWS@1.150 +2 -2 + Update severity information + +ChangeSet@1.3574, 2015-10-20 08:00:43+00:00, stenn@psp-deb1.ntp.org + Update CVEs + + NEWS@1.149 +16 -16 + Update CVEs + +ChangeSet@1.3573, 2015-10-17 06:28:49+00:00, stenn@psp-deb1.ntp.org + ntp-4.2.8p4-sec-RC2 + + NEWS@1.148 +336 -4 + ntp-4.2.8p4-sec-RC2 + + ntpd/invoke-ntp.conf.texi@1.192 +1 -1 + ntp-4.2.8p4-sec-RC2 + + ntpd/invoke-ntp.keys.texi@1.184 +1 -1 + ntp-4.2.8p4-sec-RC2 + + ntpd/invoke-ntpd.texi@1.501 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.conf.5man@1.226 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.conf.5mdoc@1.226 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.conf.html@1.180 +107 -94 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.conf.man.in@1.226 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.conf.mdoc.in@1.226 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.keys.5man@1.218 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.keys.5mdoc@1.218 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.keys.html@1.180 +33 -21 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.keys.man.in@1.218 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntp.keys.mdoc.in@1.218 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd-opts.c@1.523 +245 -245 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd-opts.h@1.522 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd.1ntpdman@1.330 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd.1ntpdmdoc@1.330 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd.html@1.174 +186 -142 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd.man.in@1.330 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpd/ntpd.mdoc.in@1.330 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpdc/invoke-ntpdc.texi@1.498 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc-opts.c@1.516 +107 -107 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc-opts.h@1.515 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc.1ntpdcman@1.329 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc.1ntpdcmdoc@1.329 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc.html@1.342 +95 -75 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc.man.in@1.329 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpdc/ntpdc.mdoc.in@1.329 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpq/invoke-ntpq.texi@1.505 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq-opts.c@1.522 +106 -106 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq-opts.h@1.520 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq.1ntpqman@1.333 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq.1ntpqmdoc@1.333 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq.html@1.171 +155 -132 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq.man.in@1.333 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpq/ntpq.mdoc.in@1.333 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/invoke-ntpsnmpd.texi@1.500 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd-opts.c@1.518 +68 -68 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd-opts.h@1.517 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.329 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.329 +2 -2 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd.html@1.169 +14 -10 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd.man.in@1.329 +3 -3 + ntp-4.2.8p4-sec-RC2 + + ntpsnmpd/ntpsnmpd.mdoc.in@1.329 +2 -2 + ntp-4.2.8p4-sec-RC2 + + packageinfo.sh@1.518 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.90 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.91 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/calc_tickadj/calc_tickadj.html@1.92 +42 -30 + ntp-4.2.8p4-sec-RC2 + + scripts/calc_tickadj/calc_tickadj.man.in@1.89 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/calc_tickadj/calc_tickadj.mdoc.in@1.91 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/calc_tickadj/invoke-calc_tickadj.texi@1.94 +1 -1 + ntp-4.2.8p4-sec-RC2 + + scripts/invoke-plot_summary.texi@1.111 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/invoke-summary.texi@1.111 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/invoke-ntp-wait.texi@1.321 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/ntp-wait-opts@1.57 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/ntp-wait.1ntp-waitman@1.318 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.319 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/ntp-wait.html@1.338 +59 -41 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/ntp-wait.man.in@1.318 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/ntp-wait/ntp-wait.mdoc.in@1.319 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/invoke-ntpsweep.texi@1.109 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/ntpsweep-opts@1.59 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/ntpsweep.1ntpsweepman@1.97 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.97 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/ntpsweep.html@1.110 +57 -46 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/ntpsweep.man.in@1.97 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/ntpsweep/ntpsweep.mdoc.in@1.98 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/invoke-ntptrace.texi@1.110 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/ntptrace-opts@1.59 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/ntptrace.1ntptraceman@1.97 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/ntptrace.1ntptracemdoc@1.98 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/ntptrace.html@1.111 +47 -38 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/ntptrace.man.in@1.97 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/ntptrace/ntptrace.mdoc.in@1.99 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/plot_summary-opts@1.59 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/plot_summary.1plot_summaryman@1.109 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/plot_summary.1plot_summarymdoc@1.109 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/plot_summary.html@1.112 +58 -40 + ntp-4.2.8p4-sec-RC2 + + scripts/plot_summary.man.in@1.109 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/plot_summary.mdoc.in@1.109 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/summary-opts@1.59 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/summary.1summaryman@1.109 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/summary.1summarymdoc@1.109 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/summary.html@1.112 +49 -37 + ntp-4.2.8p4-sec-RC2 + + scripts/summary.man.in@1.109 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/summary.mdoc.in@1.109 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/invoke-update-leap.texi@1.10 +1 -1 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/update-leap-opts@1.10 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/update-leap.1update-leapman@1.10 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/update-leap.1update-leapmdoc@1.10 +2 -2 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/update-leap.html@1.10 +72 -48 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/update-leap.man.in@1.10 +3 -3 + ntp-4.2.8p4-sec-RC2 + + scripts/update-leap/update-leap.mdoc.in@1.10 +2 -2 + ntp-4.2.8p4-sec-RC2 + + sntp/invoke-sntp.texi@1.498 +2 -2 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp-opts.c@1.517 +159 -159 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp-opts.h@1.515 +3 -3 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp.1sntpman@1.333 +3 -3 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp.1sntpmdoc@1.333 +2 -2 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp.html@1.513 +135 -111 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp.man.in@1.333 +3 -3 + ntp-4.2.8p4-sec-RC2 + + sntp/sntp.mdoc.in@1.333 +2 -2 + ntp-4.2.8p4-sec-RC2 + + util/invoke-ntp-keygen.texi@1.501 +2 -2 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen-opts.c@1.519 +173 -173 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen-opts.h@1.517 +3 -3 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen.1ntp-keygenman@1.329 +3 -3 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen.1ntp-keygenmdoc@1.329 +2 -2 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen.html@1.175 +216 -157 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen.man.in@1.329 +3 -3 + ntp-4.2.8p4-sec-RC2 + + util/ntp-keygen.mdoc.in@1.329 +2 -2 + ntp-4.2.8p4-sec-RC2 + +ChangeSet@1.3572, 2015-10-17 03:10:01+00:00, stenn@psp-deb1.ntp.org + cleanup + + ChangeLog@1.1756 +1 -5 + cleanup + +ChangeSet@1.3571, 2015-10-17 01:39:22+00:00, stenn@psp-deb1.ntp.org + [Sec 2941] NAK to the Future: Symmetric association authentication bypass via crypto-NAK + + ChangeLog@1.1755 +4 -1 + [Sec 2941] NAK to the Future: Symmetric association authentication bypass via crypto-NAK + +ChangeSet@1.3558.3.3, 2015-10-11 08:10:20+02:00, jnperlin@hydra.localnet + [Bug 2941] NAK to the Future: Symmetric association authentication bypass via crypto-NAK + + ChangeLog@1.1743.3.3 +3 -0 + [Bug 2941] NAK to the Future: Symmetric association authentication bypass via crypto-NAK + + ntpd/ntp_proto.c@1.364.1.1 +18 -0 + [Bug 2941] NAK to the Future: Symmetric association authentication bypass via crypto-NAK + +ChangeSet@1.3558.3.2, 2015-10-06 06:25:48-04:00, stenn@deacon.udel.edu + NTP_4_2_8P4_RC1 + TAG: NTP_4_2_8P4_RC1 + + ChangeLog@1.1743.3.2 +1 -0 + NTP_4_2_8P4_RC1 + + ntpd/invoke-ntp.conf.texi@1.191 +1 -1 + NTP_4_2_8P4_RC1 + + ntpd/invoke-ntp.keys.texi@1.183 +1 -1 + NTP_4_2_8P4_RC1 + + ntpd/invoke-ntpd.texi@1.500 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntp.conf.5man@1.225 +3 -3 + NTP_4_2_8P4_RC1 + + ntpd/ntp.conf.5mdoc@1.225 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntp.conf.html@1.179 +1196 -1524 + NTP_4_2_8P4_RC1 + + ntpd/ntp.conf.man.in@1.225 +3 -3 + NTP_4_2_8P4_RC1 + + ntpd/ntp.conf.mdoc.in@1.225 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntp.keys.5man@1.217 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntp.keys.5mdoc@1.217 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntp.keys.html@1.179 +1 -1 + NTP_4_2_8P4_RC1 + + ntpd/ntp.keys.man.in@1.217 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntp.keys.mdoc.in@1.217 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntpd-opts.c@1.522 +245 -245 + NTP_4_2_8P4_RC1 + + ntpd/ntpd-opts.h@1.521 +3 -3 + NTP_4_2_8P4_RC1 + + ntpd/ntpd.1ntpdman@1.329 +8 -4 + NTP_4_2_8P4_RC1 + + ntpd/ntpd.1ntpdmdoc@1.329 +7 -3 + NTP_4_2_8P4_RC1 + + ntpd/ntpd.html@1.173 +2 -2 + NTP_4_2_8P4_RC1 + + ntpd/ntpd.man.in@1.329 +8 -4 + NTP_4_2_8P4_RC1 + + ntpd/ntpd.mdoc.in@1.329 +7 -3 + NTP_4_2_8P4_RC1 + + ntpdc/invoke-ntpdc.texi@1.497 +2 -2 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc-opts.c@1.515 +107 -107 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc-opts.h@1.514 +3 -3 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc.1ntpdcman@1.328 +3 -3 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc.1ntpdcmdoc@1.328 +2 -2 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc.html@1.341 +2 -2 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc.man.in@1.328 +3 -3 + NTP_4_2_8P4_RC1 + + ntpdc/ntpdc.mdoc.in@1.328 +2 -2 + NTP_4_2_8P4_RC1 + + ntpq/invoke-ntpq.texi@1.504 +2 -2 + NTP_4_2_8P4_RC1 + + ntpq/ntpq-opts.c@1.521 +106 -106 + NTP_4_2_8P4_RC1 + + ntpq/ntpq-opts.h@1.519 +3 -3 + NTP_4_2_8P4_RC1 + + ntpq/ntpq.1ntpqman@1.332 +3 -3 + NTP_4_2_8P4_RC1 + + ntpq/ntpq.1ntpqmdoc@1.332 +2 -2 + NTP_4_2_8P4_RC1 + + ntpq/ntpq.html@1.170 +2 -2 + NTP_4_2_8P4_RC1 + + ntpq/ntpq.man.in@1.332 +3 -3 + NTP_4_2_8P4_RC1 + + ntpq/ntpq.mdoc.in@1.332 +2 -2 + NTP_4_2_8P4_RC1 + + ntpsnmpd/invoke-ntpsnmpd.texi@1.499 +2 -2 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd-opts.c@1.517 +68 -68 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd-opts.h@1.516 +3 -3 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.328 +3 -3 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.328 +2 -2 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd.html@1.168 +1 -1 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd.man.in@1.328 +3 -3 + NTP_4_2_8P4_RC1 + + ntpsnmpd/ntpsnmpd.mdoc.in@1.328 +2 -2 + NTP_4_2_8P4_RC1 + + packageinfo.sh@1.517 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.89 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.90 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/calc_tickadj/calc_tickadj.html@1.91 +1 -1 + NTP_4_2_8P4_RC1 + + scripts/calc_tickadj/calc_tickadj.man.in@1.88 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/calc_tickadj/calc_tickadj.mdoc.in@1.90 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/calc_tickadj/invoke-calc_tickadj.texi@1.93 +1 -1 + NTP_4_2_8P4_RC1 + + scripts/invoke-plot_summary.texi@1.110 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/invoke-summary.texi@1.110 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/invoke-ntp-wait.texi@1.320 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/ntp-wait-opts@1.56 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/ntp-wait.1ntp-waitman@1.317 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.318 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/ntp-wait.html@1.337 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/ntp-wait.man.in@1.317 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/ntp-wait/ntp-wait.mdoc.in@1.318 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/invoke-ntpsweep.texi@1.108 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/ntpsweep-opts@1.58 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/ntpsweep.1ntpsweepman@1.96 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.96 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/ntpsweep.html@1.109 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/ntpsweep.man.in@1.96 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/ntpsweep/ntpsweep.mdoc.in@1.97 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/invoke-ntptrace.texi@1.109 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/ntptrace-opts@1.58 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/ntptrace.1ntptraceman@1.96 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/ntptrace.1ntptracemdoc@1.97 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/ntptrace.html@1.110 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/ntptrace.man.in@1.96 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/ntptrace/ntptrace.mdoc.in@1.98 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/plot_summary-opts@1.58 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/plot_summary.1plot_summaryman@1.108 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/plot_summary.1plot_summarymdoc@1.108 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/plot_summary.html@1.111 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/plot_summary.man.in@1.108 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/plot_summary.mdoc.in@1.108 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/summary-opts@1.58 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/summary.1summaryman@1.108 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/summary.1summarymdoc@1.108 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/summary.html@1.111 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/summary.man.in@1.108 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/summary.mdoc.in@1.108 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/update-leap/invoke-update-leap.texi@1.9 +1 -1 + NTP_4_2_8P4_RC1 + + scripts/update-leap/update-leap-opts@1.9 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/update-leap/update-leap.1update-leapman@1.9 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/update-leap/update-leap.1update-leapmdoc@1.9 +2 -2 + NTP_4_2_8P4_RC1 + + scripts/update-leap/update-leap.html@1.9 +1 -1 + NTP_4_2_8P4_RC1 + + scripts/update-leap/update-leap.man.in@1.9 +3 -3 + NTP_4_2_8P4_RC1 + + scripts/update-leap/update-leap.mdoc.in@1.9 +2 -2 + NTP_4_2_8P4_RC1 + + sntp/invoke-sntp.texi@1.497 +2 -2 + NTP_4_2_8P4_RC1 + + sntp/sntp-opts.c@1.516 +159 -159 + NTP_4_2_8P4_RC1 + + sntp/sntp-opts.h@1.514 +3 -3 + NTP_4_2_8P4_RC1 + + sntp/sntp.1sntpman@1.332 +3 -3 + NTP_4_2_8P4_RC1 + + sntp/sntp.1sntpmdoc@1.332 +2 -2 + NTP_4_2_8P4_RC1 + + sntp/sntp.html@1.512 +2 -2 + NTP_4_2_8P4_RC1 + + sntp/sntp.man.in@1.332 +3 -3 + NTP_4_2_8P4_RC1 + + sntp/sntp.mdoc.in@1.332 +2 -2 + NTP_4_2_8P4_RC1 + + util/invoke-ntp-keygen.texi@1.500 +2 -2 + NTP_4_2_8P4_RC1 + + util/ntp-keygen-opts.c@1.518 +173 -173 + NTP_4_2_8P4_RC1 + + util/ntp-keygen-opts.h@1.516 +3 -3 + NTP_4_2_8P4_RC1 + + util/ntp-keygen.1ntp-keygenman@1.328 +3 -3 + NTP_4_2_8P4_RC1 + + util/ntp-keygen.1ntp-keygenmdoc@1.328 +2 -2 + NTP_4_2_8P4_RC1 + + util/ntp-keygen.html@1.174 +2 -2 + NTP_4_2_8P4_RC1 + + util/ntp-keygen.man.in@1.328 +3 -3 + NTP_4_2_8P4_RC1 + + util/ntp-keygen.mdoc.in@1.328 +2 -2 + NTP_4_2_8P4_RC1 + +ChangeSet@1.3558.3.1, 2015-10-06 05:40:23-04:00, stenn@deacon.udel.edu + Prepare for 4.2.8p4-RC1 + + ChangeLog@1.1743.3.1 +1 -0 + Prepare for 4.2.8p4-RC1 + + NEWS@1.147 +143 -4 + Prepare for 4.2.8p4-RC1 + + packageinfo.sh@1.516 +1 -1 + Prepare for 4.2.8p4-RC1 + +ChangeSet@1.3568, 2015-10-06 08:51:27+00:00, stenn@psp-deb1.ntp.org + [Sec 2922] decodenetnum() will ASSERT botch instead of returning FAIL on some bogus values. Harlan Stenn. + + ChangeLog@1.1752 +2 -0 + [Sec 2922] decodenetnum() will ASSERT botch instead of returning FAIL on some [Sec 2922] decodenetnum() will ASSERT botch instead of returning FAIL on some bogus values. Harlan Stenn. + + libntp/decodenetnum.c@1.18 +4 -1 + [Sec 2922] decodenetnum() will ASSERT botch instead of returning FAIL on some [Sec 2922] decodenetnum() will ASSERT botch instead of returning FAIL on some bogus values. Harlan Stenn. + +ChangeSet@1.3567, 2015-10-06 08:02:23+00:00, stenn@psp-deb1.ntp.org + Log incoming packets that fail TEST2. Harlan Stenn. + + ChangeLog@1.1751 +1 -1 + Log incoming packets that fail TEST2. Harlan Stenn. + + ntpd/ntp_proto.c@1.367 +7 -1 + Log incoming packets that fail TEST2. Harlan Stenn. + +ChangeSet@1.3566, 2015-10-06 07:47:24+00:00, stenn@psp-deb1.ntp.org + cleanup + + ChangeLog@1.1750 +2 -1 + cleanup + + ntpd/ntp_proto.c@1.366 +113 -95 + cleanup + +ChangeSet@1.3564, 2015-10-06 03:56:29+00:00, stenn@psp-deb1.ntp.org + [Sec 2921] TALOS-CAN-0065: password length memory corruption. JPerlinger. + + ChangeLog@1.1748 +1 -0 + [Sec 2921] TALOS-CAN-0065: password length memory corruption. JPerlinger. + Fixed as part of [Sec 2916] TALOS-CAN-0054: memory corruption in password store. JPerlinger. + +ChangeSet@1.3562, 2015-10-05 21:11:21+00:00, stenn@psp-deb1.ntp.org + typo + + libntp/authreadkeys.c@1.22 +1 -1 + typo + +ChangeSet@1.3552.9.2, 2015-10-05 11:11:54+00:00, stenn@psp-deb1.ntp.org + 2909 is a security bug + + ChangeLog@1.1739.5.2 +1 -1 + 2909 is a security bug + +ChangeSet@1.3558.2.2, 2015-10-05 11:03:39+00:00, stenn@psp-deb1.ntp.org + 2902 is a security bug + + ChangeLog@1.1743.2.2 +2 -2 + 2902 is a security bug + +ChangeSet@1.3558.1.4, 2015-10-05 10:49:30+00:00, stenn@psp-deb1.ntp.org + Update the ChangeLog for 2899 + + ChangeLog@1.1743.1.4 +1 -1 + Update the ChangeLog for 2899 + +ChangeSet@1.3552.4.2, 2015-10-05 10:32:02+00:00, stenn@psp-deb1.ntp.org + typos + + ntpd/ntp_crypto.c@1.183 +4 -4 + typos + +ChangeSet@1.3558.1.2, 2015-10-05 06:26:46+00:00, stenn@psp-deb1.ntp.org + [Bug 2912] no munlockall() under Windows. David Taylor, Harlan Stenn. + + ChangeLog@1.1743.1.2 +1 -0 + [Bug 2912] no munlockall() under Windows. David Taylor, Harlan Stenn. + + ntpd/ntp_config.c@1.335 +4 -0 + [Bug 2912] no munlockall() under Windows. David Taylor, Harlan Stenn. + +ChangeSet@1.3561, 2015-10-03 09:08:20+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0055] Infinite loop if extended logging enabled and the logfile and keyfile are the same + + ChangeLog@1.1746 +2 -0 + [TALOS-CAN-0055] Infinite loop if extended logging enabled and the logfile and keyfile are the same + + include/ntp_stdlib.h@1.79 +1 -0 + [TALOS-CAN-0055] Infinite loop if extended logging enabled and the logfile and keyfile are the same + - add 'mvsyslog()' function to make wrapping calls to syslog easier + + include/ntp_syslog.h@1.9 +1 -0 + [TALOS-CAN-0055] Infinite loop if extended logging enabled and the logfile and keyfile are the same + - add 'mvsyslog()' function to make wrapping calls to syslog easier + + libntp/authreadkeys.c@1.21 +71 -18 + [TALOS-CAN-0055] Infinite loop if extended logging enabled and the logfile and keyfile are the same + - Avoid endless loop by logging only the first 5 errors explicitely, counting the next 10 silently, and aborting + the parsing of the file with proper diagnostic when more than 15 errors where encountered. + + libntp/msyslog.c@1.53 +12 -0 + [TALOS-CAN-0055] Infinite loop if extended logging enabled and the logfile and keyfile are the same + - add 'mvsyslog()' function to make wrapping calls to syslog easier + +ChangeSet@1.3558.1.1, 2015-10-01 03:27:35-04:00, stenn@deacon.udel.edu + build system tweaks. Harlan Stenn. + + ChangeLog@1.1743.1.1 +2 -1 + build system tweaks. Harlan Stenn. + + Makefile.am@1.134 +1 -1 + build system tweaks. Harlan Stenn. + + sntp/m4/ntp_problemtests.m4@1.3 +14 -14 + build system tweaks. Harlan Stenn. + +ChangeSet@1.3560, 2015-09-30 22:47:45+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0062] prevent directory traversal for VMS, too, when using 'saveconfig' command. + + ChangeLog@1.1745 +2 -0 + [TALOS-CAN-0062] prevent directory traversal for VMS, too, when using 'saveconfig' command. + + ntpd/ntp_control.c@1.204 +25 -9 + [TALOS-CAN-0062] prevent directory traversal for VMS, too, when using 'saveconfig' command. + +ChangeSet@1.3559, 2015-09-30 21:55:09+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0064] signed/unsiged clash could lead to buffer overun + + BitKeeper/etc/ignore@1.89 +4 -0 + keep cscope files away from repo + + ChangeLog@1.1744 +2 -0 + [TALOS-CAN-0064] signed/unsiged clash could lead to buffer overun + + ntpd/ntp_io.c@1.408 +9 -6 + [TALOS-CAN-0064] signed/unsiged clash could lead to buffer overun + +ChangeSet@1.3552.11.4, 2015-09-30 20:15:13+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0063] avoid buffer overrun in ntpq + + ChangeLog@1.1739.7.3 +1 -0 + [TALOS-CAN-0063] avoid buffer overrun in ntpq + + ntpq/ntpq.c@1.162 +6 -1 + [TALOS-CAN-0063] avoid buffer overrun in ntpq + +ChangeSet@1.3552.11.3, 2015-09-30 18:44:18+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0054] memory corruption + - make sure there's *always* a new buffer for storing the key again + + libntp/authkeys.c@1.27 +9 -5 + [TALOS-CAN-0054] memory corruption + - make sure there's *always* a new buffer for storing the key again + +ChangeSet@1.3552.1.32, 2015-09-30 07:40:52+00:00, stenn@psp-deb1.ntp.org + formatting cleanup + + ChangeLog@1.1739.1.18 +1 -1 + formatting cleanup + +ChangeSet@1.3552.12.2, 2015-09-30 06:45:59+00:00, stenn@psp-deb1.ntp.org + Implement --disable-problem-tests (off by default). Harlan Stenn. + + ChangeLog@1.1739.8.1 +1 -0 + Implement --disable-problem-tests (off by default). Harlan Stenn. + + sntp/m4/ntp_problemtests.m4@1.2 +20 -6 + Implement --disable-problem-tests (off by default). Harlan Stenn. + +ChangeSet@1.3552.12.1, 2015-09-30 06:11:05+00:00, stenn@psp-deb1.ntp.org + whitespace cleanup + + ntpd/ntp_io.c@1.407 +13 -13 + whitespace cleanup + +ChangeSet@1.3552.11.2, 2015-09-29 23:13:13+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0054] memory corruption in password store + + ChangeLog@1.1739.7.2 +1 -0 + [TALOS-CAN-0054] memory corruption in password store + + libntp/authkeys.c@1.26 +4 -0 + [TALOS-CAN-0054] memory corruption in password store + - make sure deallocated pointers are NULLed and new storage is allocated on demand + +ChangeSet@1.3552.11.1, 2015-09-29 22:00:10+02:00, jnperlin@hydra.localnet + [TALOS-CAN-0052] crash by loop counter underrun. + + ChangeLog@1.1739.7.1 +1 -0 + [TALOS-CAN-0052] crash by loop counter underrun. + + ntpd/ntp_request.c@1.114 +7 -3 + [TALOS-CAN-0052] crash by loop counter underrun. + - add missing reload of loop counter + +ChangeSet@1.3552.10.2, 2015-09-29 20:34:05+02:00, jnperlin@hydra.localnet + [Bug 2902] configuration directives "pidfile" and "driftfile" should be local-only. + + ChangeLog@1.1739.6.2 +2 -0 + [Bug 2902] configuration directives "pidfile" and "driftfile" should be local-only. + + ntpd/ntp_parser.c@1.99 +235 -226 + [Bug 2902] configuration directives "pidfile" and "driftfile" should be local-only. + - update bison-generated files + + ntpd/ntp_parser.h@1.64 +3 -5 + [Bug 2902] configuration directives "pidfile" and "driftfile" should be local-only. + - update bison-generated files + + ntpd/ntp_parser.y@1.89 +26 -15 + [Bug 2902] configuration directives "pidfile" and "driftfile" should be local-only. + - applied patch from Miroslav Lichvar, plus minor cosmetic changes + +ChangeSet@1.3552.10.1, 2015-09-29 06:10:38-04:00, stenn@pogo.udel.edu + Disable certain test programs on certain platforms. Harlan Stenn. + + ChangeLog@1.1739.6.1 +1 -0 + Disable certain test programs on certain platforms. Harlan Stenn. + + configure.ac@1.602 +2 -0 + Disable certain test programs on certain platforms. Harlan Stenn. + + sntp/m4/ntp_problemtests.m4@1.1 +42 -0 + BitKeeper file /pogo/users/stenn/ntp-stable/sntp/m4/ntp_problemtests.m4 + + sntp/m4/ntp_problemtests.m4@1.0 +0 -0 + + tests/ntpd/Makefile.am@1.28 +14 -3 + Disable certain test programs on certain platforms. Harlan Stenn. + +ChangeSet@1.3552.9.1, 2015-09-28 18:22:06+02:00, jnperlin@hydra.localnet + [Bug 2909] - Slow memory leak in CRYPTO_ASSOC + - added missing call to 'free()' in ntp_crypto.c. + + ChangeLog@1.1739.5.1 +1 -0 + [Bug 2909] - Slow memory leak in CRYPTO_ASSOC + - added missing call to 'free()' in ntp_crypto.c. + + ntpd/ntp_crypto.c@1.181.1.1 +1 -0 + [Bug 2909] - Slow memory leak in CRYPTO_ASSOC + - added missing call to 'free()' in ntp_crypto.c. + +ChangeSet@1.3556, 2015-09-27 12:52:27+02:00, jnperlin@hydra.localnet + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/buftvtots.c@1.5 +7 -7 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/calendar.c@1.9 +45 -35 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/clocktime.c@1.8 +16 -16 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/hextolfp.c@1.9 +9 -9 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/lfptostr.c@1.7 +14 -14 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/prettydate.c@1.4 +1 -1 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/strtolfp.c@1.6 +3 -3 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/tstotv.c@1.4 +3 -3 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/tvtots.c@1.6 +10 -10 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + + tests/libntp/uglydate.c@1.8 +1 -1 + [Bug2888] Fixed compiler warnings, converted C++ comments to C comments + +ChangeSet@1.3552.8.1, 2015-09-27 02:30:13+00:00, mayer@psp-deb1.ntp.org + Drop invalid packet before checking KoD. Check for all KoD's + + ChangeLog@1.1739.4.1 +1 -0 + Drop invalid packet before checking KoD. Check for all KoD's + + ntpd/ntp_proto.c@1.365 +66 -9 + Drop invalid packet before checking KoD. Check for all KoD's + +ChangeSet@1.3552.1.29, 2015-09-26 13:17:13+00:00, perlinger@psp-deb1.ntp.org + [bug2332] Create & cancel a dummy thread to warm-up the pthread runtime + instead of linking against libgcc_s on Linux targets + + ChangeLog@1.1739.1.15 +3 -0 + [Bug2332](reopened) fixed + + ntpd/ntpd.c@1.165 +74 -0 + [bug2332] Create & cancel a dummy thread to warm-up the pthread runtime + + sntp/m4/ntp_libntp.m4@1.32 +0 -14 + [bug2332] Remove the forced link against 'libgcc_s' since it breaks other targets + +ChangeSet@1.3552.7.6, 2015-09-25 06:51:35+00:00, stenn@psp-deb1.ntp.org + gcc on older HPUX may need +allowdups. Harlan Stenn. + + sntp/m4/os_cflags.m4@1.12 +1 -1 + gcc on older HPUX may need +allowdups. Harlan Stenn. + +ChangeSet@1.3552.7.5, 2015-09-25 04:21:37+00:00, stenn@psp-deb1.ntp.org + Adding missing MCAST protection. Harlan Stenn. + + ChangeLog@1.1739.1.14 +1 -0 + Adding missing MCAST protection. Harlan Stenn. + + ntpd/ntp_io.c@1.406 +2 -0 + Adding missing MCAST protection. Harlan Stenn. + +ChangeSet@1.3552.7.4, 2015-09-25 04:13:23+00:00, stenn@psp-deb1.ntp.org + gcc on older HPUX may need +allowdups. Harlan Stenn. + + ChangeLog@1.1739.1.13 +1 -0 + gcc on older HPUX may need +allowdups. Harlan Stenn. + + sntp/m4/os_cflags.m4@1.11 +32 -2 + gcc on older HPUX may need +allowdups. Harlan Stenn. + +ChangeSet@1.3552.7.3, 2015-09-24 11:27:07+00:00, stenn@psp-deb1.ntp.org + More updates for bug 2817. Harlan Stenn. + + ntpd/ntpd.c@1.164 +1 -1 + More updates for bug 2817. Harlan Stenn. + +ChangeSet@1.3552.7.2, 2015-09-24 10:27:51+00:00, stenn@psp-deb1.ntp.org + More updates for bug 2817. Harlan Stenn. + + ntpd/ntpd.c@1.163 +6 -3 + More updates for bug 2817. Harlan Stenn. + +ChangeSet@1.3552.7.1, 2015-09-24 05:44:53+00:00, stenn@psp-deb1.ntp.org + Fix bugs in tests/ntpd/ntp_prio_q.c. Harlan Stenn. + + ChangeLog@1.1739.1.12 +1 -0 + Fix bugs in tests/ntpd/ntp_prio_q.c. Harlan Stenn. + + tests/ntpd/ntp_prio_q.c@1.2 +8 -7 + Fix bugs in tests/ntpd/ntp_prio_q.c. Harlan Stenn. + +ChangeSet@1.3552.1.23, 2015-09-23 07:49:24-04:00, stenn@deacon.udel.edu + More updates for bug 2817. Harlan Stenn. + + sntp/m4/ntp_rlimit.m4@1.5 +5 -5 + More updates for bug 2817. Harlan Stenn. + +ChangeSet@1.3552.1.22, 2015-09-23 10:29:51+00:00, stenn@psp-deb1.ntp.org + More updates for bug 2817. Harlan Stenn. + + ChangeLog@1.1739.1.11 +1 -0 + More updates for bug 2817. Harlan Stenn. + + html/miscopt.html@1.83 +2 -2 + More updates for bug 2817. Harlan Stenn. + + include/ntp_config.h@1.83 +2 -2 + More updates for bug 2817. Harlan Stenn. + + ntpd/invoke-ntp.conf.texi@1.190 +8 -5 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntp.conf.5man@1.224 +9 -6 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntp.conf.5mdoc@1.224 +9 -6 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntp.conf.def@1.20 +6 -3 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntp.conf.man.in@1.224 +9 -6 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntp.conf.mdoc.in@1.224 +9 -6 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntp_config.c@1.334 +26 -4 + More updates for bug 2817. Harlan Stenn. + + ntpd/ntpd.c@1.162 +1 -1 + More updates for bug 2817. Harlan Stenn. + + sntp/m4/ntp_rlimit.m4@1.4 +2 -2 + More updates for bug 2817. Harlan Stenn. + +ChangeSet@1.3552.1.21, 2015-09-21 10:53:44+00:00, stenn@psp-deb1.ntp.org + Update the patch for bug 2817. Harlan Stenn. + + ChangeLog@1.1739.1.10 +1 -0 + Update the patch for bug 2817. Harlan Stenn. + + configure.ac@1.601 +0 -54 + Update the patch for bug 2817. Harlan Stenn. + + sntp/m4/ntp_rlimit.m4@1.3 +57 -2 + Update the patch for bug 2817. Harlan Stenn. + +ChangeSet@1.3552.1.20, 2015-09-21 10:30:35+00:00, stenn@psp-deb1.ntp.org + Clean trailing whitespace in tests/ntpd/Makefile.am. Harlan Stenn. + + ChangeLog@1.1739.1.9 +1 -0 + Clean trailing whitespace in tests/ntpd/Makefile.am. Harlan Stenn. + + tests/ntpd/Makefile.am@1.27 +5 -5 + Clean trailing whitespace in tests/ntpd/Makefile.am. Harlan Stenn. + +ChangeSet@1.3552.1.19, 2015-09-21 08:09:33+00:00, stenn@psp-deb1.ntp.org + Fix progname definition in unity runner scripts. Harlan Stenn. + + ChangeLog@1.1739.1.8 +1 -0 + Fix progname definition in unity runner scripts. Harlan Stenn. + + sntp/tests/run-packetProcessing.c@1.9 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + sntp/tests/run-t-log.c@1.3 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + sntp/unity/auto/generate_test_runner.rb@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-a_md5encrypt.c@1.14 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-atoint.c@1.8 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-atouint.c@1.9 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-authkeys.c@1.11 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-buftvtots.c@1.6 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-calendar.c@1.8.1.1 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-caljulian.c@1.13 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-caltontp.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-calyearstart.c@1.7 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-clocktime.c@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-decodenetnum.c@1.9 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-hextoint.c@1.9 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-hextolfp.c@1.8 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-humandate.c@1.6 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-lfpfunc.c@1.17 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-lfptostr.c@1.7 +12 -12 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-modetoa.c@1.11 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-msyslog.c@1.8 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-netof.c@1.7 +2 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-numtoa.c@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-numtohost.c@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-octtoint.c@1.7 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-prettydate.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-recvbuff.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-refidsmear.c@1.6 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-refnumtoa.c@1.8 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-sfptostr.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-socktoa.c@1.12 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-ssl_init.c@1.9 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-statestr.c@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-strtolfp.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-timespecops.c@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-timevalops.c@1.12 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-tstotv.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-tvtots.c@1.6 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-uglydate.c@1.10 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-vi64ops.c@1.8 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/libntp/run-ymd2yd.c@1.11 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/ntpd/run-leapsec.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/ntpd/run-ntp_prio_q.c@1.4 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/ntpd/run-rc_cmdlength.c@1.3 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/ntpd/run-t-ntp_scanner.c@1.5 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/ntpd/run-t-ntp_signd.c@1.8 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + + tests/ntpq/run-t-ntpq.c@1.3 +1 -1 + Fix progname definition in unity runner scripts. Harlan Stenn. + +ChangeSet@1.3552.1.18, 2015-09-21 08:06:14+00:00, stenn@psp-deb1.ntp.org + Pthread autoconf macro cleanup. Harlan Stenn. + + ChangeLog@1.1739.1.7 +1 -0 + Pthread autoconf macro cleanup. Harlan Stenn. + + sntp/m4/ntp_libevent.m4@1.15 +15 -19 + Pthread autoconf macro cleanup. Harlan Stenn. + + sntp/m4/ntp_libntp.m4@1.31 +5 -2 + Pthread autoconf macro cleanup. Harlan Stenn. + + sntp/m4/openldap-thread-check.m4@1.7 +6 -0 + Pthread autoconf macro cleanup. Harlan Stenn. + +ChangeSet@1.3552.1.16, 2015-09-17 11:09:07+00:00, stenn@psp-deb1.ntp.org + Avoid spurious SCCS get + + ntpd/Makefile.am@1.134 +3 -0 + Avoid spurious SCCS get + +ChangeSet@1.3552.6.3, 2015-09-16 11:10:41+00:00, stenn@psp-deb1.ntp.org + Cleanup various test Makefile.am files. Harlan Stenn. + + ChangeLog@1.1739.1.6 +1 -0 + Cleanup various test Makefile.am files. Harlan Stenn. + + sntp/tests/Makefile.am@1.64.1.3 +5 -5 + Cleanup various test Makefile.am files. Harlan Stenn. + + tests/libntp/Makefile.am@1.93 +23 -23 + Cleanup various test Makefile.am files. Harlan Stenn. + + tests/ntpd/Makefile.am@1.22.1.3 +7 -12 + Cleanup various test Makefile.am files. Harlan Stenn. + + tests/ntpq/Makefile.am@1.5.1.1 +3 -10 + Cleanup various test Makefile.am files. Harlan Stenn. + +ChangeSet@1.3552.6.2, 2015-09-15 10:44:48+00:00, stenn@psp-deb1.ntp.org + Unit test dist cleanup. Harlan Stenn + + ChangeLog@1.1739.1.5 +1 -0 + Unit test dist cleanup. Harlan Stenn + + sntp/configure.ac@1.82 +1 -0 + Unit test dist cleanup. Harlan Stenn + + sntp/tests/Makefile.am@1.64.1.2 +2 -0 + Unit test dist cleanup. Harlan Stenn + + tests/Makefile.am@1.17.1.1 +1 -0 + Unit test dist cleanup. Harlan Stenn + + tests/ntpd/Makefile.am@1.22.1.2 +0 -9 + Unit test dist cleanup. Harlan Stenn + +ChangeSet@1.3552.5.6, 2015-09-15 07:45:39+00:00, stenn@psp-deb1.ntp.org + [Bug 2906] make check needs better support for pthreads. Harlan Stenn. + + sntp/m4/ntp_libevent.m4@1.14 +23 -0 + [Bug 2906] make check needs better support for pthreads. Harlan Stenn. + +ChangeSet@1.3552.5.5, 2015-09-15 07:12:08+00:00, stenn@psp-deb1.ntp.org + documentation notes + + sntp/m4/openldap-thread-check.m4@1.6 +3 -0 + documentation notes + +ChangeSet@1.3552.5.4, 2015-09-14 06:36:37+00:00, stenn@psp-deb1.ntp.org + [Bug 2906] "make check" needs better support for pthreads + + ChangeLog@1.1739.3.4 +1 -0 + [Bug 2906] "make check" needs better support for pthreads + + sntp/m4/ntp_libevent.m4@1.13 +2 -0 + [Bug 2906] "make check" needs better support for pthreads + + sntp/tests/Makefile.am@1.62.2.1 +5 -0 + [Bug 2906] "make check" needs better support for pthreads + + tests/libntp/Makefile.am@1.90.1.1 +12 -12 + [Bug 2906] "make check" needs better support for pthreads + + tests/ntpd/Makefile.am@1.12.3.1 +4 -2 + [Bug 2906] "make check" needs better support for pthreads + +ChangeSet@1.3552.5.3, 2015-09-14 05:50:02+00:00, stenn@psp-deb1.ntp.org + [Bug 2907] dist* build targets require our libevent/ to be enabled. HStenn. + + ChangeLog@1.1739.3.3 +1 -0 + [Bug 2907] dist* build targets require our libevent/ to be enabled. HStenn. + + sntp/Makefile.am@1.86.1.1 +7 -4 + [Bug 2907] dist* build targets require our libevent/ to be enabled. HStenn. + +ChangeSet@1.3552.5.2, 2015-09-13 22:11:31+00:00, stenn@psp-deb1.ntp.org + Autoconf cleanup + + ChangeLog@1.1739.3.2 +1 -0 + Autoconf cleanup + + configure.ac@1.598.1.1 +1 -0 + Autoconf cleanup + +ChangeSet@1.3552.5.1, 2015-09-13 22:10:03+00:00, stenn@psp-deb1.ntp.org + Update the NEWS file + + ChangeLog@1.1739.3.1 +1 -0 + Update the NEWS file + + NEWS@1.146 +14 -0 + Update the NEWS file + +ChangeSet@1.3552.1.15, 2015-08-20 17:13:37+02:00, viperus@ubuntu.(none) + t-ntp_scanner.c: + Rename: tests/ntpd/ntp_scanner.c -> tests/ntpd/t-ntp_scanner.c + new static functions tested + run-t-ntp_scanner.c: + Rename: tests/ntpd/run-ntp_scanner.c -> tests/ntpd/run-t-ntp_scanner.c + Makefile.am: + updates required for include *.c to work + run-t-ntp_scanner.c: + update + + tests/ntpd/Makefile.am@1.25 +6 -5 + updates required for include *.c to work + + tests/ntpd/run-t-ntp_scanner.c@1.4 +18 -7 + update + + tests/ntpd/run-t-ntp_scanner.c@1.3 +0 -0 + Rename: tests/ntpd/run-ntp_scanner.c -> tests/ntpd/run-t-ntp_scanner.c + + tests/ntpd/t-ntp_scanner.c@1.5 +73 -2 + new static functions tested + + tests/ntpd/t-ntp_scanner.c@1.4 +0 -0 + Rename: tests/ntpd/ntp_scanner.c -> tests/ntpd/t-ntp_scanner.c + +ChangeSet@1.3552.1.14, 2015-08-20 16:35:29+02:00, viperus@ubuntu.(none) + t-ntpq.c: + disabled for now, very trick to test static functions. + run-t-ntpq.c: + update + ntp_scanner.c: + added new test + Makefile.am: + added more include dirs + + tests/ntpd/ntp_scanner.c@1.3 +11 -3 + added new test + + tests/ntpq/Makefile.am@1.7 +2 -3 + added more include dirs + + tests/ntpq/run-t-ntpq.c@1.2 +1 -2 + update + + tests/ntpq/t-ntpq.c@1.3 +25 -2 + disabled for now, very trick to test static functions. + +ChangeSet@1.3552.1.13, 2015-08-20 10:15:12+02:00, viperus@ubuntu.(none) + http-server.c: + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + Many files: + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/sample/http-server.c@1.12 +6 -2 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + sntp/libevent/test/bench_httpclient.c@1.8 +5 -1 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/test/regress.c@1.8 +6 -2 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/test/regress_dns.c@1.10 +6 -5 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/test/regress_http.c@1.10 +8 -4 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/test/regress_minheap.c@1.5 +2 -1 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/test/test-ratelim.c@1.11 +6 -2 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + + sntp/libevent/test/test-time.c@1.7 +2 -1 + reverted emalloc (and similar) to malloc + added checks if malloc is NULL, because emalloc is not linked here. + + +ChangeSet@1.3552.1.12, 2015-08-20 01:10:57+02:00, viperus@ubuntu.(none) + Makefile.am: + added 2 more temp files to CLEANFILES and DISTCLEAN, because it prevented make distcheck from finishing properly + pathfind.c: + reverted emalloc to malloc with if(result == NULL)... because sntp/ doesn't link libntp...probably for a reason unknown to me. + + sntp/libopts/compat/pathfind.c@1.13 +17 -6 + reverted emalloc to malloc with if(result == NULL)... because sntp/ doesn't link libntp...probably for a reason unknown to me. + + sntp/tests/Makefile.am@1.65 +4 -0 + added 2 more temp files to CLEANFILES and DISTCLEAN, because it prevented make distcheck from finishing properly + +ChangeSet@1.3552.1.11, 2015-08-20 01:04:40+02:00, viperus@ubuntu.(none) + run-packetProcessing.c: + manually updated due to char / const char progname issues when autogenerating + Makefile.am: + re-enabled ntpq dir + + sntp/tests/run-packetProcessing.c@1.8 +1 -1 + manually updated due to char / const char progname issues when autogenerating + + tests/Makefile.am@1.18 +1 -0 + re-enabled ntpq dir + +ChangeSet@1.3552.1.10, 2015-08-20 00:23:42+02:00, viperus@ubuntu.(none) + machines.c: + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + Many files: + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + libntp/machines.c@1.26 +3 -3 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + ntpd/refclock_palisade.c@1.43 +2 -2 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + ntpq/ntpq.c@1.161 +7 -7 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/sample/http-server.c@1.11 +2 -2 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/bench_httpclient.c@1.7 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/regress.c@1.7 +2 -2 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/regress_dns.c@1.9 +4 -4 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/regress_http.c@1.9 +3 -3 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/regress_minheap.c@1.4 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/test-ratelim.c@1.10 +2 -2 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libevent/test/test-time.c@1.6 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/libopts/compat/pathfind.c@1.12 +5 -5 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/tests/fileHandlingTest.c@1.3 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + sntp/tests/packetProcessing.c@1.8 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + tests/libntp/a_md5encrypt.c@1.12 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + tests/libntp/calendar.c@1.6.1.1 +4 -4 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + + tests/libntp/caljulian.c@1.10 +1 -1 + Fixing bug 2898, replacing malloc with emalloc, calloc with emalloc_zero, strdup with estrup etc. + + +ChangeSet@1.3552.1.9, 2015-08-17 13:56:23+02:00, viperus@ubuntu.(none) + Makefile.am: + fixed minor typo which caused me a lot of headache + t-ntp_signd.c: + added a new test + run-t-ntp_signd.c: + autogen update + Makefile.am: + removed unnecessary CFLAG + t-ntp_signd.c: + minor update + + tests/ntpd/Makefile.am@1.24 +2 -1 + fixed minor typo which caused me a lot of headache + + tests/ntpd/Makefile.am@1.23 +0 -3 + removed unnecessary CFLAG + + tests/ntpd/run-t-ntp_signd.c@1.7 +10 -5 + autogen update + + tests/ntpd/t-ntp_signd.c@1.10 +23 -14 + added a new test + + tests/ntpd/t-ntp_signd.c@1.9 +10 -3 + minor update + +ChangeSet@1.3552.1.8, 2015-08-17 12:21:45+02:00, viperus@ubuntu.(none) + run-t-ntp_signd.c: + added more tests manually + + tests/ntpd/run-t-ntp_signd.c@1.6 +2 -1 + added more tests manually + + tests/ntpd/t-ntp_signd.c@1.8 +0 -1 + +ChangeSet@1.3552.1.7, 2015-08-17 12:15:56+02:00, viperus@ubuntu.(none) + t-ntp_signd.c: + adding more tests , added mocked functinos section + + tests/ntpd/t-ntp_signd.c@1.7 +34 -0 + adding more tests , added mocked functinos section + +ChangeSet@1.3552.1.6, 2015-08-17 11:28:21+02:00, viperus@ubuntu.(none) + t-ntp_signd.c: + new tests added + run-t-ntp_signd.c: + I had some issues with bk and this file + t-ntp_signd.c: + basic mocking concept added. connect() is mocked, and always returns 1 + + tests/ntpd/run-t-ntp_signd.c@1.5 +4 -2 + I had some issues with bk and this file + + tests/ntpd/t-ntp_signd.c@1.6 +13 -9 + basic mocking concept added. connect() is mocked, and always returns 1 + + tests/ntpd/t-ntp_signd.c@1.5 +22 -2 + new tests added + +ChangeSet@1.3552.4.1, 2015-08-17 07:54:01+02:00, jnperlin@hydra.(none) + CVE-2014-9297 + + ChangeLog@1.1739.2.1 +1 -0 + CVE-2014-9297 + + ntpd/ntp_crypto.c@1.182 +78 -27 + CVE-2014-9297: buffer overrun checks + +ChangeSet@1.3552.3.1, 2015-08-14 12:05:44+02:00, viperus@ubuntu.(none) + Makefile.am: + removed unnecessary CFLAGS + + tests/ntpq/Makefile.am@1.6 +0 -5 + removed unnecessary CFLAGS + +ChangeSet@1.3552.1.4, 2015-08-14 08:24:21+00:00, stenn@psp-at1.ntp.org + Unity test cleanup: move declaration of 'initializing'. Harlan Stenn. + + ChangeLog@1.1739.1.3 +1 -0 + Unity test cleanup: move declaration of 'initializing'. Harlan Stenn. + + ntpd/ntp_timer.c@1.92 +6 -0 + Unity test cleanup: move declaration of 'initializing'. Harlan Stenn. + + ntpd/ntpd.c@1.161 +0 -6 + Unity test cleanup: move declaration of 'initializing'. Harlan Stenn. + +ChangeSet@1.3552.1.3, 2015-08-10 13:15:13+02:00, viperus@ubuntu.(none) + run-ntp_util.c: + new file, I guess? + Makefile.am: + changes to harlan's makefile after merge + run-ntp_prio_q.c: + hopefully, fixes stuff. Why is this here? Did harlan pull something from tfendrich? + + tests/ntpd/Makefile.am@1.22 +13 -13 + changes to harlan's makefile after merge + + tests/ntpd/run-ntp_prio_q.c@1.3 +1 -1 + hopefully, fixes stuff. Why is this here? Did harlan pull something from tfendrich? + + tests/ntpd/run-ntp_util.c@1.1 +60 -0 + new file, I guess? + + tests/ntpd/run-ntp_util.c@1.0 +0 -0 + +ChangeSet@1.3552.2.1, 2015-08-10 09:50:16+00:00, stenn@psp-at1.ntp.org + Retire google test - phase I. Harlan Stenn. + + BitKeeper/deleted/07/g_packetHandling.cpp~2e07085e82bde6c@1.2 +0 -0 + Delete: sntp/tests/g_packetHandling.cpp + + BitKeeper/deleted/09/tvtots.cpp~c58754a7b62dde1c@1.9 +0 -0 + Delete: tests/libntp/g_tvtots.cpp + + BitKeeper/deleted/0a/sntptest.h~c408c7764b75cd4f@1.7 +0 -0 + Delete: sntp/tests/g_sntptest.h + + BitKeeper/deleted/0a/utilities.cpp~2657edd0f94e49eb@1.12 +0 -0 + Delete: sntp/tests/g_utilities.cpp + + BitKeeper/deleted/0c/buftvtots.cpp~eababa3e59583108@1.6 +0 -0 + Delete: tests/libntp/g_buftvtots.cpp + + BitKeeper/deleted/0f/uglydate.cpp~a0fdfbbfdc636411@1.5 +0 -0 + Delete: tests/libntp/g_uglydate.cpp + + BitKeeper/deleted/10/sfptostr.cpp~cef5595e4f89eac8@1.4 +0 -0 + Delete: tests/libntp/g_sfptostr.cpp + + BitKeeper/deleted/13/g_lfptostr.cpp~386d730e91bb76de@1.3 +0 -0 + Delete: tests/libntp/g_lfptostr.cpp + + BitKeeper/deleted/14/humandate.cpp~c3b455ca717b631a@1.5 +0 -0 + Delete: tests/libntp/g_humandate.cpp + + BitKeeper/deleted/15/g_nameresolution.cpp~23956912aa26e0b9@1.2 +0 -0 + Delete: sntp/tests/g_nameresolution.cpp + + BitKeeper/deleted/17/a_md5encrypt.cpp~1013ff09a55a7336@1.8 +0 -0 + Delete: tests/libntp/g_a_md5encrypt.cpp + + BitKeeper/deleted/1c/crypto.cpp~77bbd0102246a5@1.7 +0 -0 + Delete: sntp/tests/g_crypto.cpp + + BitKeeper/deleted/24/atoint.cpp~533534d530ae4081@1.5 +0 -0 + Delete: tests/libntp/g_atoint.cpp + + BitKeeper/deleted/29/networking.cpp~a6f1b3f0b76192c9@1.11 +0 -0 + Delete: sntp/tests/g_networking.cpp + + BitKeeper/deleted/29/refnumtoa.cpp~ed3c5e075503bdf4@1.5 +0 -0 + Delete: tests/libntp/g_refnumtoa.cpp + + BitKeeper/deleted/2d/libntptest.h~1990ef7fb70295d6@1.6 +0 -0 + Delete: tests/libntp/g_libntptest.h + + BitKeeper/deleted/30/g_recvbuff.cpp~7b0d3114520a0616@1.3 +0 -0 + Delete: tests/libntp/g_recvbuff.cpp + + BitKeeper/deleted/30/main.cpp~62ec7f38f7d49413@1.10 +0 -0 + Delete: sntp/tests_main.cpp + + BitKeeper/deleted/37/statestr.cpp~65497a98bac68a52@1.5 +0 -0 + Delete: tests/libntp/g_statestr.cpp + + BitKeeper/deleted/3b/tvalops.cpp~fa0bb1554d1d08d4@1.11 +0 -0 + Delete: tests/libntp/g_timevalops.cpp + + BitKeeper/deleted/3c/g_octtoint.cpp~8124d76dd2b395e5@1.3 +0 -0 + Delete: tests/libntp/g_octtoint.cpp + + BitKeeper/deleted/3f/calendar.cpp~72447c9b8c0deced@1.4 +0 -0 + Delete: tests/libntp/g_calendar.cpp + + BitKeeper/deleted/4e/g_hextolfp.cpp~ba8561698c15b354@1.3 +0 -0 + Delete: tests/libntp/g_hextolfp.cpp + + BitKeeper/deleted/57/ntpdtest.h~25bdfa3eeda7b121@1.3 +0 -0 + Delete: tests/ntpd/g_ntpdtest.h + + BitKeeper/deleted/5b/sockaddrtest.h~4bf7e82961607bf0@1.6 +0 -0 + Delete: tests/libntp/g_sockaddrtest.h + + BitKeeper/deleted/5f/authkeys.cpp~24496a9d93173937@1.10 +0 -0 + Delete: tests/libntp/g_authkeys.cpp + + BitKeeper/deleted/62/g_strtolfp.cpp~5a50a9b282094e7f@1.3 +0 -0 + Delete: tests/libntp/g_strtolfp.cpp + + BitKeeper/deleted/77/lfpfunc.cpp~9ed51f8dc31368eb@1.5 +0 -0 + Delete: tests/libntp/g_lfpfunc.cpp + + BitKeeper/deleted/82/clocktime.cpp~7dd85c09c049ffd4@1.7 +0 -0 + Delete: tests/libntp/g_clocktime.cpp + + BitKeeper/deleted/8b/atouint.cpp~43abc72d64a1857a@1.4 +0 -0 + Delete: tests/libntp/g_atouint.cpp + + BitKeeper/deleted/8b/leapsec.cpp~11be64d438063292@1.17 +0 -0 + Delete: tests/ntpd/g_leapsec.cpp + + BitKeeper/deleted/93/g_vi64ops.cpp~e023cb72bff45261@1.3 +0 -0 + Delete: tests/libntp/g_vi64ops.cpp + + BitKeeper/deleted/96/numtoa.cpp~b3b85b1ebc36fc2b@1.5 +0 -0 + Delete: tests/libntp/g_numtoa.cpp + + BitKeeper/deleted/98/g_tstotv.cpp~37896736f73c48b0@1.3 +0 -0 + Delete: tests/libntp/g_tstotv.cpp + + BitKeeper/deleted/9a/packetProcessing.cpp~4822a1d49ca16be5@1.8 +0 -0 + Delete: sntp/tests/g_packetProcessing.cpp + + BitKeeper/deleted/9c/kodDatabase.cpp~f9244577ca9f0aa9@1.6 +0 -0 + Delete: sntp/tests/g_kodDatabase.cpp + + BitKeeper/deleted/a4/g_msyslog.cpp~ec51c9e8395b3e4b@1.3 +0 -0 + Delete: tests/libntp/g_msyslog.cpp + + BitKeeper/deleted/ae/lfptest.h~a452179b90fdedaa@1.8 +0 -0 + Delete: tests/libntp/g_lfptest.h + + BitKeeper/deleted/af/calyearstart.cpp~586f44f58a75b25e@1.6 +0 -0 + Delete: tests/libntp/g_calyearstart.cpp + + BitKeeper/deleted/b2/ntpdtest.cpp~d4e605db974f754d@1.4 +0 -0 + Delete: tests/ntpd/g_ntpdtest.cpp + + BitKeeper/deleted/b3/timestructs.cpp~2bc53cc52f6599d5@1.7 +0 -0 + Delete: tests/libntp/g_timestructs.cpp + + BitKeeper/deleted/c1/ssl_init.cpp~81ce47bbb0e4fbbc@1.6 +0 -0 + Delete: tests/libntp/g_ssl_init.cpp + + BitKeeper/deleted/c3/modetoa.cpp~50f2955120b0ed6f@1.4 +0 -0 + Delete: tests/libntp/g_modetoa.cpp + + BitKeeper/deleted/c6/kodFile.cpp~c593859a65c8e9e3@1.11 +0 -0 + Delete: sntp/tests/g_kodFile.cpp + + BitKeeper/deleted/c9/main.h~44cc5c4040b89c30@1.9 +0 -0 + Delete: sntp/tests_main.h + + BitKeeper/deleted/ce/timestructs.h~a7213e57006326f@1.6 +0 -0 + Delete: tests/libntp/g_timestructs.h + + BitKeeper/deleted/cf/libntptest.cpp~fb911e064fe18517@1.6 +0 -0 + Delete: tests/libntp/g_libntptest.cpp + + BitKeeper/deleted/d0/g_caltontp.cpp~ea2471ca2734873a@1.3 +0 -0 + Delete: tests/libntp/g_caltontp.cpp + + BitKeeper/deleted/d8/hextoint.cpp~78aeb35b2f896bed@1.6 +0 -0 + Delete: tests/libntp/g_hextoint.cpp + + BitKeeper/deleted/dd/keyFile.cpp~7ca67d971ffc97ae@1.9 +0 -0 + Delete: sntp/tests/g_keyFile.cpp + + BitKeeper/deleted/e0/g_socktoa.cpp~9f28a4451c7f0c1a@1.3 +0 -0 + Delete: tests/libntp/g_socktoa.cpp + + BitKeeper/deleted/eb/g_prettydate.cpp~7800800c1dbf9688@1.3 +0 -0 + Delete: tests/libntp/g_prettydate.cpp + + BitKeeper/deleted/ee/caljulian.cpp~4c368703107f888@1.8 +0 -0 + Delete: tests/libntp/g_caljulian.cpp + + BitKeeper/deleted/ef/fileHandlingTest.h~212fb01783c1dfd7@1.7 +0 -0 + Delete: sntp/tests/g_fileHandlingTest.h + + BitKeeper/deleted/f6/g_decodenetnum.cpp~5b151a58bf8417a2@1.3 +0 -0 + Delete: tests/libntp/g_decodenetnum.cpp + + BitKeeper/deleted/f8/g_netof.cpp~a772fe4f2f1b84e8@1.3 +0 -0 + Delete: tests/libntp/g_netof.cpp + + BitKeeper/deleted/fa/tspecops.cpp~fabae81f65cd8134@1.11 +0 -0 + Delete: tests/libntp/g_timespecops.cpp + + BitKeeper/deleted/fd/ymd2yd.cpp~eeb76d1d2a534b6@1.4 +0 -0 + Delete: tests/libntp/g_ymd2yd.cpp + + BitKeeper/deleted/ff/numtohost.cpp~c346ee31ae5ffefe@1.4 +0 -0 + Delete: tests/libntp/g_numtohost.cpp + + ChangeLog@1.1739.1.2 +1 -1 + Retire google test - phase I. Harlan Stenn. + + ChangeLog@1.1739.1.1 +1 -0 + Retire google test - phase I + + sntp/Makefile.am@1.87 +0 -1 + Retire google test - phase I. Harlan Stenn. + + sntp/tests/Makefile.am@1.62.1.1 +15 -28 + Retire google test - phase I. Harlan Stenn. + + tests/Makefile.am@1.12.1.1 +0 -13 + Retire google test - phase I. Harlan Stenn. + + tests/libntp/Makefile.am@1.91 +0 -63 + Retire google test - phase I. Harlan Stenn. + + tests/ntpd/Makefile.am@1.12.2.1 +32 -50 + Retire google test - phase I. Harlan Stenn. + + tests/sandbox/Makefile.am@1.7 +14 -5 + Retire google test - phase I. Harlan Stenn. + +ChangeSet@1.3548.1.16, 2015-08-07 08:07:50+02:00, viperus@ubuntu.(none) + Makefile.am: + re-added ntpq, works now + run-t-ntpq.c: + added + Makefile.am: + minor cleanup + configure.ac: + added ntpq dir + + configure.ac@1.599 +1 -0 + added ntpq dir + + tests/Makefile.am@1.16 +2 -0 + re-added ntpq, works now + + tests/ntpq/Makefile.am@1.5 +0 -1 + minor cleanup + + tests/ntpq/run-t-ntpq.c@1.1 +55 -0 + added + + tests/ntpq/run-t-ntpq.c@1.0 +0 -0 + +ChangeSet@1.3548.1.15, 2015-08-06 21:42:18+02:00, viperus@ubuntu.(none) + Makefile.am: + removed ntpq becuase it doesnt work?! + + tests/Makefile.am@1.15 +0 -2 + removed ntpq becuase it doesnt work?! + +ChangeSet@1.3548.1.14, 2015-08-06 21:03:10+02:00, viperus@ubuntu.(none) + Makefile.am: + adding new Makefile + minor change + Makefile.am, t-ntpq.c: + update + + tests/Makefile.am@1.14 +1 -0 + update + + tests/ntpq/Makefile.am@1.4 +3 -1 + minor change + + tests/ntpq/Makefile.am@1.3 +6 -15 + adding new Makefile + + tests/ntpq/t-ntpq.c@1.2 +1 -1 + update + +ChangeSet@1.3548.1.13, 2015-08-06 20:41:02+02:00, viperus@ubuntu.(none) + socktoa.c: + fixed. Tests are skipped when you do ./build --disable-ipv6 + + t-ntpq.c: + new test file + decodenetnum.c: + fixed. Tests are skipped when you do ./build --disable-ipv6 + Makefile.am: + changes + run-t-log.c: + updated + + sntp/tests/run-t-log.c@1.2 +4 -3 + updated + + tests/libntp/decodenetnum.c@1.9 +3 -3 + fixed. Tests are skipped when you do ./build --disable-ipv6 + + tests/libntp/socktoa.c@1.9 +2 -2 + fixed. Tests are skipped when you do ./build --disable-ipv6 + + + tests/ntpq/Makefile.am@1.2 +8 -37 + changes + + tests/ntpq/t-ntpq.c@1.1 +14 -0 + new test file + + tests/ntpq/t-ntpq.c@1.0 +0 -0 + +ChangeSet@1.3548.1.12, 2015-08-06 20:24:05+02:00, viperus@ubuntu.(none) + log.c: + modified to allow calling of multiple atexit(cleanup_log) without causing a segfault. + t-log.c: + minor cleanup, fixes, stuff works (in combination with updated log.c) + + sntp/log.c@1.24 +15 -6 + modified to allow calling of multiple atexit(cleanup_log) without causing a segfault. + + sntp/tests/t-log.c@1.2 +13 -11 + minor cleanup, fixes, stuff works (in combination with updated log.c) + +ChangeSet@1.3548.1.11, 2015-08-06 10:27:35+02:00, viperus@ubuntu.(none) + Makefile.am: + small fix + socktoa.c, run-decodenetnum.c: + update + decodenetnum.c: + Minor changes due to the autogenerated ruby script + run-socktoa.c: + Minor changes due to the autogenerated ruby script + + + tests/libntp/decodenetnum.c@1.8 +22 -6 + Minor changes due to the autogenerated ruby script + + tests/libntp/run-decodenetnum.c@1.8 +4 -5 + update + + tests/libntp/run-socktoa.c@1.11 +7 -7 + Minor changes due to the autogenerated ruby script + + + tests/libntp/socktoa.c@1.8 +22 -6 + update + + tests/ntpd/Makefile.am@1.20 +0 -1 + small fix + +ChangeSet@1.3548.1.10, 2015-08-05 16:53:22+02:00, viperus@ubuntu.(none) + Makefile.am: + new file + added ntpq dir + added a new test, test-log + t-log.c: + removed the 2nd test because only one open_logfile per program can be used (segfault otherwise) + run-t-log.c: + new file, HAS ISSUES WITH CONST CHAR *progname. + + sntp/tests/Makefile.am@1.63 +11 -0 + added a new test, test-log + + sntp/tests/run-t-log.c@1.1 +56 -0 + new file, HAS ISSUES WITH CONST CHAR *progname. + + sntp/tests/run-t-log.c@1.0 +0 -0 + + sntp/tests/t-log.c@1.1 +66 -0 + removed the 2nd test because only one open_logfile per program can be used (segfault otherwise) + + sntp/tests/t-log.c@1.0 +0 -0 + + tests/Makefile.am@1.13 +2 -0 + added ntpq dir + + tests/ntpq/Makefile.am@1.1 +146 -0 + BitKeeper file /home/viperus/Desktop/ntp-stable-unity/tests/ntpq/Makefile.am + + tests/ntpq/Makefile.am@1.0 +0 -0 + +ChangeSet@1.3554, 2015-08-03 20:59:21+02:00, jnperlin@nemesis.localnet + [Bug 2888] streamline calendar functions + - MSVC compilation issue + + libntp/ntp_calendar.c@1.17 +3 -1 + [Bug 2888] streamline calendar functions + - 'uint' not known with MSVC; use u_int instead + +ChangeSet@1.3529.4.1, 2015-08-03 20:34:01+02:00, jnperlin@hydra.(none) + [Bug 2888] streamline calendar functions. + + ChangeLog@1.1725.2.1 +1 -1 + [Bug 2888] streamline calendar functions. + + include/ntp_calendar.h@1.18 +13 -0 + [Bug 2888] streamline calendar functions. + + libntp/ntp_calendar.c@1.16 +495 -321 + [Bug 2888] streamline calendar functions. + - reduce number of divisions for gregorian calendar + - rewrite divisions to use explicit 2's complement calculation via unsigned types + - avoid branches in calculations where possible + + tests/libntp/calendar.c@1.7 +211 -132 + [Bug 2888] streamline calendar functions. + - added tests for ISO8601 week calendar + - streamlined string formatting + - converted struct-by-value to struct-by-pointer in several cases + - fixed prototypes + + tests/libntp/run-calendar.c@1.9 +19 -11 + [Bug 2888] streamline calendar functions. + - update of test runner + +ChangeSet@1.3548.1.9, 2015-08-03 11:43:07+02:00, viperus@ubuntu.(none) + Makefile.am: + changed signdT -> t-ntp_signd. All tests files will from now on be named t-name.c , where name.c is the name of the tested file. + run-ntp_signdT.c~8aba306cc0dcbfc: + Delete: tests/ntpd/run-ntp_signdT.c + run-t-ntp_signd.c: + Rename: tests/ntpd/run-ntp_signd.c -> tests/ntpd/run-t-ntp_signd.c + t-ntp_signd.c: + Rename: tests/ntpd/ntp_signdT.c -> tests/ntpd/t-ntp_signd.c + + BitKeeper/deleted/3a/run-ntp_signdT.c~8aba306cc0dcbfc@1.3 +0 -0 + Delete: tests/ntpd/run-ntp_signdT.c + + tests/ntpd/Makefile.am@1.19 +17 -17 + changed signdT -> t-ntp_signd. All tests files will from now on be named t-name.c , where name.c is the name of the tested file. + + tests/ntpd/run-t-ntp_signd.c@1.4 +0 -0 + Rename: tests/ntpd/run-ntp_signd.c -> tests/ntpd/run-t-ntp_signd.c + + tests/ntpd/t-ntp_signd.c@1.4 +0 -0 + Rename: tests/ntpd/ntp_signdT.c -> tests/ntpd/t-ntp_signd.c + +ChangeSet@1.3548.1.8, 2015-08-03 08:48:00+00:00, viperus@psp-deb1.ntp.org + Makefile.am: + minor fixes, trying to link on psp-deb1 + + tests/ntpd/Makefile.am@1.18 +3 -4 + minor fixes, trying to link on psp-deb1 + +ChangeSet@1.3548.1.7, 2015-08-03 10:36:05+02:00, viperus@ubuntu.(none) + ntp_signdT.c: + added extern, hopefully, it will work + + tests/ntpd/ntp_signdT.c@1.3 +1 -1 + added extern, hopefully, it will work + +ChangeSet@1.3548.1.6, 2015-08-03 10:18:52+02:00, viperus@ubuntu.(none) + Makefile.am: + added rc_cmdlength.o + + tests/ntpd/Makefile.am@1.17 +1 -0 + added rc_cmdlength.o + +ChangeSet@1.3548.1.5, 2015-08-03 10:14:12+02:00, viperus@ubuntu.(none) + Makefile.am: + minor fix + + tests/ntpd/Makefile.am@1.16 +1 -1 + minor fix + +ChangeSet@1.3547.1.1, 2015-08-03 12:30:29+05:30, loki@dadasgift.(none) + ntp_util.c: + new file + + tests/libntp/decodenetnum.c@1.7 +7 -1 + + tests/libntp/socktoa.c@1.7 +8 -1 + + tests/ntpd/Makefile.am@1.12.1.1 +23 -0 + + tests/ntpd/ntp_util.c@1.1 +74 -0 + BitKeeper file /home/loki/ntp_gsoc/2_damir_code/ntp-stable-unity/tests/ntpd/ntp_util.c + + tests/ntpd/ntp_util.c@1.0 +0 -0 + +ChangeSet@1.3548.1.3, 2015-08-03 08:51:53+02:00, viperus@ubuntu.(none) + ntp_signd.c~736d4c4a37ef4b86: + Delete: tests/ntpd/ntp_signd.c + + BitKeeper/deleted/7f/ntp_signd.c~736d4c4a37ef4b86@1.3 +0 -0 + Delete: tests/ntpd/ntp_signd.c + +ChangeSet@1.3552, 2015-08-03 08:16:57+02:00, jnperlin@nemesis.localnet + [Bug 2889] ntp-dev-4.3.67 does not build on Windows + + ChangeLog@1.1739 +1 -0 + [Bug 2889] ntp-dev-4.3.67 does not build on Windows + + libntp/msyslog.c@1.52 +2 -2 + [Bug 2889] ntp-dev-4.3.67 does not build on Windows + - fixed a Windows-specific const clash in string processing + +ChangeSet@1.3548.1.2, 2015-08-01 22:40:51+02:00, viperus@ubuntu.(none) + ntp_signdT.c: + MUST ADD #define HAVE_NTP_NAME above the #include "ntp_NAME.c" + Makefile.am: + + + Added test ntp_singd again, renamed it to ntp_signdT (including the original ntp_signd.c doesn't work if you have 2 files with the same name). + I included the original ntp_signd.c, so static functions can be tested. + Additional .o objects had to be added for everyhting to work. + + + run-ntp_signdT.c: + autogenerated + + tests/ntpd/Makefile.am@1.14 +7 -2 + + + Added test ntp_singd again, renamed it to ntp_signdT (including the original ntp_signd.c doesn't work if you have 2 files with the same name). + I included the original ntp_signd.c, so static functions can be tested. + Additional .o objects had to be added for everyhting to work. + + + + tests/ntpd/ntp_signdT.c@1.2 +17 -2 + MUST ADD #define HAVE_NTP_NAME above the #include "ntp_NAME.c" + + tests/ntpd/run-ntp_signdT.c@1.2 +2 -2 + autogenerated + +ChangeSet@1.3548.1.1, 2015-08-01 20:49:22+02:00, viperus@ubuntu.(none) + Makefile.am: + added ntp_signdT + ntp_signdT.c, run-ntp_signdT.c: + new file + + tests/ntpd/Makefile.am@1.13 +11 -9 + added ntp_signdT + + tests/ntpd/ntp_signdT.c@1.1 +28 -0 + new file + + tests/ntpd/ntp_signdT.c@1.0 +0 -0 + + tests/ntpd/run-ntp_signdT.c@1.1 +58 -0 + new file + + tests/ntpd/run-ntp_signdT.c@1.0 +0 -0 + +ChangeSet@1.3549.1.1, 2015-07-31 07:58:11+00:00, stenn@psp-at1.ntp.org + [Bug 2890] Ignore ENOBUFS on routing netlink socket. Konstantin Khlebnikov. + + ChangeLog@1.1736.1.1 +1 -0 + [Bug 2890] Ignore ENOBUFS on routing netlink socket. Konstantin Khlebnikov. + + ntpd/ntp_io.c@1.405 +9 -4 + [Bug 2890] Ignore ENOBUFS on routing netlink socket. Konstantin Khlebnikov. + +ChangeSet@1.3550, 2015-07-29 22:50:29+02:00, jnperlin@hydra.(none) + Bug 2821: minor build issues: fixed refclock_gpsdjson.c + + ChangeLog@1.1737 +1 -0 + Bug 2821: minor build issues: fixed refclock_gpsdjson.c + + ntpd/refclock_gpsdjson.c@1.23 +9 -9 + Bug 2821: minor build issues: fixed refclock_gpsdjson.c + - 'isprint()' is called with u_char argument + - unified 'unsigned char' and 'u_char' to 'u_char' + +ChangeSet@1.3549, 2015-07-29 10:04:53+00:00, stenn@psp-at1.ntp.org + ChangeLog cleanup + + ChangeLog@1.1736 +5 -3 + ChangeLog cleanup + +ChangeSet@1.3548, 2015-07-29 12:01:10+02:00, viperus@ubuntu.(none) + ChangeLog: + updated ChangeLog + + ChangeLog@1.1735 +3 -1 + updated ChangeLog + +ChangeSet@1.3529.3.1, 2015-07-29 13:18:47+05:30, loki@dadasgift.(none) + ntp_util + + tests/ntpd/Makefile.am@1.6.2.1 +13 -10 + +ChangeSet@1.3545, 2015-07-28 09:37:25+00:00, stenn@psp-at1.ntp.org + update tests/libntp/run-socktoa.c + + tests/libntp/run-socktoa.c@1.8.1.1 +6 -6 + update tests/libntp/run-socktoa.c + +ChangeSet@1.3544, 2015-07-28 09:36:24+00:00, stenn@psp-at1.ntp.org + Typo fix for GCC warning suppression. Harlan Stenn. + + ChangeLog@1.1734 +1 -0 + Typo fix for GCC warning suppression. Harlan Stenn. + + ntpd/ntp_config.c@1.333 +5 -5 + Typo fix for GCC warning suppression. Harlan Stenn. + + ntpd/ntp_proto.c@1.364 +1 -1 + Typo fix for GCC warning suppression. Harlan Stenn. + +ChangeSet@1.3529.1.18, 2015-07-27 19:46:25+02:00, viperus@ubuntu.(none) + Many files: + update + + run-leapsec.c: + minor change + run-ntp_scanner.c, run-decodenetnum.c: + update + ntp_scanner.c: + Added more tests + lfptest.h: + minor move after merge with lokesh + Makefile.am: + Merge + + tests/libntp/lfptest.h@1.5.1.2 +0 -16 + minor move after merge with lokesh + + tests/libntp/run-decodenetnum.c@1.7 +1 -0 + update + + tests/libntp/run-lfptostr.c@1.6 +11 -11 + update + + + tests/libntp/run-netof.c@1.6 +0 -1 + update + + + tests/libntp/run-socktoa.c@1.9 +6 -6 + update + + + tests/ntpd/Makefile.am@1.6.1.4 +8 -3 + Merge + + tests/ntpd/ntp_scanner.c@1.2 +30 -2 + Added more tests + + tests/ntpd/run-leapsec.c@1.4 +9 -3 + minor change + + tests/ntpd/run-ntp_scanner.c@1.2 +7 -1 + update + + tests/ntpd/run-ntp_signd.c@1.3 +2 -2 + update + + + tests/ntpd/run-rc_cmdlength.c@1.2 +8 -3 + update + + +ChangeSet@1.3543, 2015-07-27 04:11:08+00:00, stenn@psp-at1.ntp.org + [Bug 2595] ntpdate man page quirks. Hal Murray, Harlan Stenn + + ChangeLog@1.1733 +1 -0 + [Bug 2595] ntpdate man page quirks. Hal Murray, Harlan Stenn + + ntpd/ntp.conf.def@1.19 +1 -1 + [Bug 2595] ntpdate man page quirks. Hal Murray, Harlan Stenn + + ntpd/ntpd-opts.def@1.13 +5 -1 + [Bug 2595] ntpdate man page quirks. Hal Murray, Harlan Stenn + +ChangeSet@1.3542, 2015-07-27 03:16:04+00:00, stenn@psp-at1.ntp.org + [Bug 2625] Deprecate flag1 in local refclock. Hal Murray, Harlan Stenn. + + ChangeLog@1.1732 +1 -0 + [Bug 2625] Deprecate flag1 in local refclock. Hal Murray, Harlan Stenn. + + ntpd/refclock_local.c@1.21 +2 -16 + [Bug 2625] Deprecate flag1 in local refclock. Hal Murray, Harlan Stenn. + +ChangeSet@1.3540, 2015-07-27 00:07:00+00:00, tflendrich@psp-at1.ntp.org + ChangeLog: + updated with info about progname and ntp_restrict.c + + ChangeLog@1.1730 +4 -0 + updated with info about progname and ntp_restrict.c + +ChangeSet@1.3529.2.1, 2015-07-26 22:04:07+00:00, stenn@psp-at1.ntp.org + [Bug 2817] Stop locking ntpd into memory by default under Linux. H.Stenn. + + ChangeLog@1.1725.1.8 +1 -0 + [Bug 2817] Stop locking ntpd into memory by default under Linux. H.Stenn. + + sntp/m4/ntp_rlimit.m4@1.2 +5 -1 + [Bug 2817] Stop locking ntpd into memory by default under Linux. H.Stenn. + +ChangeSet@1.3529.1.17, 2015-07-26 21:48:29+02:00, viperus@ubuntu.(none) + run-ntp_scanner.c, ntp_scanner.c: + new file + + tests/ntpd/ntp_scanner.c@1.1 +29 -0 + BitKeeper file /home/viperus/Desktop/ntp-stable-unity/tests/ntpd/ntp_scanner.c + + tests/ntpd/ntp_scanner.c@1.0 +0 -0 + + tests/ntpd/run-ntp_scanner.c@1.1 +55 -0 + BitKeeper file /home/viperus/Desktop/ntp-stable-unity/tests/ntpd/run-ntp_scanner.c + + tests/ntpd/run-ntp_scanner.c@1.0 +0 -0 + +ChangeSet@1.3529.1.16, 2015-07-26 21:34:45+02:00, viperus@ubuntu.(none) + + tests/ntpd/Makefile.am@1.6.1.3 +20 -1 + + tests/ntpd/ntp_signd.c@1.2 +3 -1 + + tests/ntpd/run-ntp_signd.c@1.2 +9 -3 + +ChangeSet@1.3529.1.14, 2015-07-26 07:23:22+00:00, stenn@psp-at1.ntp.org + update tests/sec-2853/run-sec-2853. + + tests/sec-2853/run-sec-2853.c@1.3.1.1 +4 -5 + update + +ChangeSet@1.3529.1.13, 2015-07-26 07:14:53+00:00, stenn@psp-at1.ntp.org + Add std_unity_tests to various Makefile.am files. Harlan Stenn. + + ChangeLog@1.1725.1.7 +1 -0 + Add std_unity_tests to various Makefile.am files. Harlan Stenn. + + sntp/tests/Makefile.am@1.62 +4 -0 + Add std_unity_tests to various Makefile.am files. Harlan Stenn. + + tests/libntp/Makefile.am@1.85.1.4 +4 -0 + Add std_unity_tests to various Makefile.am files. Harlan Stenn. + + tests/ntpd/Makefile.am@1.4.1.1 +4 -0 + Add std_unity_tests to various Makefile.am files. Harlan Stenn. + + tests/sandbox/Makefile.am@1.6 +4 -0 + Add std_unity_tests to various Makefile.am files. Harlan Stenn. + +ChangeSet@1.3529.1.12, 2015-07-26 06:43:54+00:00, stenn@psp-at1.ntp.org + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + NEWS@1.145 +10 -0 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + +ChangeSet@1.3529.1.11, 2015-07-26 06:37:30+00:00, stenn@psp-at1.ntp.org + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ChangeLog@1.1725.1.6 +1 -0 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + html/decode.html@1.26 +2 -2 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + html/stats.html@1.4 +24 -24 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + include/ntp_control.h@1.59 +1 -1 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + libntp/statestr.c@1.28 +1 -1 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/invoke-ntp.conf.texi@1.189 +2 -2 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp.conf.5man@1.223 +4 -4 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp.conf.5mdoc@1.223 +3 -3 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp.conf.def@1.18 +1 -1 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp.conf.html@1.178 +1522 -1191 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp.conf.man.in@1.223 +4 -4 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp.conf.mdoc.in@1.223 +3 -3 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp_loopfilter.c@1.185 +4 -4 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpd/ntp_proto.c@1.363 +1 -1 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpq/libntpq.h@1.10 +1 -1 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + + ntpq/ntpq-subs.c@1.111 +1 -1 + [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org + +ChangeSet@1.3537, 2015-07-25 18:08:16+02:00, tomek@tomek-n56vz.(none) + Changed "char * progname;" variable to be "char const * progname;", so now it is consistent + Many files: + changed a variable to be const + autogenerated + + adjtimed/adjtimed.c@1.5 +1 -1 + changed a variable to be const + + clockstuff/chutest.c@1.7 +1 -1 + changed a variable to be const + + clockstuff/propdelay.c@1.8 +1 -1 + changed a variable to be const + + libntp/msyslog.c@1.51 +3 -3 + changed a variable to be const + + libntp/ntp_lineedit.c@1.13 +1 -1 + changed a variable to be const + + ntpdate/ntpdate.c@1.94 +1 -1 + changed a variable to be const + + ntpdc/ntpdc.c@1.104 +1 -1 + changed a variable to be const + + ntpq/ntpq.c@1.160 +1 -1 + changed a variable to be const + + sntp/log.c@1.23 +1 -1 + changed a variable to be const + + sntp/log.h@1.12 +1 -1 + changed a variable to be const + + sntp/tests/run-crypto.c@1.6 +1 -1 + autogenerated + + sntp/tests/run-keyFile.c@1.9 +1 -1 + autogenerated + + sntp/tests/run-kodDatabase.c@1.7 +1 -1 + autogenerated + + sntp/tests/run-kodFile.c@1.7 +1 -1 + autogenerated + + sntp/tests/run-networking.c@1.3 +1 -1 + autogenerated + + sntp/tests/run-packetHandling.c@1.6 +1 -1 + autogenerated + + sntp/tests/run-packetProcessing.c@1.7 +1 -1 + autogenerated + + sntp/tests/run-utilities.c@1.6 +1 -1 + autogenerated + + tests/ntpd/run-ntp_restrict.c@1.4 +1 -1 + autogenerated + + tests/sandbox/run-modetoa.c@1.3 +7 -4 + autogenerated + + tests/sandbox/run-uglydate.c@1.3 +9 -4 + autogenerated + + tests/sandbox/run-ut-2803.c@1.2 +7 -4 + autogenerated + + util/ntp-keygen.c@1.106 +1 -1 + changed a variable to be const + + util/ntptime.c@1.27 +1 -1 + changed a variable to be const + +ChangeSet@1.3529.1.10, 2015-07-25 16:54:29+02:00, viperus@ubuntu.(none) + Many files: + added declarations + + lfpfunc.c: + adding declarations, reorganizing + Many files: + adding declarations + + update + + run-clocktime.c: + update + clocktime.c: + adding declarations + socktoa.c: + added declarations + + tests/libntp/clocktime.c@1.7 +1 -0 + adding declarations + + tests/libntp/lfpfunc.c@1.13 +28 -7 + adding declarations, reorganizing + + tests/libntp/netof.c@1.3.1.1 +8 -0 + adding declarations + + + tests/libntp/numtoa.c@1.6 +2 -0 + adding declarations + + + tests/libntp/numtohost.c@1.5 +2 -0 + adding declarations + + + tests/libntp/octtoint.c@1.3.1.1 +10 -0 + adding declarations + + + tests/libntp/prettydate.c@1.3 +3 -0 + adding declarations + + + tests/libntp/recvbuff.c@1.5 +4 -0 + adding declarations + + + tests/libntp/refidsmear.c@1.5 +6 -3 + adding declarations + + + tests/libntp/refnumtoa.c@1.5 +4 -0 + adding declarations + + + tests/libntp/run-clocktime.c@1.9 +1 -1 + update + + tests/libntp/run-lfpfunc.c@1.16 +9 -9 + update + + + tests/libntp/run-netof.c@1.5 +4 -4 + update + + + tests/libntp/run-numtoa.c@1.9 +2 -2 + update + + + tests/libntp/run-numtohost.c@1.9 +1 -1 + update + + + tests/libntp/run-octtoint.c@1.6 +7 -7 + update + + + tests/libntp/run-prettydate.c@1.4 +1 -1 + update + + + tests/libntp/run-recvbuff.c@1.4 +3 -3 + update + + + tests/libntp/run-refidsmear.c@1.5 +1 -1 + update + + + tests/libntp/run-refnumtoa.c@1.7 +2 -2 + update + + + tests/libntp/run-sfptostr.c@1.4 +7 -7 + update + + + tests/libntp/run-socktoa.c@1.8 +6 -6 + update + + + tests/libntp/run-ssl_init.c@1.8 +5 -5 + update + + + tests/libntp/run-statestr.c@1.9 +4 -4 + update + + + tests/libntp/run-strtolfp.c@1.4 +6 -6 + update + + + tests/libntp/run-timespecops.c@1.9 +28 -28 + update + + + tests/libntp/run-timevalops.c@1.11 +28 -28 + update + + + tests/libntp/run-tstotv.c@1.4 +3 -3 + update + + + tests/libntp/run-tvtots.c@1.5 +3 -3 + update + + + tests/libntp/run-vi64ops.c@1.7 +3 -3 + update + + + tests/libntp/run-ymd2yd.c@1.10 +4 -4 + update + + + tests/libntp/sfptostr.c@1.3 +10 -0 + update + + + tests/libntp/sockaddrtest.c@1.2 +1 -0 + update + + + tests/libntp/socktoa.c@1.3.1.1 +6 -0 + added declarations + + tests/libntp/ssl_init.c@1.8 +6 -0 + added declarations + + + tests/libntp/statestr.c@1.5 +4 -0 + added declarations + + + tests/libntp/strtolfp.c@1.2.1.1 +9 -0 + added declarations + + + tests/libntp/timespecops.c@1.8 +40 -1 + added declarations + + + tests/libntp/timevalops.c@1.11 +37 -1 + added declarations + + + tests/libntp/tstotv.c@1.3 +5 -0 + added declarations + + + tests/libntp/tvtots.c@1.5 +3 -0 + added declarations + + + tests/libntp/vi64ops.c@1.6 +6 -0 + added declarations + + + tests/libntp/ymd2yd.c@1.6 +5 -0 + added declarations + + +ChangeSet@1.3536, 2015-07-25 02:08:32+02:00, tomek@tomek-n56vz.(none) + run-ntp_restrict.c: + autogenerated, but modified manually... + Makefile.am: + removed something not longer in use + ntp_restrict.c: + added another test + run-ntp_restrict.c, run-ntp_prio_q.c, run-sec-2853.c, run-bug-2803.c: + autogenerated + + tests/bug-2803/run-bug-2803.c@1.8 +8 -4 + autogenerated + + tests/ntpd/Makefile.am@1.9 +0 -3 + removed something not longer in use + + tests/ntpd/ntp_restrict.c@1.2 +17 -4 + added another test + + tests/ntpd/run-ntp_prio_q.c@1.2 +9 -4 + autogenerated + + tests/ntpd/run-ntp_restrict.c@1.3 +1 -1 + autogenerated, but modified manually... + + tests/ntpd/run-ntp_restrict.c@1.2 +8 -4 + autogenerated + + tests/sec-2853/run-sec-2853.c@1.4 +5 -6 + autogenerated + +ChangeSet@1.3529.1.9, 2015-07-24 18:38:05+02:00, viperus@ubuntu.(none) + calendar.c: + added function declarations + minor comment fixes + + Many files: + added declarations + + updated + + run-buftvtots.c, run-calendar.c: + update + lfptest.c: + added #include + buftvtots.c: + added function declarations + caljulian.c: + added declarations + run-caljulian.c: + updated + + tests/libntp/buftvtots.c@1.4 +4 -0 + added function declarations + + tests/libntp/calendar.c@1.6 +42 -18 + added function declarations + minor comment fixes + + + tests/libntp/caljulian.c@1.9 +10 -0 + added declarations + + tests/libntp/caltontp.c@1.3 +5 -0 + added declarations + + + tests/libntp/calyearstart.c@1.4 +5 -0 + added declarations + + + tests/libntp/clocktime.c@1.6 +11 -0 + added declarations + + + tests/libntp/decodenetnum.c@1.3.1.1 +7 -0 + added declarations + + + tests/libntp/hextoint.c@1.4 +6 -0 + added declarations + + + tests/libntp/hextolfp.c@1.5.1.1 +7 -0 + added declarations + + + tests/libntp/humandate.c@1.5 +4 -0 + added declarations + + + tests/libntp/lfpfunc.c@1.12 +13 -0 + added declarations + + + tests/libntp/lfptest.c@1.2 +1 -0 + added #include + + tests/libntp/lfptostr.c@1.3.1.1 +15 -0 + added declarations + + + tests/libntp/modetoa.c@1.7 +3 -0 + added declarations + + + tests/libntp/msyslog.c@1.6 +10 -0 + added declarations + + + tests/libntp/run-buftvtots.c@1.5 +10 -10 + update + + tests/libntp/run-calendar.c@1.8 +11 -11 + update + + tests/libntp/run-caljulian.c@1.12 +4 -4 + updated + + tests/libntp/run-caltontp.c@1.4 +4 -4 + updated + + + tests/libntp/run-calyearstart.c@1.6 +3 -3 + updated + + + tests/libntp/run-clocktime.c@1.8 +8 -8 + updated + + + tests/libntp/run-decodenetnum.c@1.6 +6 -6 + updated + + + tests/libntp/run-hextoint.c@1.8 +5 -5 + updated + + + tests/libntp/run-hextolfp.c@1.7 +6 -6 + updated + + + tests/libntp/run-humandate.c@1.5 +2 -2 + updated + + + tests/libntp/run-lfpfunc.c@1.15 +9 -9 + updated + + + tests/libntp/run-lfptostr.c@1.5 +10 -10 + updated + + + tests/libntp/run-modetoa.c@1.10 +2 -2 + updated + + + tests/libntp/run-msyslog.c@1.7 +8 -8 + updated + + +ChangeSet@1.3523.2.7, 2015-07-24 12:01:24+05:30, loki@dadasgift.(none) + ntp signd testing + + tests/ntpd/ntp_signd.c@1.1 +24 -0 + BitKeeper file /home/loki/ntp_gsoc/2_damir_code/ntp-stable-unity/tests/ntpd/ntp_signd.c + + tests/ntpd/ntp_signd.c@1.0 +0 -0 + +ChangeSet@1.3523.2.6, 2015-07-24 11:55:00+05:30, loki@dadasgift.(none) + ntp_signd test changes + + tests/ntpd/Makefile.am@1.6.1.1 +21 -0 + + tests/ntpd/run-ntp_signd.c@1.1 +52 -0 + BitKeeper file /home/loki/ntp_gsoc/2_damir_code/ntp-stable-unity/tests/ntpd/run-ntp_signd.c + + tests/ntpd/run-ntp_signd.c@1.0 +0 -0 + +ChangeSet@1.3535, 2015-07-23 19:19:08+02:00, tomek@tomek-n56vz.(none) + Wrote tests for ntpd/ntp_restrict.c + ntp_restrict.c, run-ntp_restrict.c: + new file + Makefile.am: + added ntp_restrict.c test + ntp_restrict.c: + added assertions (I prefer them to a segfault) + + ntpd/ntp_restrict.c@1.39 +6 -0 + added assertions (I prefer them to a segfault) + + tests/ntpd/Makefile.am@1.8 +25 -0 + added ntp_restrict.c test + + tests/ntpd/ntp_restrict.c@1.1 +185 -0 + BitKeeper file /home/tomek/ntp/ntpd_tests/ntp-stable-unity/tests/ntpd/ntp_restrict.c + + tests/ntpd/ntp_restrict.c@1.0 +0 -0 + + tests/ntpd/run-ntp_restrict.c@1.1 +64 -0 + BitKeeper file /home/tomek/ntp/ntpd_tests/ntp-stable-unity/tests/ntpd/run-ntp_restrict.c + + tests/ntpd/run-ntp_restrict.c@1.0 +0 -0 + +ChangeSet@1.3529.1.8, 2015-07-23 18:37:16+02:00, viperus@ubuntu.(none) + reduced number of warnings in sntp/tests/ + + sntp/tests/crypto.c@1.9 +6 -0 + added declarations for tests + + sntp/tests/fileHandlingTest.c@1.2 +1 -1 + commented out unnecessary array + + sntp/tests/keyFile.c@1.7 +4 -0 + added declarations for tests + + + sntp/tests/kodDatabase.c@1.7 +6 -0 + added declarations for tests + + + sntp/tests/kodFile.c@1.8 +8 -0 + added declarations for tests + + + sntp/tests/nameresolution.c@1.2 +3 -0 + added declarations for tests + + + sntp/tests/packetHandling.c@1.5 +13 -0 + added declarations for tests + + + sntp/tests/packetProcessing.c@1.7 +24 -0 + added declarations for tests + + + sntp/tests/run-crypto.c@1.5 +5 -5 + added declarations for tests + + + sntp/tests/run-keyFile.c@1.8 +4 -4 + updated + + sntp/tests/run-kodDatabase.c@1.6 +5 -5 + updated + + sntp/tests/run-kodFile.c@1.6 +6 -6 + updated + + sntp/tests/run-packetHandling.c@1.5 +10 -10 + updated + + sntp/tests/run-packetProcessing.c@1.6 +18 -18 + updated + + sntp/tests/run-utilities.c@1.5 +7 -7 + updated + + sntp/tests/utilities.c@1.4 +12 -0 + added declarations for tests + + +ChangeSet@1.3529.1.7, 2015-07-22 20:09:39+02:00, viperus@ubuntu.(none) + Updated unity ruby testRunner generator with mark's latest fixes. Modified tests/libntp/Makefile.am and sntp/tests/Makefile.am accordingly. Also, split some .h files into .h and .c because they contained declarations and definitions which caused error in the newly generated test runners. Started fixing some warnings. We can add both declarations and defitions in a single test.c file without any issues now. Autogenerated tests will be run in order of the declarations in the test file. + + sntp/tests/Makefile.am@1.61 +4 -0 + New ruby generator script required some changes. Removed some definitions form header files and created their own .c files. + + sntp/tests/crypto.c@1.8 +2 -0 + started adding declarations at the top of the file + + sntp/tests/fileHandlingTest.c@1.1 +74 -0 + new file. Contains definitions from fileHandlingTest.h.in + + sntp/tests/fileHandlingTest.c@1.0 +0 -0 + + sntp/tests/fileHandlingTest.h.in@1.14 +7 -46 + changes stuff a bit, to work with the updated ruby generator + + sntp/tests/keyFile.c@1.6 +4 -0 + added declarations to avoid warnings + + sntp/tests/run-crypto.c@1.4 +12 -9 + updated autogenerated code + + sntp/tests/run-keyFile.c@1.7 +12 -8 + updated autogenerated code + + + sntp/tests/run-kodDatabase.c@1.5 +9 -3 + updated autogenerated code + + + sntp/tests/run-kodFile.c@1.5 +7 -3 + updated autogenerated code + + + sntp/tests/run-networking.c@1.2 +5 -2 + updated autogenerated code + + + sntp/tests/run-packetHandling.c@1.4 +11 -3 + updated autogenerated code + + + sntp/tests/run-packetProcessing.c@1.5 +6 -3 + updated autogenerated code + + + sntp/tests/run-utilities.c@1.4 +8 -3 + updated autogenerated code + + + sntp/tests/sntptest.c@1.1 +33 -0 + definitions placed from .h to .c + + sntp/tests/sntptest.c@1.0 +0 -0 + + sntp/tests/sntptest.h@1.6 +0 -29 + added sntptest.c and put definitions in it. + + sntp/unity/auto/generate_test_runner.rb@1.9 +3 -3 + some changes were needed after mark's update to work better with NTP + + sntp/unity/auto/generate_test_runner.rb@1.8 +209 -110 + updated the ruby script with new stuff from Mark + + sntp/unity/auto/parseOutput.rb@1.1 +191 -0 + mark's new file from the update + + sntp/unity/auto/parseOutput.rb@1.0 +0 -0 + + sntp/unity/auto/type_sanitizer.rb@1.1 +8 -0 + mark's new file from the update + + + sntp/unity/auto/type_sanitizer.rb@1.0 +0 -0 + + sntp/unity/auto/unity_test_summary.py@1.1 +135 -0 + mark's new file from the update + + + sntp/unity/auto/unity_test_summary.py@1.0 +0 -0 + + sntp/unity/auto/unity_test_summary.rb@1.3 +48 -25 + added Marks new changes + + tests/libntp/Makefile.am@1.85.1.3 +7 -0 + New ruby generator script required some changes. Removed some definitions form header files and created their own .c files. + + + tests/libntp/a_md5encrypt.c@1.11 +8 -0 + added declarations + + tests/libntp/atoint.c@1.4 +9 -0 + added declarations + + + tests/libntp/atouint.c@1.5 +8 -0 + added declarations + + + tests/libntp/authkeys.c@1.10 +17 -6 + added declarations + + + tests/libntp/lfptest.c@1.1 +10 -0 + new file, contains definitions from lfptest.h + + tests/libntp/lfptest.c@1.0 +0 -0 + + tests/libntp/lfptest.h@1.4.1.3 +2 -8 + split to .h and .c which now contains definitions + + tests/libntp/run-a_md5encrypt.c@1.13 +9 -7 + autogenerated file update + + tests/libntp/run-atoint.c@1.7 +10 -7 + autogenerated file update + + + tests/libntp/run-atouint.c@1.8 +10 -7 + autogenerated file update + + + tests/libntp/run-authkeys.c@1.10 +12 -9 + autogenerated file update + + + tests/libntp/run-buftvtots.c@1.4 +8 -3 + autogenerated file update + + + tests/libntp/run-calendar.c@1.7 +6 -3 + autogenerated file update + + + tests/libntp/run-caljulian.c@1.11 +7 -3 + autogenerated file update + + + tests/libntp/run-caltontp.c@1.3 +4 -3 + autogenerated file update + + + tests/libntp/run-calyearstart.c@1.5 +6 -3 + autogenerated file update + + + tests/libntp/run-clocktime.c@1.7 +6 -3 + autogenerated file update + + + tests/libntp/run-decodenetnum.c@1.5 +5 -3 + autogenerated file update + + + tests/libntp/run-hextoint.c@1.7 +6 -2 + autogenerated file update + + + tests/libntp/run-hextolfp.c@1.6 +6 -3 + autogenerated file update + + + tests/libntp/run-humandate.c@1.4 +5 -3 + autogenerated file update + + + tests/libntp/run-lfpfunc.c@1.14 +7 -3 + autogenerated file update + + + tests/libntp/run-lfptostr.c@1.4 +5 -3 + autogenerated file update + + + tests/libntp/run-modetoa.c@1.9 +4 -3 + autogenerated file update + + + tests/libntp/run-msyslog.c@1.6 +4 -3 + autogenerated file update + + + tests/libntp/run-netof.c@1.4 +6 -3 + autogenerated file update + + + tests/libntp/run-numtoa.c@1.8 +5 -3 + autogenerated file update + + + tests/libntp/run-numtohost.c@1.8 +5 -3 + autogenerated file update + + + tests/libntp/run-octtoint.c@1.5 +4 -2 + autogenerated file update + + + tests/libntp/run-prettydate.c@1.3 +6 -2 + autogenerated file update + + + tests/libntp/run-recvbuff.c@1.3 +4 -2 + autogenerated file update + + + tests/libntp/run-refidsmear.c@1.4 +7 -3 + autogenerated file update + + + tests/libntp/run-refnumtoa.c@1.6 +5 -3 + autogenerated file update + + + tests/libntp/run-sfptostr.c@1.3 +4 -3 + autogenerated file update + + + tests/libntp/run-socktoa.c@1.7 +6 -2 + autogenerated file update + + + tests/libntp/run-ssl_init.c@1.7 +4 -3 + autogenerated file update + + + tests/libntp/run-statestr.c@1.8 +6 -3 + autogenerated file update + + + tests/libntp/run-strtolfp.c@1.3 +6 -2 + autogenerated file update + + + tests/libntp/run-timespecops.c@1.8 +8 -3 + autogenerated file update + + + tests/libntp/run-timevalops.c@1.10 +7 -3 + autogenerated file update + + + tests/libntp/run-tstotv.c@1.3 +5 -2 + autogenerated file update + + + tests/libntp/run-tvtots.c@1.4 +6 -3 + autogenerated file update + + + tests/libntp/run-uglydate.c@1.9 +6 -4 + autogenerated file update + + + tests/libntp/run-vi64ops.c@1.6 +5 -3 + autogenerated file update + + + tests/libntp/run-ymd2yd.c@1.9 +4 -3 + autogenerated file update + + + tests/libntp/sockaddrtest.c@1.1 +50 -0 + New file created by splitting sockaddrtest.h. + + tests/libntp/sockaddrtest.c@1.0 +0 -0 + + tests/libntp/sockaddrtest.h@1.6 +4 -45 + removed definitions and placed them in sockaddrtest.c + + tests/libntp/uglydate.c@1.7 +1 -0 + added some declarations to test the new generator. Unfinished + +ChangeSet@1.3523.3.18, 2015-07-21 06:47:23+00:00, stenn@psp-deb1.ntp.org + [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. + + ChangeLog@1.1708.1.19 +1 -0 + [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. + + ntpd/ntp_parser.c@1.98 +1141 -1381 + [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. + + ntpd/ntp_parser.h@1.63 +216 -230 + [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. + + ntpd/ntp_parser.y@1.88 +1 -1 + [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. + +ChangeSet@1.3523.3.17, 2015-07-20 07:32:09+00:00, stenn@psp-at1.ntp.org + ntpd/ntp_peer.c:newpeer(): added a DEBUG_REQUIRE(srcadr). Harlan Stenn. + + ChangeLog@1.1708.1.18 +1 -0 + ntpd/ntp_peer.c:newpeer(): added a DEBUG_REQUIRE(srcadr). Harlan Stenn. + + ntpd/ntp_peer.c@1.158 +2 -0 + ntpd/ntp_peer.c:newpeer(): added a DEBUG_REQUIRE(srcadr). Harlan Stenn. + +ChangeSet@1.3523.3.16, 2015-07-20 07:20:04+00:00, stenn@psp-at1.ntp.org + [Bug 2849] Systems with more than one default route may never synchronize. Brian Utterback. + + ChangeLog@1.1708.1.17 +3 -0 + [Bug 2849] Systems with more than one default route may never synchronize. Brian Utterback. + + ntpd/ntp_peer.c@1.157 +7 -3 + [Bug 2849] Systems with more than one default route may never synchronize. Brian Utterback. + +ChangeSet@1.3523.3.15, 2015-07-20 06:38:37+00:00, stenn@psp-at1.ntp.org + util/ntptime.c: initialization nit. Harlan Stenn. + + ChangeLog@1.1708.1.16 +1 -0 + util/ntptime.c: initialization nit. Harlan Stenn. + + util/ntptime.c@1.26 +1 -1 + util/ntptime.c: initialization nit. Harlan Stenn. + +ChangeSet@1.3523.3.14, 2015-07-19 21:49:06-04:00, stenn@deacon.udel.edu + Typo + + ChangeLog@1.1708.1.15 +1 -1 + Typo + +ChangeSet@1.3523.3.13, 2015-07-19 21:46:59-04:00, stenn@deacon.udel.edu + libntp/icom.c: Typos fix. Harlan Stenn. + + ChangeLog@1.1708.1.14 +1 -0 + libntp/icom.c: Typos fix. Harlan Stenn. + + libntp/icom.c@1.20 +1 -1 + libntp/icom.c: Typos fix. Harlan Stenn. + +ChangeSet@1.3523.3.12, 2015-07-19 05:37:40+00:00, stenn@psp-at1.ntp.org + Code cleanup. Harlan Stenn. + + ChangeLog@1.1708.1.13 +1 -0 + Code cleanup. Harlan Stenn. + + include/Makefile.am@1.52 +1 -0 + Code cleanup. Harlan Stenn. + + include/rc_cmdlength.h@1.1 +2 -0 + BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable/include/rc_cmdlength.h + + include/rc_cmdlength.h@1.0 +0 -0 + + libntp/audio.c@1.36 +8 -5 + Code cleanup. Harlan Stenn. + + libntp/icom.c@1.19 +23 -7 + Code cleanup. Harlan Stenn. + + libntp/ntp_worker.c@1.5 +1 -1 + Code cleanup. Harlan Stenn. + + ntpd/ntp_config.c@1.332 +10 -0 + Code cleanup. Harlan Stenn. + + ntpd/ntp_control.c@1.203 +1 -2 + Code cleanup. Harlan Stenn. + + ntpd/ntp_crypto.c@1.181 +1 -1 + Code cleanup. Harlan Stenn. + + ntpd/ntp_monitor.c@1.44 +4 -0 + Code cleanup. Harlan Stenn. + + ntpd/ntp_peer.c@1.156 +1 -0 + Code cleanup. Harlan Stenn. + + ntpd/ntp_proto.c@1.362 +3 -1 + Code cleanup. Harlan Stenn. + + ntpd/ntp_restrict.c@1.38 +4 -0 + Code cleanup. Harlan Stenn. + + ntpd/rc_cmdlength.c@1.2 +1 -0 + Code cleanup. Harlan Stenn. + + ntpd/refclock_arc.c@1.33 +1 -1 + Code cleanup. Harlan Stenn. + + ntpd/refclock_chu.c@1.57 +1 -1 + Code cleanup. Harlan Stenn. + + ntpd/refclock_nmea.c@1.78 +4 -3 + Code cleanup. Harlan Stenn. + + ntpd/refclock_parse.c@1.81 +3 -0 + Code cleanup. Harlan Stenn. + + ntpd/refclock_wwv.c@1.80 +4 -2 + Code cleanup. Harlan Stenn. + + ntpq/ntpq.c@1.159 +0 -1 + Code cleanup. Harlan Stenn. + + sntp/networking.c@1.66 +1 -1 + Code cleanup. Harlan Stenn. + + tests/sec-2853/run-sec-2853.c@1.3 +2 -2 + Code cleanup. Harlan Stenn. + + tests/sec-2853/sec-2853.c@1.5 +2 -2 + Code cleanup. Harlan Stenn. + + util/ntp-keygen.c@1.105 +2 -2 + Code cleanup. Harlan Stenn. + +ChangeSet@1.3523.3.11, 2015-07-16 07:37:32+00:00, stenn@psp-at1.ntp.org + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ChangeLog@1.1708.1.12 +1 -0 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + include/ntp_assert.h@1.9 +0 -4 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + include/ntp_lists.h@1.15 +3 -3 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/atolfp.c@1.6 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/caljulian.c@1.16 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/caltontp.c@1.7 +8 -8 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/decodenetnum.c@1.17 +3 -3 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/msyslog.c@1.50 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/ntp_intres.c@1.99 +12 -12 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/ntp_rfc2553.c@1.48 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/prettydate.c@1.20 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/recvbuff.c@1.40 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/socket.c@1.10 +2 -2 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + libntp/socktohost.c@1.15 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_config.c@1.331 +7 -8 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_control.c@1.202 +18 -18 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_crypto.c@1.180 +14 -14 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_io.c@1.404 +15 -15 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_monitor.c@1.43 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_peer.c@1.155 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_refclock.c@1.120 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpd/ntp_restrict.c@1.37 +9 -9 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpdc/ntpdc.c@1.103 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ntpq/ntpq-subs.c@1.110 +7 -7 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ports/winnt/libntp/termios.c@1.31 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ports/winnt/ntpd/nt_clockstuff.c@1.66 +1 -1 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + + ports/winnt/ntpd/ntp_iocompletionport.c@1.71 +7 -8 + Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. + +ChangeSet@1.3523.3.10, 2015-07-13 04:28:29+00:00, stenn@psp-at1.ntp.org + [Bug 2823] ntpsweep with recursive peers option doesn't work. H.Stenn. + + ChangeLog@1.1708.1.11 +1 -0 + [Bug 2823] ntpsweep with recursive peers option doesn't work. H.Stenn. + + scripts/ntpsweep/ntpsweep.in@1.9 +2 -1 + [Bug 2823] ntpsweep with recursive peers option doesn't work. H.Stenn. + +ChangeSet@1.3523.3.9, 2015-07-13 04:18:36+00:00, stenn@psp-at1.ntp.org + scripts/lib/NTP/Util.pm: stratum output is version-dependent. Harlan Stenn. + + ChangeLog@1.1708.1.10 +1 -0 + scripts/lib/NTP/Util.pm: stratum output is version-dependent. Harlan Stenn. + + scripts/lib/NTP/Util.pm@1.5 +8 -1 + scripts/lib/NTP/Util.pm: stratum output is version-dependent. Harlan Stenn. + +ChangeSet@1.3531, 2015-07-13 04:21:50+02:00, tomek@tomek-n56vz.(none) + wrote tests for ntpd/ntp_prio_q.c + + Makefile.am: + added ntp_prio_q.c + ntp_prio_q.c, run-ntp_prio_q.c: + new file + ChangeLog: + added info about the test of ntpd/ntp_prio_q.c + + ChangeLog@1.1726 +1 -0 + added info about the test of ntpd/ntp_prio_q.c + + tests/ntpd/Makefile.am@1.7 +28 -0 + added ntp_prio_q.c + + tests/ntpd/ntp_prio_q.c@1.1 +261 -0 + BitKeeper file /home/tomek/ntp/ntpd_tests/ntp-stable-unity/tests/ntpd/ntp_prio_q.c + + tests/ntpd/ntp_prio_q.c@1.0 +0 -0 + + tests/ntpd/run-ntp_prio_q.c@1.1 +64 -0 + BitKeeper file /home/tomek/ntp/ntpd_tests/ntp-stable-unity/tests/ntpd/run-ntp_prio_q.c + + tests/ntpd/run-ntp_prio_q.c@1.0 +0 -0 + +ChangeSet@1.3523.2.5, 2015-07-12 22:59:46+05:30, loki@dadasgift.(none) + rc_cmdlength test + + tests/ntpd/rc_cmdlength.c@1.2 +20 -4 + + tests/ntpd/run-rc_cmdlength.c@1.1 +52 -0 + BitKeeper file /home/loki/ntp_gsoc/2_damir_code/ntp-stable-unity/tests/ntpd/run-rc_cmdlength.c + + tests/ntpd/run-rc_cmdlength.c@1.0 +0 -0 + +ChangeSet@1.3523.3.8, 2015-07-11 19:20:33-04:00, stenn@deacon.udel.edu + br-flock: --enable-local-libevent. Harlan Stenn. + + ChangeLog@1.1708.1.9 +1 -0 + br-flock: --enable-local-libevent. Harlan Stenn. + + br-flock@1.17 +1 -1 + br-flock: --enable-local-libevent. Harlan Stenn. + +ChangeSet@1.3523.3.7, 2015-07-11 18:46:20-04:00, stenn@deacon.udel.edu + [Bug 2875] libevent is improperly bundled in the tarball + + Makefile.am@1.133 +1 -1 + [Bug 2875] libevent is improperly bundled in the tarball + +ChangeSet@1.3523.4.1, 2015-07-11 20:28:26+00:00, stenn@psp-at1.ntp.org + [Bug 2875] sntp/Makefile.am: Get rid of DIST_SUBDIRS. libevent must be configured for the distribution targets. Harlan Stenn. + + ChangeLog@1.1708.2.1 +2 -0 + [Bug 2875] sntp/Makefile.am: Get rid of DIST_SUBDIRS. libevent must be configured for the distribution targets. Harlan Stenn. + + sntp/Makefile.am@1.86 +13 -24 + [Bug 2875] sntp/Makefile.am: Get rid of DIST_SUBDIRS. libevent must be configured for the distribution targets. Harlan Stenn. + +ChangeSet@1.3523.2.4, 2015-07-11 00:19:36+05:30, loki@dadasgift.(none) + rc_cmdlength testing + + tests/ntpd/Makefile.am@1.6 +20 -0 + + tests/ntpd/rc_cmdlength.c@1.1 +22 -0 + BitKeeper file /home/loki/ntp_gsoc/2_damir_code/ntp-stable-unity/tests/ntpd/rc_cmdlength.c + + tests/ntpd/rc_cmdlength.c@1.0 +0 -0 + +ChangeSet@1.3523.3.5, 2015-07-09 09:03:46+00:00, stenn@psp-at1.ntp.org + tests/libntp/test_caltontp needs -lpthread. Harlan Stenn. + + ChangeLog@1.1708.1.7 +1 -0 + tests/libntp/test_caltontp needs -lpthread. Harlan Stenn. + + tests/libntp/Makefile.am@1.85.1.2 +5 -0 + tests/libntp/test_caltontp needs -lpthread. Harlan Stenn. + +ChangeSet@1.3523.3.4, 2015-07-09 03:42:45-04:00, stenn@deacon.udel.edu + Don't build sntp/libevent/sample/. Harlan Stenn. + + ChangeLog@1.1708.1.6 +1 -0 + Don't build sntp/libevent/sample/. Harlan Stenn. + + sntp/libevent/Makefile.am@1.14 +1 -1 + Don't build sntp/libevent/sample/. Harlan Stenn. + +ChangeSet@1.3523.3.3, 2015-07-09 06:06:50+00:00, stenn@psp-at1.ntp.org + Phase 1 deprecation of google test in tests/libntp/. Harlan Stenn. + + ChangeLog@1.1708.1.5 +1 -0 + Phase 1 deprecation of google test in tests/libntp/. Harlan Stenn. + + tests/libntp/Makefile.am@1.85.1.1 +113 -408 + Phase 1 deprecation of google test in tests/libntp/. Harlan Stenn. + +ChangeSet@1.3527, 2015-07-09 04:25:01+02:00, tomek@tomek-n56vz.(none) + lfptest.h: + now it uses NTP's conventions + ChangeLog: + add info about lfptest.h + test-libntp.c: + fixed formatting + sockaddrtest.h: + formatting fix + kodDatabase.c: + formatting, adding const, adding a missing library + ChangeLog: + added info about timespecops.c + kodFile.c: + formatting, changes to usage of unity macros to get better print messages, cleanup + crypto.c, lfptest.h: + cleanup + ChangeLog: + add info about test-libntp.c + timespecops.c: + further formatting changes + ChangeLog: + added info about timevalops.c + fileHandlingTest.h.in: + fixed buffer overflow problem and fixed one function that previously did nothing + timevalops.c: + fixed the order of includes, deleted unnecessary + packetProcessing.c: + formatting, sprintf->snprintf + packetHandling.c: + formatting, using better unity functions, using proper unity functions, deleting unused variable + keyFile.c: + formatting, using proper unity's macros + ChangeLog: + fileHandlingTest.h info + updating with info about sockaddrtest.h + timespecops.c: + forgot to delete one comment + ChangeLog: + added info about my code review changes in sntp/tests/ + kodDatabase.c: + missed something in formatting + sntptest.h: + formatting + Many files: + autogenerated + kodDatabase.c: + added a header. now it's windows compliant too! + fileHandlingTest.h.in: + formatting, deleted unnecessary prints + timespecops.c: + fixed formatting, fixed the order of includes, + removed unnecessary comments, cleanup + utilities.c: + the order of includes, formatting, removing unnecessary comments, using proper unity assertions + + ChangeLog@1.1723 +2 -1 + fileHandlingTest.h info + + ChangeLog@1.1722 +17 -0 + added info about my code review changes in sntp/tests/ + + ChangeLog@1.1721 +1 -0 + add info about test-libntp.c + + ChangeLog@1.1720 +2 -0 + updating with info about sockaddrtest.h + + ChangeLog@1.1719 +1 -0 + add info about lfptest.h + + ChangeLog@1.1718 +2 -0 + added info about timevalops.c + + ChangeLog@1.1717 +3 -1 + added info about timespecops.c + + sntp/tests/crypto.c@1.7 +14 -8 + cleanup + + sntp/tests/fileHandlingTest.h.in@1.13 +6 -6 + fixed buffer overflow problem and fixed one function that previously did nothing + + sntp/tests/fileHandlingTest.h.in@1.12 +13 -39 + formatting, deleted unnecessary prints + + sntp/tests/keyFile.c@1.5 +33 -24 + formatting, using proper unity's macros + + sntp/tests/kodDatabase.c@1.6 +1 -1 + added a header. now it's windows compliant too! + + sntp/tests/kodDatabase.c@1.5 +1 -2 + missed something in formatting + + sntp/tests/kodDatabase.c@1.4 +39 -31 + formatting, adding const, adding a missing library + + sntp/tests/kodFile.c@1.7 +34 -32 + formatting, changes to usage of unity macros to get better print messages, cleanup + + sntp/tests/packetHandling.c@1.4 +46 -31 + formatting, using better unity functions, using proper unity functions, deleting unused variable + + sntp/tests/packetProcessing.c@1.6 +67 -25 + formatting, sprintf->snprintf + + sntp/tests/run-crypto.c@1.3 +6 -6 + autogenerated + + sntp/tests/run-keyFile.c@1.6 +5 -5 + autogenerated + + sntp/tests/run-kodDatabase.c@1.4 +5 -5 + autogenerated + + sntp/tests/run-kodDatabase.c@1.3 +4 -4 + autogenerated + + sntp/tests/run-kodFile.c@1.4 +5 -5 + autogenerated + + sntp/tests/run-packetHandling.c@1.3 +10 -10 + autogenerated + + sntp/tests/run-packetProcessing.c@1.4 +18 -18 + autogenerated + + sntp/tests/run-utilities.c@1.3 +7 -7 + autogenerated + + sntp/tests/sntptest.h@1.5 +9 -3 + formatting + + sntp/tests/utilities.c@1.3 +38 -20 + the order of includes, formatting, removing unnecessary comments, using proper unity assertions + + tests/libntp/lfptest.h@1.4.1.2 +2 -3 + now it uses NTP's conventions + + tests/libntp/lfptest.h@1.4.1.1 +7 -16 + cleanup + + tests/libntp/run-timespecops.c@1.5.1.3 +28 -28 + autogenerated + + tests/libntp/run-timespecops.c@1.5.1.2 +28 -28 + autogenerated + + tests/libntp/run-timespecops.c@1.5.1.1 +28 -28 + autogenerated + + tests/libntp/run-timevalops.c@1.7.1.1 +28 -28 + autogenerated + + tests/libntp/sockaddrtest.h@1.5 +6 -5 + formatting fix + + tests/libntp/test-libntp.c@1.10 +6 -11 + fixed formatting + + tests/libntp/timespecops.c@1.5.1.3 +7 -6 + further formatting changes + + tests/libntp/timespecops.c@1.5.1.2 +0 -1 + forgot to delete one comment + + tests/libntp/timespecops.c@1.5.1.1 +129 -85 + fixed formatting, fixed the order of includes, + removed unnecessary comments, cleanup + + tests/libntp/timevalops.c@1.8.1.1 +137 -87 + fixed the order of includes, deleted unnecessary + +ChangeSet@1.3523.3.2, 2015-07-07 01:27:49+00:00, stenn@psp-at1.ntp.org + sntp/unity/unity.c: Clean up a printf(). Harlan Stenn + + ChangeLog@1.1708.1.4 +1 -0 + sntp/unity/unity.c: Clean up a printf(). Harlan Stenn + + sntp/unity/unity.c@1.3 +1 -3 + sntp/unity/unity.c: Clean up a printf(). Harlan Stenn + +ChangeSet@1.3523.3.1, 2015-07-07 01:21:36+00:00, stenn@psp-at1.ntp.org + [Bug 2873] libevent should not include .deps/ in the tarball. H.Stenn + + ChangeLog@1.1708.1.3 +1 -0 + [Bug 2873] libevent should not include .deps/ in the tarball. H.Stenn + + sntp/Makefile.am@1.85 +1 -1 + [Bug 2873] libevent should not include .deps/ in the tarball. H.Stenn + +ChangeSet@1.3523.2.2, 2015-07-06 20:30:39+05:30, loki@dadasgift.(none) + code review changes + + tests/libntp/lfptest.h@1.5 +7 -6 + + tests/libntp/strtolfp.c@1.3 +20 -19 + +ChangeSet@1.3514.1.2, 2015-07-06 19:55:50+05:30, loki@dadasgift.(none) + Code review changes + + tests/libntp/decodenetnum.c@1.2.1.1 +13 -9 + + tests/libntp/hextolfp.c@1.4.1.1 +0 -1 + + tests/libntp/lfptostr.c@1.2.1.1 +23 -12 + + tests/libntp/netof.c@1.4 +9 -6 + + tests/libntp/octtoint.c@1.4 +14 -7 + + tests/libntp/socktoa.c@1.4 +16 -13 + +ChangeSet@1.3523.1.3, 2015-07-06 08:37:13+00:00, stenn@psp-at1.ntp.org + [Bug 2874] Don't distribute generated sntp/tests/fileHandlingTest.h. H.Stenn + + ChangeLog@1.1708.1.2 +1 -0 + [Bug 2874] Don't distribute generated sntp/tests/fileHandlingTest.h. H.Stenn + + sntp/tests/Makefile.am@1.60 +0 -1 + [Bug 2874] Don't distribute generated sntp/tests/fileHandlingTest.h. H.Stenn + +ChangeSet@1.3523.1.2, 2015-07-06 08:31:19+00:00, stenn@psp-at1.ntp.org + update tests/libntp/run-lfpfunc.c + + tests/libntp/run-lfpfunc.c@1.13 +9 -9 + update + +ChangeSet@1.3523.1.1, 2015-07-06 05:48:25+00:00, stenn@psp-at1.ntp.org + sntp/unity/Makefile.am: fix some broken paths. Harlan Stenn. + + ChangeLog@1.1708.1.1 +1 -0 + sntp/unity/Makefile.am: fix some broken paths. Harlan Stenn. + + sntp/tests/Makefile.am@1.59 +4 -4 + sntp/unity/Makefile.am: fix some broken paths. Harlan Stenn. + +ChangeSet@1.3524, 2015-07-05 23:58:57+02:00, tomek@tomek-n56vz.(none) + vi64ops.c: + deleted a comment + ymd2yd.c: + fixed formatting, deleted empty setUp() and tearDown() + ssl_init.c: + fixed formatting + ChangeLog: + updated the changes to vi64ops.c + vi64ops.c: + fixed formatting (trailing spaces, the order of includes, return type of a function in a new line) + ChangeLog: + info about tvtots.c + ymd2yd.c: + removed an include + ChangeLog: + info about ymd2yd.c + uglydate.c: + removed an unnecessary include + ChangeLog: + info about uglydate.c + statestr.c: + deleted unnecessary empty functions, fixed formatting, removed an unnecessary include + ChangeLog: + info about vi64ops.c + tvtots.c: + fixed a bug, fixed formatting + Many files: + autogenerated + + ChangeLog@1.1714 +2 -3 + info about ymd2yd.c + + ChangeLog@1.1713 +2 -0 + info about ymd2yd.c + + ChangeLog@1.1712 +2 -1 + updated the changes to vi64ops.c + + ChangeLog@1.1711 +1 -0 + info about vi64ops.c + + ChangeLog@1.1710 +1 -0 + info about uglydate.c + + ChangeLog@1.1709 +4 -0 + info about tvtots.c + + tests/libntp/run-ssl_init.c@1.6 +5 -5 + autogenerated + + tests/libntp/run-statestr.c@1.7 +5 -4 + autogenerated + + tests/libntp/run-tvtots.c@1.3 +4 -3 + autogenerated + + tests/libntp/run-uglydate.c@1.8 +2 -1 + autogenerated + + tests/libntp/run-vi64ops.c@1.5 +3 -3 + autogenerated + + tests/libntp/run-ymd2yd.c@1.8 +4 -4 + autogenerated + + tests/libntp/run-ymd2yd.c@1.7 +5 -4 + autogenerated + + tests/libntp/ssl_init.c@1.7 +11 -6 + fixed formatting + + tests/libntp/statestr.c@1.4 +12 -15 + deleted unnecessary empty functions, fixed formatting, removed an unnecessary include + + tests/libntp/tvtots.c@1.4 +12 -5 + fixed a bug, fixed formatting + + tests/libntp/uglydate.c@1.6 +0 -1 + removed an unnecessary include + + tests/libntp/vi64ops.c@1.5 +1 -1 + deleted a comment + + tests/libntp/vi64ops.c@1.4 +17 -14 + fixed formatting (trailing spaces, the order of includes, return type of a function in a new line) + + tests/libntp/ymd2yd.c@1.5 +0 -1 + removed an include + + tests/libntp/ymd2yd.c@1.4 +14 -16 + fixed formatting, deleted empty setUp() and tearDown() + +ChangeSet@1.3523, 2015-07-05 18:41:36+02:00, tomek@tomek-n56vz.(none) + refnumtoa.c: + fixed formatting + numtoa.c: + remove unnecessary empty functions, fix formatting + lfpfunc.c: + remove unnecessary include, remove old comments, fix formatting, cleanup + numtohost.c: + added const, fixed formatting + lfptostr.c: + fix formatting, delete an include + lfpfunc.c: + removed an endline + ChangeLog: + update with new changes to numtoa.c + numtoa.c: + added "const" + ChangeLog: + changes with numtohost.c + added changes to lfpfunc.c + add info about numtoa.c + updated with modetoa.c changes + add info about lfptostr.c + msyslog.c, modetoa.c: + fix formatting + Many files: + autogenerated + ChangeLog: + add info about msyslog.c + lfpfunc.c: + added spaces after the commas + ChangeLog: + updated info about refnumtoa.c + + ChangeLog@1.1708 +1 -0 + updated info about refnumtoa.c + + ChangeLog@1.1707 +1 -0 + changes with numtohost.c + + ChangeLog@1.1706 +2 -2 + update with new changes to numtoa.c + + ChangeLog@1.1705 +2 -0 + add info about numtoa.c + + ChangeLog@1.1704 +1 -0 + add info about msyslog.c + + ChangeLog@1.1703 +1 -0 + updated with modetoa.c changes + + ChangeLog@1.1702 +3 -1 + add info about lfptostr.c + + ChangeLog@1.1701 +2 -0 + added changes to lfpfunc.c + + tests/libntp/lfpfunc.c@1.11 +0 -2 + removed an endline + + tests/libntp/lfpfunc.c@1.10 +55 -55 + added spaces after the commas + + tests/libntp/lfpfunc.c@1.9 +100 -188 + remove unnecessary include, remove old comments, fix formatting, cleanup + + tests/libntp/lfptostr.c@1.3 +20 -13 + fix formatting, delete an include + + tests/libntp/modetoa.c@1.6 +5 -5 + fix formatting + + tests/libntp/msyslog.c@1.5 +11 -2 + fix formatting + + tests/libntp/numtoa.c@1.5 +3 -3 + added "const" + + tests/libntp/numtoa.c@1.4 +12 -20 + remove unnecessary empty functions, fix formatting + + tests/libntp/numtohost.c@1.4 +3 -4 + added const, fixed formatting + + tests/libntp/refnumtoa.c@1.4 +10 -12 + fixed formatting + + tests/libntp/run-lfpfunc.c@1.12 +9 -9 + autogenerated + + tests/libntp/run-lfptostr.c@1.3 +11 -10 + autogenerated + + tests/libntp/run-modetoa.c@1.8 +2 -1 + autogenerated + + tests/libntp/run-msyslog.c@1.5 +8 -8 + autogenerated + + tests/libntp/run-numtoa.c@1.7 +3 -2 + autogenerated + + tests/libntp/run-numtohost.c@1.7 +1 -0 + autogenerated + + tests/libntp/run-refnumtoa.c@1.5 +1 -1 + autogenerated + +ChangeSet@1.3514.2.2, 2015-07-04 21:58:49+00:00, stenn@psp-at1.ntp.org + sntp/libevent/evconfig-private.h: remove generated filefrom SCM. H.Stenn. + + BitKeeper/deleted/42/evconfig-private.h~c311ed41afa56d3b@1.2 +0 -0 + Delete: sntp/libevent/evconfig-private.h + + ChangeLog@1.1695.1.2 +1 -0 + sntp/libevent/evconfig-private.h: remove generated filefrom SCM. H.Stenn. + +ChangeSet@1.3514.2.1, 2015-07-04 21:44:33+00:00, stenn@psp-at1.ntp.org + sntp/unity/unity_config.h: Distribute it. Harlan Stenn. + + ChangeLog@1.1695.1.1 +1 -0 + sntp/unity/unity_config.h: Distribute it. Harlan Stenn. + + sntp/unity/Makefile.am@1.6.1.1 +1 -0 + sntp/unity/unity_config.h: Distribute it. Harlan Stenn. + +ChangeSet@1.3513.1.1, 2015-07-04 23:32:08+02:00, viperus@ubuntu.(none) + timevalops.c: + added timevaltoa() and fixed the printfs + timespecops.c: + added timespectoa() and fixed the printfs + + tests/libntp/run-timespecops.c@1.6 +28 -28 + + tests/libntp/run-timevalops.c@1.8 +28 -28 + + tests/libntp/timespecops.c@1.6 +58 -1 + added timespectoa() and fixed the printfs + + tests/libntp/timevalops.c@1.9 +53 -1 + added timevaltoa() and fixed the printfs + +ChangeSet@1.3520, 2015-07-04 14:10:34+00:00, tflendrich@psp-deb1.ntp.org + ChangeLog: + updated my changes + + ChangeLog@1.1698 +1 -0 + updated my changs + +ChangeSet@1.3519, 2015-07-04 15:41:50+02:00, tomek@tomek-n56vz.(none) + ChangeLog: + updated to match my changes + + ChangeLog@1.1697 +3 -3 + updated to match my changes + +ChangeSet@1.3518, 2015-07-04 15:39:51+02:00, tomek@tomek-n56vz.(none) + humandate.c: + reordered code so that it is C90-compilant, renamed variables so that they are different that function names, fixed formatting to match NTP's convention + hextolfp.c: + removed a trailing endline, changed formatting to match NTP's convention, + decodenetnum.c: + changed the order of imports, removed an unnecessary import, removed a trailing space, changed the return type from a function to be in a new line + run-humandate.c, run-hextolfp.c, run-decodenetnum.c: + autogenerated + + tests/libntp/decodenetnum.c@1.3 +16 -11 + changed the order of imports, removed an unnecessary import, removed a trailing space, changed the return type from a function to be in a new line + + tests/libntp/hextolfp.c@1.5 +12 -7 + removed a trailing endline, changed formatting to match NTP's convention, + + tests/libntp/humandate.c@1.4 +11 -9 + reordered code so that it is C90-compilant, renamed variables so that they are different that function names, fixed formatting to match NTP's convention + + tests/libntp/run-decodenetnum.c@1.4 +5 -5 + autogenerated + + tests/libntp/run-hextolfp.c@1.5 +6 -6 + autogenerated + + tests/libntp/run-humandate.c@1.3 +3 -2 + autogenerated + +ChangeSet@1.3517, 2015-07-04 12:38:08+00:00, tflendrich@psp-deb1.ntp.org + Makefile.am: + adding a forgotten header, so that "make distcheck" works + + sntp/unity/Makefile.am@1.7 +1 -0 + adding a forgotten header, so that "make distcheck" works + +ChangeSet@1.3516, 2015-07-04 11:55:26+00:00, tflendrich@psp-deb1.ntp.org + ChangeLog: + updated with my changes + + ChangeLog@1.1696 +4 -0 + updated with my changes + +ChangeSet@1.3499.1.1, 2015-07-04 13:39:28+02:00, tomek@tomek-n56vz.(none) + buftvtots.c: + fix formatting, declarations before code (C90) + authkeys.c: + fixed formatting, removed unnecessary comment + calendar.c: + further cleanup: deleted unnecessary comments, made first declaration, then code + clocktime.c: + removed comments, fixed formatting + a_md5encrypt.c: + fix formatting, add (void) as argument to a function etc + caltontp.c: + fixed the order of #includes + run-buftvtots.c, run-a_md5encrypt.c: + adding autogenerated file + calendar.c: + deleted comments, fixed formatting, used snprintf instead of sprintf, change variable names to be meaningful, + caljulian.c: + changed sprintf to snprintf, fixed formatting etc + a_md5encrypt.c: + changed to first declaration, then code (C90 compatibility) + Many files: + autogenerated + authkeys.c: + further changes of formatting + + tests/libntp/a_md5encrypt.c@1.9 +8 -3 + changed to first declaration, then code (C90 compatibility) + + tests/libntp/a_md5encrypt.c@1.8 +17 -21 + fix formatting, add (void) as argument to a function etc + + tests/libntp/authkeys.c@1.8 +20 -10 + further changes of formatting + + tests/libntp/authkeys.c@1.7 +5 -11 + fixed formatting, removed unnecessary comment + + tests/libntp/buftvtots.c@1.2 +10 -7 + fix formatting, declarations before code (C90) + + tests/libntp/calendar.c@1.4 +12 -7 + further cleanup: deleted unnecessary comments, made first declaration, then code + + tests/libntp/calendar.c@1.3 +121 -114 + deleted comments, fixed formatting, used snprintf instead of sprintf, change variable names to be meaningful, + + tests/libntp/caljulian.c@1.7 +41 -39 + changed sprintf to snprintf, fixed formatting etc + + tests/libntp/caltontp.c@1.2 +1 -1 + fixed the order of #includes + + tests/libntp/clocktime.c@1.4 +24 -15 + removed comments, fixed formatting + + tests/libntp/run-a_md5encrypt.c@1.11 +4 -4 + adding autogenerated file + + tests/libntp/run-a_md5encrypt.c@1.10 +10 -10 + adding autogenerated file + + tests/libntp/run-authkeys.c@1.8 +6 -5 + autogenerated + + tests/libntp/run-buftvtots.c@1.2 +9 -8 + adding autogenerated file + + tests/libntp/run-calendar.c@1.5 +10 -10 + autogenerated + + tests/libntp/run-calendar.c@1.4 +22 -21 + autogenerated + + tests/libntp/run-caljulian.c@1.9 +7 -7 + autogenerated + + tests/libntp/run-caltontp.c@1.2 +1 -0 + autogenerated + + tests/libntp/run-clocktime.c@1.5 +17 -16 + autogenerated + +ChangeSet@1.3514, 2015-07-04 10:24:57+00:00, viperus@psp-at1.ntp.org + cleanup + + ChangeLog@1.1695 +2 -3 + cleanup + +ChangeSet@1.3512, 2015-07-04 12:19:42+02:00, viperus@ubuntu.(none) + fixes to unsigned printing in timespecops.c and timevalops.c + + tests/libntp/timespecops.c@1.5 +1 -1 + + tests/libntp/timevalops.c@1.8 +1 -1 + +ChangeSet@1.3511, 2015-07-04 12:15:31+02:00, viperus@ubuntu.(none) + ChangeLog: + added my changes + timespecops.c: + many fixes, better printfs etc. + minor fixes to printf, formatting, etc. + timevalops.c: + minor fixes to printf, formatting, etc. + + ChangeLog@1.1692.1.1 +3 -0 + added my changes + + tests/libntp/run-timespecops.c@1.5 +28 -28 + + tests/libntp/run-timevalops.c@1.7 +28 -28 + + tests/libntp/timespecops.c@1.4 +7 -13 + many fixes, better printfs etc. + minor fixes to printf, formatting, etc. + + tests/libntp/timevalops.c@1.7 +5 -9 + minor fixes to printf, formatting, etc. + +ChangeSet@1.3509.1.1, 2015-07-04 09:34:18+00:00, stenn@psp-at1.ntp.org + [Bug 2866] segmentation fault at initgroups(). Harlan Stenn. + + ChangeLog@1.1693 +1 -0 + [Bug 2866] segmentation fault at initgroups(). Harlan Stenn. + + ntpd/ntpd.c@1.160 +11 -4 + [Bug 2866] segmentation fault at initgroups(). Harlan Stenn. + +ChangeSet@1.3510, 2015-07-04 11:27:04+02:00, viperus@ubuntu.(none) + sockaddrtest.h: + fully converted some tricky cout to printf (af_inet, sockaddr etc.) + + tests/libntp/sockaddrtest.h@1.4 +3 -7 + fully converted some tricky cout to printf (af_inet, sockaddr etc.) + +ChangeSet@1.3505.1.3, 2015-07-04 09:19:48+00:00, stenn@psp-at1.ntp.org + sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris. Harlan Stenn. + + ChangeLog@1.1690.1.2 +1 -0 + sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris. Harlan Stenn. + + sntp/unity/unity_internals.h@1.4 +6 -6 + sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris. Harlan Stenn. + +ChangeSet@1.3505.1.2, 2015-07-04 09:16:51+00:00, stenn@psp-at1.ntp.org + sntp/unity/unity_config.h: handle stdint.h. Harlan Stenn. + + ChangeLog@1.1690.1.1 +1 -0 + sntp/unity/unity_config.h: handle stdint.h. Harlan Stenn. + + sntp/unity/unity_config.h@1.2 +4 -0 + sntp/unity/unity_config.h: handle stdint.h. Harlan Stenn. + +ChangeSet@1.3508, 2015-07-04 09:11:47+00:00, stenn@psp-at1.ntp.org + tests/{libntp,ntpd} function parameter cleanup from Damir + + ChangeLog@1.1691 +2 -0 + tests/{libntp,ntpd} function parameter cleanup from Damir + +ChangeSet@1.3505.1.1, 2015-07-04 08:56:15+00:00, stenn@psp-at1.ntp.org + Update sntp/tests/run-crypto.c + + sntp/tests/run-crypto.c@1.2 +6 -6 + Update sntp/tests/run-crypto.c + +ChangeSet@1.3504.1.2, 2015-07-04 10:38:08+02:00, viperus@ubuntu.(none) + minor fixes, adding void, cleanup... + + tests/libntp/a_md5encrypt.c@1.7.1.1 +5 -5 + + tests/libntp/atouint.c@1.4 +5 -5 + + tests/libntp/authkeys.c@1.6.1.1 +6 -6 + + tests/libntp/buftvtots.c@1.1.1.1 +4 -4 + + tests/libntp/calendar.c@1.2.1.1 +27 -32 + + tests/libntp/caljulian.c@1.6.1.1 +6 -8 + + tests/libntp/calyearstart.c@1.3 +6 -6 + + tests/libntp/clocktime.c@1.3.1.1 +10 -10 + + tests/libntp/lfpfunc.c@1.8 +9 -10 + + tests/libntp/lfptest.h@1.4 +2 -0 + + tests/libntp/msyslog.c@1.4 +0 -1 + + tests/libntp/refnumtoa.c@1.3 +2 -2 + + tests/libntp/run-a_md5encrypt.c@1.9.1.1 +5 -5 + + tests/libntp/run-atouint.c@1.7 +6 -5 + + tests/libntp/run-authkeys.c@1.7.1.1 +7 -6 + + tests/libntp/run-buftvtots.c@1.1.1.1 +5 -4 + + tests/libntp/run-calendar.c@1.3.1.1 +23 -22 + + tests/libntp/run-caljulian.c@1.8.1.1 +8 -8 + + tests/libntp/run-calyearstart.c@1.4 +4 -3 + + tests/libntp/run-clocktime.c@1.4.1.1 +9 -8 + + tests/libntp/run-lfpfunc.c@1.11 +17 -17 + + tests/libntp/run-msyslog.c@1.4 +8 -8 + + tests/libntp/run-refidsmear.c@1.3 +1 -1 + + tests/libntp/run-refnumtoa.c@1.4 +3 -2 + + tests/libntp/run-ssl_init.c@1.5 +6 -5 + + tests/libntp/run-timespecops.c@1.4 +29 -28 + + tests/libntp/run-timevalops.c@1.6 +29 -28 + + tests/libntp/run-vi64ops.c@1.4 +6 -6 + + tests/libntp/ssl_init.c@1.6 +5 -5 + + tests/libntp/timespecops.c@1.3 +28 -28 + + tests/libntp/timevalops.c@1.6 +37 -37 + + tests/libntp/vi64ops.c@1.3 +10 -11 + +ChangeSet@1.3504.1.1, 2015-07-04 10:08:41+02:00, viperus@ubuntu.(none) + minor warning fixes, adding voids etc. + + tests/ntpd/leapsec.c@1.3 +40 -45 + + tests/ntpd/run-leapsec.c@1.3 +66 -66 + +ChangeSet@1.3505, 2015-07-04 08:08:23+00:00, stenn@psp-at1.ntp.org + sntp/tests/ function parameter list cleanup. Damir Tomi\xc4\x87. + + ChangeLog@1.1690 +1 -0 + sntp/tests/ function parameter list cleanup. Damir Tomi\xc4\x87. + +ChangeSet@1.3504, 2015-07-04 09:49:26+02:00, viperus@ubuntu.(none) + minor warning fixes like adding void etc. + + sntp/tests/crypto.c@1.6 +1 -0 + + sntp/tests/keyFile.c@1.4 +5 -5 + + sntp/tests/kodDatabase.c@1.3 +5 -5 + + sntp/tests/kodFile.c@1.6 +8 -8 + + sntp/tests/packetProcessing.c@1.5 +2 -2 + + sntp/tests/run-keyFile.c@1.5 +6 -5 + + sntp/tests/run-kodDatabase.c@1.2 +6 -5 + + sntp/tests/run-kodFile.c@1.3 +7 -6 + + sntp/tests/run-utilities.c@1.2 +14 -14 + + sntp/tests/sntptest.h@1.4 +6 -3 + + sntp/tests/utilities.c@1.2 +7 -9 + +ChangeSet@1.3503, 2015-07-04 07:25:15+00:00, stenn@psp-at1.ntp.org + top_srcdir can change based on ntp v. sntp. Harlan Stenn. + + ChangeLog@1.1689 +1 -0 + top_srcdir can change based on ntp v. sntp. Harlan Stenn. + + sntp/tests/Makefile.am@1.58 +1 -1 + top_srcdir can change based on ntp v. sntp. Harlan Stenn. + +ChangeSet@1.3502, 2015-07-04 00:44:41-04:00, stenn@deacon.udel.edu + On some versions of HP-UX, inttypes.h does not include stdint.h. H.Stenn. + + ChangeLog@1.1688 +1 -0 + On some versions of HP-UX, inttypes.h does not include stdint.h. H.Stenn. + + include/ntp_types.h@1.35 +2 -1 + On some versions of HP-UX, inttypes.h does not include stdint.h. H.Stenn. + +ChangeSet@1.3501, 2015-07-04 03:49:10+00:00, stenn@psp-at1.ntp.org + Phase 1 deprecation of google test in sntp/tests/. Harlan Stenn. + + ChangeLog@1.1687 +1 -0 + Phase 1 deprecation of google test in sntp/tests/. Harlan Stenn. + + sntp/tests/Makefile.am@1.57 +20 -97 + Phase 1 deprecation of google test in sntp/tests/. Harlan Stenn. + +ChangeSet@1.3500, 2015-07-03 20:30:06+00:00, stenn@psp-fb1.ntp.org + tests/ntpd/g_leapsec.cpp typo fix. Harlan Stenn. + + ChangeLog@1.1686 +1 -0 + tests/ntpd/g_leapsec.cpp typo fix. Harlan Stenn. + + tests/ntpd/g_leapsec.cpp@1.16 +1 -1 + tests/ntpd/g_leapsec.cpp typo fix. Harlan Stenn. + +ChangeSet@1.3498, 2015-07-03 19:27:53+00:00, stenn@psp-at1.ntp.org + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + ChangeLog@1.1685 +1 -0 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + sntp/tests/Makefile.am@1.56 +4 -2 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + sntp/unity/Makefile.am@1.6 +1 -1 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + sntp/unity/unity_config.h@1.1 +8 -0 + BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-unity/sntp/unity/unity_config.h + + sntp/unity/unity_config.h@1.0 +0 -0 + + tests/bug-2803/Makefile.am@1.13 +2 -0 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + tests/libntp/Makefile.am@1.83.1.1 +2 -4 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + tests/ntpd/Makefile.am@1.1.1.1 +2 -0 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + tests/sandbox/Makefile.am@1.5 +2 -0 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + tests/sandbox/smeartest.c@1.3.1.3 +12 -0 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + + tests/sec-2853/Makefile.am@1.3 +2 -0 + Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. + +ChangeSet@1.3497, 2015-07-03 09:30:02+00:00, stenn@psp-at1.ntp.org + libntp/emalloc.c: Remove explicit include of stdint.h. Harlan Stenn. + + ChangeLog@1.1684 +1 -0 + libntp/emalloc.c: Remove explicit include of stdint.h. Harlan Stenn. + + libntp/emalloc.c@1.19 +0 -2 + libntp/emalloc.c: Remove explicit include of stdint.h. Harlan Stenn. + +ChangeSet@1.3492.1.3, 2015-07-02 09:34:06+00:00, stenn@psp-at1.ntp.org + Fix ChangeLog + + ChangeLog@1.1680.1.2 +3 -1 + Fix ChangeLog + +ChangeSet@1.3495, 2015-07-02 09:32:14+00:00, stenn@psp-at1.ntp.org + Fix ChangeLog + + ChangeLog@1.1682 +3 -1 + Fix ChangeLog + +ChangeSet@1.3473.1.23, 2015-07-01 10:06:49+02:00, viperus@ubuntu.(none) + leapsec.c: + added include to fix everything, yey! + Makefile.am: + changed the order of libntp.a and libntpd.a, stuff builds now + + tests/ntpd/Makefile.am@1.3 +11 -9 + changed the order of libntp.a and libntpd.a, stuff builds now + + tests/ntpd/leapsec.c@1.2 +8 -4 + added include to fix everything, yey! + + tests/ntpd/run-leapsec.c@1.2 +33 -33 + +ChangeSet@1.3473.1.22, 2015-07-01 09:31:35+02:00, viperus@ubuntu.(none) + g_leapsec.cpp: + Rename: tests/ntpd/leapsec.cpp -> tests/ntpd/g_leapsec.cpp + run-leapsec.c, leapsec.c: + new file + Makefile.am: + added /tests/ntpd/ dir + unity tests + removed a comment line + g_ntpdtest.h: + Rename: tests/ntpd/ntpdtest.h -> tests/ntpd/g_ntpdtest.h + Makefile.am: + added support for unity tests + test-libntp.h: + added new headers + g_ntpdtest.cpp: + minor change in the header name + Rename: tests/ntpd/ntpdtest.cpp -> tests/ntpd/g_ntpdtest.cpp + + tests/Makefile.am@1.9.1.1 +6 -5 + added /tests/ntpd/ dir + unity tests + + tests/libntp/Makefile.am@1.84 +0 -1 + removed a comment line + + tests/libntp/test-libntp.h@1.7 +5 -0 + added new headers + + tests/ntpd/Makefile.am@1.2 +62 -6 + added support for unity tests + + tests/ntpd/g_leapsec.cpp@1.15 +0 -0 + Rename: tests/ntpd/leapsec.cpp -> tests/ntpd/g_leapsec.cpp + + tests/ntpd/g_ntpdtest.cpp@1.3 +1 -1 + minor change in the header name + + tests/ntpd/g_ntpdtest.cpp@1.2 +0 -0 + Rename: tests/ntpd/ntpdtest.cpp -> tests/ntpd/g_ntpdtest.cpp + + tests/ntpd/g_ntpdtest.h@1.2 +0 -0 + Rename: tests/ntpd/ntpdtest.h -> tests/ntpd/g_ntpdtest.h + + tests/ntpd/leapsec.c@1.1 +1230 -0 + BitKeeper file /home/viperus/Desktop/ntp-stable-unity/tests/ntpd/leapsec.c + + tests/ntpd/leapsec.c@1.0 +0 -0 + + tests/ntpd/run-leapsec.c@1.1 +116 -0 + BitKeeper file /home/viperus/Desktop/ntp-stable-unity/tests/ntpd/run-leapsec.c + + tests/ntpd/run-leapsec.c@1.0 +0 -0 + +ChangeSet@1.3492.2.1, 2015-07-01 03:11:28-04:00, stenn@deacon.udel.edu + Update the repo's description and contact email + + BitKeeper/etc/config@1.11 +2 -2 + Update the repo's description and contact email + +ChangeSet@1.3492.1.1, 2015-07-01 08:53:24+02:00, jnperlin@hydra.(none) + [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv' + + ChangeLog@1.1680.1.1 +1 -0 + [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv' + + + ntpd/ntp_control.c@1.201 +5 -2 + [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv' + make sure 'ctl_var' table matches indices (CS_LEAPSMEAR* is unconditionally defined and affects AUTOKEY vars) + +ChangeSet@1.3493, 2015-07-01 08:40:44+02:00, jnperlin@nemesis.localnet + [Bug 2864] 4.2.8p3 fails to compile on Windows. + fixed project files. (tested with VS2008 and VS2013) + + ChangeLog@1.1681 +1 -0 + [Bug 2864] 4.2.8p3 fails to compile on Windows. + fix project files. (tested with VS2008 and VS2013) + + ports/winnt/vs2005/ntpd.vcproj@1.20 +22 -0 + [Bug 2864] 4.2.8p3 fails to compile on Windows. + fixed project files. (UNTESTED!) + + ports/winnt/vs2008/ntpd/ntpd.vcproj@1.49 +4 -0 + [Bug 2864] 4.2.8p3 fails to compile on Windows. + fixed project files. (tested) + + ports/winnt/vs2013/ntpd/ntpd.vcxproj@1.7 +1 -0 + [Bug 2864] 4.2.8p3 fails to compile on Windows. + fixed project files. (tested) + + ports/winnt/vs2013/ntpd/ntpd.vcxproj.filters@1.5 +3 -0 + [Bug 2864] 4.2.8p3 fails to compile on Windows. + fixed project files. (tested) + +ChangeSet@1.3492, 2015-06-29 16:52:34-04:00, stenn@deacon.udel.edu + Makefile.in should not be checked in + + BitKeeper/deleted/bd/Makefile.in~a06c74c485656b20@1.3 +0 -0 + Delete: tests/sec-2853/Makefile.in + ChangeSet@1.3491, 2015-06-29 16:34:44-04:00, stenn@deacon.udel.edu NTP_4_2_8P3 TAG: NTP_4_2_8P3 @@ -344,7 +5257,16 @@ ChangeSet@1.3489, 2015-06-29 19:33:22+00:00, stenn@psp-at1.ntp.org NEWS@1.144 +18 -3 NEWS file update for bug 2853 -ChangeSet@1.3473.1.40, 2015-06-29 06:00:52+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.1.21, 2015-06-29 20:33:15+02:00, viperus@ubuntu.(none) + a_md5encrypt.c: + minor change to memory compare, suggested by Tomasz + + tests/libntp/a_md5encrypt.c@1.7 +2 -1 + minor change to memory compare, suggested by Tomasz + + tests/libntp/run-a_md5encrypt.c@1.9 +5 -4 + +ChangeSet@1.3473.3.23, 2015-06-29 06:00:52+00:00, stenn@psp-at1.ntp.org html/miscopt.html: Document leapsmearinterval, other cleanup. Harlan Stenn. ChangeLog@1.1666.1.19 +1 -0 @@ -353,7 +5275,7 @@ ChangeSet@1.3473.1.40, 2015-06-29 06:00:52+00:00, stenn@psp-at1.ntp.org html/miscopt.html@1.82 +18 -15 html/miscopt.html: Document leapsmearinterval, other cleanup. Harlan Stenn. -ChangeSet@1.3473.1.39, 2015-06-29 05:28:47+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.22, 2015-06-29 05:28:47+00:00, stenn@psp-at1.ntp.org ntpd/ntp.conf.def: Document DSCP and leapsmearinterval. Harlan Stenn. ChangeLog@1.1666.1.18 +1 -0 @@ -383,14 +5305,14 @@ ChangeSet@1.3486, 2015-06-29 03:39:39+00:00, stenn@psp-at1.ntp.org ChangeLog@1.1677 +2 -1 Updated entry for Sec 2853 -ChangeSet@1.3473.3.2, 2015-06-29 04:57:16+02:00, tomek@tomek-n56vz.(none) +ChangeSet@1.3473.4.2, 2015-06-29 04:57:16+02:00, tomek@tomek-n56vz.(none) ChangeLog: moved a change to the proper place ChangeLog@1.1666.2.2 +1 -1 moved a change to the proper place -ChangeSet@1.3473.3.1, 2015-06-29 04:50:55+02:00, tomek@tomek-n56vz.(none) +ChangeSet@1.3473.4.1, 2015-06-29 04:50:55+02:00, tomek@tomek-n56vz.(none) ChangeLog: updated my changes msyslog.c: @@ -407,7 +5329,7 @@ ChangeSet@1.3473.3.1, 2015-06-29 04:50:55+02:00, tomek@tomek-n56vz.(none) tests/libntp/run-msyslog.c@1.3 +1 -0 checking in the autogenerated file -ChangeSet@1.3473.1.37, 2015-06-29 01:16:44+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.20, 2015-06-29 01:16:44+00:00, stenn@psp-at1.ntp.org [Bug 2860] ntpq ifstats sanity check is too stringent. Frank Kardel. ChangeLog@1.1666.1.16 +1 -0 @@ -419,13 +5341,13 @@ ChangeSet@1.3473.1.37, 2015-06-29 01:16:44+00:00, stenn@psp-at1.ntp.org ntpq/ntpq-subs.c@1.109 +1 -1 [Bug 2860] ntpq ifstats sanity check is too stringent. Frank Kardel. -ChangeSet@1.3473.1.36, 2015-06-29 01:13:38+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.19, 2015-06-29 01:13:38+00:00, stenn@psp-at1.ntp.org Update the NEWS file with info about README.leapsmear NEWS@1.142 +2 -1 Update the NEWS file with info about README.leapsmear -ChangeSet@1.3473.1.35, 2015-06-29 00:10:53+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.18, 2015-06-29 00:10:53+00:00, stenn@psp-at1.ntp.org README.leapsmear edited. Harlan Stenn. ChangeLog@1.1666.1.15 +1 -0 @@ -434,7 +5356,7 @@ ChangeSet@1.3473.1.35, 2015-06-29 00:10:53+00:00, stenn@psp-at1.ntp.org README.leapsmear@1.2 +240 -75 README.leapsmear edited. Harlan Stenn. -ChangeSet@1.3473.1.34, 2015-06-28 21:20:27+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.17, 2015-06-28 21:20:27+00:00, stenn@psp-at1.ntp.org README.leapsmear added. Martin Burnicki. ChangeLog@1.1666.1.14 +1 -0 @@ -448,19 +5370,19 @@ ChangeSet@1.3473.1.34, 2015-06-28 21:20:27+00:00, stenn@psp-at1.ntp.org README.leapsmear@1.0 +0 -0 -ChangeSet@1.3473.1.33, 2015-06-27 23:05:51-04:00, stenn@deacon.udel.edu +ChangeSet@1.3473.3.16, 2015-06-27 23:05:51-04:00, stenn@deacon.udel.edu [Bug 2846] Report 'unsynchronized' status during the leap second. Fixed in Martin's changes to Bug 2855. Martin Burnicki. ChangeLog@1.1666.1.13 +2 -0 [Bug 2846] Report 'unsynchronized' status during the leap second. Fixed in Martin's changes to Bug 2855. Martin Burnicki. -ChangeSet@1.3473.1.32, 2015-06-27 21:34:55+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.15, 2015-06-27 21:34:55+00:00, stenn@psp-at1.ntp.org NEWS file update NEWS@1.141 +12 -0 NEWS file update -ChangeSet@1.3473.1.31, 2015-06-27 19:25:39+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.14, 2015-06-27 19:25:39+00:00, stenn@psp-at1.ntp.org [Bug 2859] Improve raw DCF77 robustness deconding. Frank Kardel. ChangeLog@1.1666.1.12 +4 -0 @@ -487,7 +5409,7 @@ ChangeSet@1.3473.1.31, 2015-06-27 19:25:39+00:00, stenn@psp-at1.ntp.org parseutil/testdcf.c@1.11 +1 -1 [Bug 2859] Improve raw DCF77 robustness deconding. Frank Kardel. -ChangeSet@1.3473.1.30, 2015-06-27 05:21:56-04:00, stenn@deacon.udel.edu +ChangeSet@1.3473.3.13, 2015-06-27 05:21:56-04:00, stenn@deacon.udel.edu NTP_4_2_8P3_RC3 TAG: NTP_4_2_8P3_RC3 @@ -821,13 +5743,13 @@ ChangeSet@1.3473.1.30, 2015-06-27 05:21:56-04:00, stenn@deacon.udel.edu util/ntp-keygen.mdoc.in@1.326 +2 -2 NTP_4_2_8P3_RC3 -ChangeSet@1.3473.1.29, 2015-06-27 04:45:02-04:00, stenn@deacon.udel.edu +ChangeSet@1.3473.3.12, 2015-06-27 04:45:02-04:00, stenn@deacon.udel.edu Update the NEWS file for 4.2.8p3-RC3 NEWS@1.140 +26 -0 Update the NEWS file for 4.2.8p3-RC3 -ChangeSet@1.3473.1.28, 2015-06-27 04:20:07-04:00, stenn@deacon.udel.edu +ChangeSet@1.3473.3.11, 2015-06-27 04:20:07-04:00, stenn@deacon.udel.edu html/drivers/driver22.html: typo fix. Harlan Stenn. ChangeLog@1.1666.1.10 +1 -0 @@ -836,7 +5758,7 @@ ChangeSet@1.3473.1.28, 2015-06-27 04:20:07-04:00, stenn@deacon.udel.edu html/drivers/driver22.html@1.23 +1 -1 html/drivers/driver22.html: typo fix. Harlan Stenn. -ChangeSet@1.3473.1.27, 2015-06-27 02:22:09-04:00, stenn@deacon.udel.edu +ChangeSet@1.3473.3.10, 2015-06-27 02:22:09-04:00, stenn@deacon.udel.edu [Bug 2857] Stratus VOS does not support SIGIO. Paul Green. ChangeLog@1.1666.1.9 +1 -0 @@ -848,7 +5770,7 @@ ChangeSet@1.3473.1.27, 2015-06-27 02:22:09-04:00, stenn@deacon.udel.edu sntp/m4/ntp_libntp.m4@1.30 +9 -0 [Bug 2857] Stratus VOS does not support SIGIO. Paul Green. -ChangeSet@1.3473.1.26, 2015-06-27 01:58:07-04:00, stenn@deacon.udel.edu +ChangeSet@1.3473.3.9, 2015-06-27 01:58:07-04:00, stenn@deacon.udel.edu [Bug 2856] ntpd should wait() on terminated child processes. Paul Green. ChangeLog@1.1666.1.8 +1 -0 @@ -857,7 +5779,7 @@ ChangeSet@1.3473.1.26, 2015-06-27 01:58:07-04:00, stenn@deacon.udel.edu libntp/work_fork.c@1.14 +23 -4 [Bug 2856] ntpd should wait() on terminated child processes. Paul Green. -ChangeSet@1.3473.1.25, 2015-06-27 05:12:21+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.8, 2015-06-27 05:12:21+00:00, stenn@psp-at1.ntp.org [Bug 2855] Report leap smear in the REFID. Harlan Stenn. ChangeLog@1.1666.1.7 +1 -0 @@ -866,7 +5788,7 @@ ChangeSet@1.3473.1.25, 2015-06-27 05:12:21+00:00, stenn@psp-at1.ntp.org ntpd/ntp_proto.c@1.361 +8 -2 [Bug 2855] Report leap smear in the REFID. Harlan Stenn. -ChangeSet@1.3473.1.24, 2015-06-27 04:53:42+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.7, 2015-06-27 04:53:42+00:00, stenn@psp-at1.ntp.org refidsmear test cleanup. Tomasz Flendrich. ChangeLog@1.1666.1.6 +1 -0 @@ -875,14 +5797,14 @@ ChangeSet@1.3473.1.24, 2015-06-27 04:53:42+00:00, stenn@psp-at1.ntp.org tests/libntp/refidsmear.c@1.4 +4 -5 refidsmear test cleanup. Tomasz Flendrich. -ChangeSet@1.3473.1.23, 2015-06-27 06:44:17+02:00, tomek@tomek-n56vz.(none) +ChangeSet@1.3473.3.6, 2015-06-27 06:44:17+02:00, tomek@tomek-n56vz.(none) refidsmear.c: moved assertions to proper places tests/libntp/refidsmear.c@1.3 +4 -2 moved assertions to proper places -ChangeSet@1.3473.1.22, 2015-06-27 04:46:21+02:00, tomek@tomek-n56vz.(none) +ChangeSet@1.3473.3.5, 2015-06-27 04:46:21+02:00, tomek@tomek-n56vz.(none) run-refidsmear.c: updated autogenerated file refidsmear.c: @@ -894,7 +5816,7 @@ ChangeSet@1.3473.1.22, 2015-06-27 04:46:21+02:00, tomek@tomek-n56vz.(none) tests/libntp/run-refidsmear.c@1.2 +1 -1 updated autogenerated file -ChangeSet@1.3473.1.21, 2015-06-27 01:16:47+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.4, 2015-06-27 01:16:47+00:00, stenn@psp-at1.ntp.org refidsmear function support and tests. Harlan Stenn. ChangeLog@1.1666.1.5 +1 -0 @@ -929,24 +5851,31 @@ ChangeSet@1.3473.1.21, 2015-06-27 01:16:47+00:00, stenn@psp-at1.ntp.org tests/libntp/run-refidsmear.c@1.0 +0 -0 -ChangeSet@1.3473.1.20, 2015-06-26 22:45:16+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.3, 2015-06-26 22:45:16+00:00, stenn@psp-at1.ntp.org tests/sandbox/smeartest.c: Harlan Stenn, Damir Tomic, Juergen Perlinger. ChangeLog@1.1666.1.4 +1 -0 tests/sandbox/smeartest.c: Harlan Stenn, Damir Tomic, Juergen Perlinger. -ChangeSet@1.3473.1.19, 2015-06-26 20:10:51+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.2, 2015-06-26 20:10:51+00:00, stenn@psp-at1.ntp.org smeartest.c fixes from Harlan - tests/sandbox/smeartest.c@1.5 +52 -1 + tests/sandbox/smeartest.c@1.3.1.2 +52 -1 smeartest.c fixes from Harlan -ChangeSet@1.3473.1.18, 2015-06-26 18:43:39+00:00, stenn@psp-at1.ntp.org +ChangeSet@1.3473.3.1, 2015-06-26 18:43:39+00:00, stenn@psp-at1.ntp.org smeartest.c fixes from Juergen, Damir, and Harlan - tests/sandbox/smeartest.c@1.4 +26 -17 + tests/sandbox/smeartest.c@1.3.1.1 +26 -17 smeartest.c fixes from Juergen, Damir, and Harlan +ChangeSet@1.3473.1.18, 2015-06-26 15:17:10+02:00, viperus@ubuntu.(none) + smeartest.c: + maybed fixed both funtions, needs checking!!! + + tests/sandbox/smeartest.c@1.4 +69 -26 + maybed fixed both funtions, needs checking!!! + ChangeSet@1.3473.1.17, 2015-06-26 11:24:43+00:00, stenn@psp-at1.ntp.org smeartest.c - Harlan Stenn diff --git a/contrib/ntp/FREEBSD-Xlist b/contrib/ntp/FREEBSD-Xlist deleted file mode 100644 index 16cfc18b3215..000000000000 --- a/contrib/ntp/FREEBSD-Xlist +++ /dev/null @@ -1,2 +0,0 @@ -*ports -*html/pic diff --git a/contrib/ntp/FREEBSD-upgrade b/contrib/ntp/FREEBSD-upgrade deleted file mode 100644 index 3253274b14a8..000000000000 --- a/contrib/ntp/FREEBSD-upgrade +++ /dev/null @@ -1,55 +0,0 @@ -# ex:ts=8 -# -# $FreeBSD$ - -NTP 4.2.8 - originals can be found on http://www.ntp.org/downloads.html - -Import ------- - -For the import of NTP the following files were removed: - - ports/* NT files - html/pic/* GIF files - html/build/hints/solaris.xtra.4095849 Trigger merge conflict script - -The stripped down version was created using FREEBSD-Xlist during -extraction: - - tar -X FREEBSD-Xlist -xvzf ntp-4.2.8.tar.gz - mv ntp-4.2.8 4.2.8 - -Imported by: - See procedure on -https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/subversion-primer.html - -Updating usr.sbin/ntp ---------------------- - -./configure --disable-all-clocks --enable-NMEA --enable-ONCORE ---enable-RAWDCF --with-crypto --disable-debugging ---enable-LOCAL-CLOCK --with-sntp --with-arlib --prefix=/usr - -config.h was generated by running configure and excluding almost all clock -drivers (what is included is DCF77 -- what I use --, NMEA, Motorola OnCORE -and local clocks). - -The file is then edited to edit the value of "NO_PARENB_IGNPAR" because we -need to set no parity on the serial port (needed for DCF77). All clock -drivers are then disabled (some of them are included by default by ntpd). - -Note that there are two #ifdef to support other architectures (WRT to long -size and endianness). They'll need to be redone for each upgrade to the -vendor branch to keep config.h in sync. - -ntpd/ntp_control.c is now the only file that is different from the vendor -branch for unsigned char/int fixes and removal of a DoS. - -Documentation in /usr/share/doc/ntp is generated from the HTML files with -lynx (without the GIF files of course). - -A patch to fix IPV6_MULTICAST_LOOP was committed to head as r222444 and -filed as http://bugs.ntp.org/show_bug.cgi?id=1936. Check if still needed -or re-apply on update. - diff --git a/contrib/ntp/Makefile.am b/contrib/ntp/Makefile.am index 11b20bfdb971..43f45edbfff2 100644 --- a/contrib/ntp/Makefile.am +++ b/contrib/ntp/Makefile.am @@ -23,7 +23,7 @@ SUBDIRS = \ tests \ $(NULL) -DISTCHECK_CONFIGURE_FLAGS = -C --with-sntp +DISTCHECK_CONFIGURE_FLAGS = -C --with-sntp --enable-local-libevent $(NTP_DCF) EXTRA_DIST = \ $(srcdir)/COPYRIGHT \ diff --git a/contrib/ntp/Makefile.in b/contrib/ntp/Makefile.in index 4d71d85fd0d2..bc2327ff756f 100644 --- a/contrib/ntp/Makefile.in +++ b/contrib/ntp/Makefile.in @@ -115,6 +115,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -262,6 +263,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -270,6 +272,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -331,6 +334,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ @@ -539,7 +543,7 @@ SUBDIRS = \ tests \ $(NULL) -DISTCHECK_CONFIGURE_FLAGS = -C --with-sntp +DISTCHECK_CONFIGURE_FLAGS = -C --with-sntp --enable-local-libevent $(NTP_DCF) EXTRA_DIST = \ $(srcdir)/COPYRIGHT \ ChangeLog \ diff --git a/contrib/ntp/NEWS b/contrib/ntp/NEWS index 4e61d1b80bb7..e16d93700837 100644 --- a/contrib/ntp/NEWS +++ b/contrib/ntp/NEWS @@ -1,3 +1,498 @@ +--- +NTP 4.2.8p4 + +Focus: Security, Bug fies, enhancements. + +Severity: MEDIUM + +In addition to bug fixes and enhancements, this release fixes the +following 13 low- and medium-severity vulnerabilities: + +* Incomplete vallen (value length) checks in ntp_crypto.c, leading + to potential crashes or potential code injection/information leakage. + + References: Sec 2899, Sec 2671, CVE-2015-7691, CVE-2015-7692, CVE-2015-7702 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, + and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6 + Summary: The fix for CVE-2014-9750 was incomplete in that there were + certain code paths where a packet with particular autokey operations + that contained malicious data was not always being completely + validated. Receipt of these packets can cause ntpd to crash. + Mitigation: + Don't use autokey. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page + Monitor your ntpd instances. + Credit: This weakness was discovered by Tenable Network Security. + +* Clients that receive a KoD should validate the origin timestamp field. + + References: Sec 2901 / CVE-2015-7704, CVE-2015-7705 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, + and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:M/Au:N/C:N/I:N/A:P) Base Score: 4.3-5.0 at worst + Summary: An ntpd client that honors Kiss-of-Death responses will honor + KoD messages that have been forged by an attacker, causing it to + delay or stop querying its servers for time updates. Also, an + attacker can forge packets that claim to be from the target and + send them to servers often enough that a server that implements + KoD rate limiting will send the target machine a KoD response to + attempt to reduce the rate of incoming packets, or it may also + trigger a firewall block at the server for packets from the target + machine. For either of these attacks to succeed, the attacker must + know what servers the target is communicating with. An attacker + can be anywhere on the Internet and can frequently learn the + identity of the target's time source by sending the target a + time query. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download Page + or the NTP Public Services Project Download Page + If you can't upgrade, restrict who can query ntpd to learn who + its servers are, and what IPs are allowed to ask your system + for the time. This mitigation is heavy-handed. + Monitor your ntpd instances. + Note: + 4.2.8p4 protects against the first attack. For the second attack, + all we can do is warn when it is happening, which we do in 4.2.8p4. + Credit: This weakness was discovered by Aanchal Malhotra, + Issac E. Cohen, and Sharon Goldberg of Boston University. + +* configuration directives to change "pidfile" and "driftfile" should + only be allowed locally. + + References: Sec 2902 / CVE-2015-5196 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, + and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:C/A:C) Base Score: 6.2 worst case + Summary: If ntpd is configured to allow for remote configuration, + and if the (possibly spoofed) source IP address is allowed to + send remote configuration requests, and if the attacker knows + the remote configuration password, it's possible for an attacker + to use the "pidfile" or "driftfile" directives to potentially + overwrite other files. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page + If you cannot upgrade, don't enable remote configuration. + If you must enable remote configuration and cannot upgrade, + remote configuration of NTF's ntpd requires: + - an explicitly configured trustedkey, and you should also + configure a controlkey. + - access from a permitted IP. You choose the IPs. + - authentication. Don't disable it. Practice secure key safety. + Monitor your ntpd instances. + Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. + +* Slow memory leak in CRYPTO_ASSOC + + References: Sec 2909 / CVE-2015-7701 + Affects: All ntp-4 releases that use autokey up to, but not + including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 0.0 best/usual case, + 4.6 otherwise + Summary: If ntpd is configured to use autokey, then an attacker can + send packets to ntpd that will, after several days of ongoing + attack, cause it to run out of memory. + Mitigation: + Don't use autokey. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page + Monitor your ntpd instances. + Credit: This weakness was discovered by Tenable Network Security. + +* mode 7 loop counter underrun + + References: Sec 2913 / CVE-2015-7848 / TALOS-CAN-0052 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, + and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6 + Summary: If ntpd is configured to enable mode 7 packets, and if the + use of mode 7 packets is not properly protected thru the use of + the available mode 7 authentication and restriction mechanisms, + and if the (possibly spoofed) source IP address is allowed to + send mode 7 queries, then an attacker can send a crafted packet + to ntpd that will cause it to crash. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade: + In ntp-4.2.8, mode 7 is disabled by default. Don't enable it. + If you must enable mode 7: + configure the use of a requestkey to control who can issue + mode 7 requests. + configure restrict noquery to further limit mode 7 requests + to trusted sources. + Monitor your ntpd instances. +Credit: This weakness was discovered by Aleksandar Nikolic of Cisco Talos. + +* memory corruption in password store + + References: Sec 2916 / CVE-2015-7849 / TALOS-CAN-0054 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:C/A:C) Base Score: 6.8, worst case + Summary: If ntpd is configured to allow remote configuration, and if + the (possibly spoofed) source IP address is allowed to send + remote configuration requests, and if the attacker knows the + remote configuration password or if ntpd was configured to + disable authentication, then an attacker can send a set of + packets to ntpd that may cause a crash or theoretically + perform a code injection attack. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade, remote configuration of NTF's + ntpd requires: + an explicitly configured "trusted" key. Only configure + this if you need it. + access from a permitted IP address. You choose the IPs. + authentication. Don't disable it. Practice secure key safety. + Monitor your ntpd instances. + Credit: This weakness was discovered by Yves Younan of Cisco Talos. + +* Infinite loop if extended logging enabled and the logfile and + keyfile are the same. + + References: Sec 2917 / CVE-2015-7850 / TALOS-CAN-0055 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, + and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6, worst case + Summary: If ntpd is configured to allow remote configuration, and if + the (possibly spoofed) source IP address is allowed to send + remote configuration requests, and if the attacker knows the + remote configuration password or if ntpd was configured to + disable authentication, then an attacker can send a set of + packets to ntpd that will cause it to crash and/or create a + potentially huge log file. Specifically, the attacker could + enable extended logging, point the key file at the log file, + and cause what amounts to an infinite loop. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade, remote configuration of NTF's ntpd + requires: + an explicitly configured "trusted" key. Only configure this + if you need it. + access from a permitted IP address. You choose the IPs. + authentication. Don't disable it. Practice secure key safety. + Monitor your ntpd instances. + Credit: This weakness was discovered by Yves Younan of Cisco Talos. + +* Potential path traversal vulnerability in the config file saving of + ntpd on VMS. + + References: Sec 2918 / CVE-2015-7851 / TALOS-CAN-0062 + Affects: All ntp-4 releases running under VMS up to, but not + including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:P/A:C) Base Score: 5.2, worst case + Summary: If ntpd is configured to allow remote configuration, and if + the (possibly spoofed) IP address is allowed to send remote + configuration requests, and if the attacker knows the remote + configuration password or if ntpd was configured to disable + authentication, then an attacker can send a set of packets to + ntpd that may cause ntpd to overwrite files. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade, remote configuration of NTF's ntpd + requires: + an explicitly configured "trusted" key. Only configure + this if you need it. + access from permitted IP addresses. You choose the IPs. + authentication. Don't disable it. Practice key security safety. + Monitor your ntpd instances. + Credit: This weakness was discovered by Yves Younan of Cisco Talos. + +* ntpq atoascii() potential memory corruption + + References: Sec 2919 / CVE-2015-7852 / TALOS-CAN-0063 + Affects: All ntp-4 releases running up to, but not including 4.2.8p4, + and 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:N/C:N/I:P/A:P) Base Score: 4.0, worst case + Summary: If an attacker can figure out the precise moment that ntpq + is listening for data and the port number it is listening on or + if the attacker can provide a malicious instance ntpd that + victims will connect to then an attacker can send a set of + crafted mode 6 response packets that, if received by ntpq, + can cause ntpq to crash. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade and you run ntpq against a server + and ntpq crashes, try again using raw mode. Build or get a + patched ntpq and see if that fixes the problem. Report new + bugs in ntpq or abusive servers appropriately. + If you use ntpq in scripts, make sure ntpq does what you expect + in your scripts. + Credit: This weakness was discovered by Yves Younan and + Aleksander Nikolich of Cisco Talos. + +* Invalid length data provided by a custom refclock driver could cause + a buffer overflow. + + References: Sec 2920 / CVE-2015-7853 / TALOS-CAN-0064 + Affects: Potentially all ntp-4 releases running up to, but not + including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77 + that have custom refclocks + CVSS: (AV:L/AC:H/Au:M/C:C/I:C/A:C) Base Score: 0.0 usual case, + 5.9 unusual worst case + Summary: A negative value for the datalen parameter will overflow a + data buffer. NTF's ntpd driver implementations always set this + value to 0 and are therefore not vulnerable to this weakness. + If you are running a custom refclock driver in ntpd and that + driver supplies a negative value for datalen (no custom driver + of even minimal competence would do this) then ntpd would + overflow a data buffer. It is even hypothetically possible + in this case that instead of simply crashing ntpd the attacker + could effect a code injection attack. + Mitigation: + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade: + If you are running custom refclock drivers, make sure + the signed datalen value is either zero or positive. + Monitor your ntpd instances. + Credit: This weakness was discovered by Yves Younan of Cisco Talos. + +* Password Length Memory Corruption Vulnerability + + References: Sec 2921 / CVE-2015-7854 / TALOS-CAN-0065 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, and + 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:C/I:C/A:C) Base Score: 0.0 best case, + 1.7 usual case, 6.8, worst case + Summary: If ntpd is configured to allow remote configuration, and if + the (possibly spoofed) source IP address is allowed to send + remote configuration requests, and if the attacker knows the + remote configuration password or if ntpd was (foolishly) + configured to disable authentication, then an attacker can + send a set of packets to ntpd that may cause it to crash, + with the hypothetical possibility of a small code injection. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade, remote configuration of NTF's + ntpd requires: + an explicitly configured "trusted" key. Only configure + this if you need it. + access from a permitted IP address. You choose the IPs. + authentication. Don't disable it. Practice secure key safety. + Monitor your ntpd instances. + Credit: This weakness was discovered by Yves Younan and + Aleksander Nikolich of Cisco Talos. + +* decodenetnum() will ASSERT botch instead of returning FAIL on some + bogus values. + + References: Sec 2922 / CVE-2015-7855 + Affects: All ntp-4 releases up to, but not including 4.2.8p4, and + 4.3.0 up to, but not including 4.3.77 + CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6, worst case + Summary: If ntpd is fed a crafted mode 6 or mode 7 packet containing + an unusually long data value where a network address is expected, + the decodenetnum() function will abort with an assertion failure + instead of simply returning a failure condition. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade: + mode 7 is disabled by default. Don't enable it. + Use restrict noquery to limit who can send mode 6 + and mode 7 requests. + Configure and use the controlkey and requestkey + authentication directives to limit who can + send mode 6 and mode 7 requests. + Monitor your ntpd instances. + Credit: This weakness was discovered by John D "Doug" Birdwell of IDA.org. + +* NAK to the Future: Symmetric association authentication bypass via + crypto-NAK. + + References: Sec 2941 / CVE-2015-7871 + Affects: All ntp-4 releases between 4.2.5p186 up to but not including + 4.2.8p4, and 4.3.0 up to but not including 4.3.77 + CVSS: (AV:N/AC:L/Au:N/C:N/I:P/A:P) Base Score: 6.4 + Summary: Crypto-NAK packets can be used to cause ntpd to accept time + from unauthenticated ephemeral symmetric peers by bypassing the + authentication required to mobilize peer associations. This + vulnerability appears to have been introduced in ntp-4.2.5p186 + when the code handling mobilization of new passive symmetric + associations (lines 1103-1165) was refactored. + Mitigation: + Implement BCP-38. + Upgrade to 4.2.8p4, or later, from the NTP Project Download + Page or the NTP Public Services Project Download Page. + If you are unable to upgrade: + Apply the patch to the bottom of the "authentic" check + block around line 1136 of ntp_proto.c. + Monitor your ntpd instances. + Credit: This weakness was discovered by Stephen Gray . + +Backward-Incompatible changes: +* [Bug 2817] Default on Linux is now "rlimit memlock -1". +While the general default of 32M is still the case, under Linux +the default value has been changed to -1 (do not lock ntpd into + memory). A value of 0 means "lock ntpd into memory with whatever + memory it needs." If your ntp.conf file has an explicit "rlimit memlock" + value in it, that value will continue to be used. + +* [Bug 2886] Misspelling: "outlyer" should be "outlier". + If you've written a script that looks for this case in, say, the + output of ntpq, you probably want to change your regex matches + from 'outlyer' to 'outl[iy]er'. + +New features in this release: +* 'rlimit memlock' now has finer-grained control. A value of -1 means + "don't lock ntpd into memore". This is the default for Linux boxes. + A value of 0 means "lock ntpd into memory" with no limits. Otherwise + the value is the number of megabytes of memory to lock. The default + is 32 megabytes. + +* The old Google Test framework has been replaced with a new framework, + based on http://www.throwtheswitch.org/unity/ . + +Bug Fixes and Improvements: +* [Bug 2332] (reopened) Exercise thread cancellation once before dropping + privileges and limiting resources in NTPD removes the need to link + forcefully against 'libgcc_s' which does not always work. J.Perlinger +* [Bug 2595] ntpdate man page quirks. Hal Murray, Harlan Stenn. +* [Bug 2625] Deprecate flag1 in local refclock. Hal Murray, Harlan Stenn. +* [Bug 2817] Stop locking ntpd into memory by default under Linux. H.Stenn. +* [Bug 2821] minor build issues: fixed refclock_gpsdjson.c. perlinger@ntp.org +* [Bug 2823] ntpsweep with recursive peers option doesn't work. H.Stenn. +* [Bug 2849] Systems with more than one default route may never + synchronize. Brian Utterback. Note that this patch might need to + be reverted once Bug 2043 has been fixed. +* [Bug 2864] 4.2.8p3 fails to compile on Windows. Juergen Perlinger +* [Bug 2866] segmentation fault at initgroups(). Harlan Stenn. +* [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv'. J.Perlinger +* [Bug 2873] libevent should not include .deps/ in the tarball. H.Stenn +* [Bug 2874] Don't distribute generated sntp/tests/fileHandlingTest.h. H.Stenn +* [Bug 2875] sntp/Makefile.am: Get rid of DIST_SUBDIRS. libevent must + be configured for the distribution targets. Harlan Stenn. +* [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. +* [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org +* [Bug 2888] streamline calendar functions. perlinger@ntp.org +* [Bug 2889] ntp-dev-4.3.67 does not build on Windows. perlinger@ntp.org +* [Bug 2890] Ignore ENOBUFS on routing netlink socket. Konstantin Khlebnikov. +* [Bug 2906] make check needs better support for pthreads. Harlan Stenn. +* [Bug 2907] dist* build targets require our libevent/ to be enabled. HStenn. +* [Bug 2912] no munlockall() under Windows. David Taylor, Harlan Stenn. +* libntp/emalloc.c: Remove explicit include of stdint.h. Harlan Stenn. +* Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. +* tests/ntpd/g_leapsec.cpp typo fix. Harlan Stenn. +* Phase 1 deprecation of google test in sntp/tests/. Harlan Stenn. +* On some versions of HP-UX, inttypes.h does not include stdint.h. H.Stenn. +* top_srcdir can change based on ntp v. sntp. Harlan Stenn. +* sntp/tests/ function parameter list cleanup. Damir Tomić. +* tests/libntp/ function parameter list cleanup. Damir Tomić. +* tests/ntpd/ function parameter list cleanup. Damir Tomić. +* sntp/unity/unity_config.h: handle stdint.h. Harlan Stenn. +* sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris. H.Stenn. +* tests/libntp/timevalops.c and timespecops.c fixed error printing. D.Tomić. +* tests/libntp/ improvements in code and fixed error printing. Damir Tomić. +* tests/libntp: a_md5encrypt.c, authkeys.c, buftvtots.c, calendar.c, caljulian.c, + caltontp.c, clocktime.c, humandate.c, hextolfp.c, decodenetnum.c - fixed + formatting; first declaration, then code (C90); deleted unnecessary comments; + changed from sprintf to snprintf; fixed order of includes. Tomasz Flendrich +* tests/libntp/lfpfunc.c remove unnecessary include, remove old comments, + fix formatting, cleanup. Tomasz Flendrich +* tests/libntp/lfptostr.c remove unnecessary include, add consts, fix formatting. + Tomasz Flendrich +* tests/libntp/statestr.c remove empty functions, remove unnecessary include, + fix formatting. Tomasz Flendrich +* tests/libntp/modetoa.c fixed formatting. Tomasz Flendrich +* tests/libntp/msyslog.c fixed formatting. Tomasz Flendrich +* tests/libntp/numtoa.c deleted unnecessary empty functions, fixed formatting. + Tomasz Flendrich +* tests/libntp/numtohost.c added const, fixed formatting. Tomasz Flendrich +* tests/libntp/refnumtoa.c fixed formatting. Tomasz Flendrich +* tests/libntp/ssl_init.c fixed formatting. Tomasz Flendrich +* tests/libntp/tvtots.c fixed a bug, fixed formatting. Tomasz Flendrich +* tests/libntp/uglydate.c removed an unnecessary include. Tomasz Flendrich +* tests/libntp/vi64ops.c removed an unnecessary comment, fixed formatting. +* tests/libntp/ymd3yd.c removed an empty function and an unnecessary include, +fixed formatting. Tomasz Flendrich +* tests/libntp/timespecops.c fixed formatting, fixed the order of includes, + removed unnecessary comments, cleanup. Tomasz Flendrich +* tests/libntp/timevalops.c fixed the order of includes, deleted unnecessary + comments, cleanup. Tomasz Flendrich +* tests/libntp/sockaddrtest.h making it agree to NTP's conventions of formatting. + Tomasz Flendrich +* tests/libntp/lfptest.h cleanup. Tomasz Flendrich +* tests/libntp/test-libntp.c fix formatting. Tomasz Flendrich +* sntp/tests/crypto.c is now using proper Unity's assertions, fixed formatting. + Tomasz Flendrich +* sntp/tests/kodDatabase.c added consts, deleted empty function, + fixed formatting. Tomasz Flendrich +* sntp/tests/kodFile.c cleanup, fixed formatting. Tomasz Flendrich +* sntp/tests/packetHandling.c is now using proper Unity's assertions, + fixed formatting, deleted unused variable. Tomasz Flendrich +* sntp/tests/keyFile.c is now using proper Unity's assertions, fixed formatting. + Tomasz Flendrich +* sntp/tests/packetProcessing.c changed from sprintf to snprintf, + fixed formatting. Tomasz Flendrich +* sntp/tests/utilities.c is now using proper Unity's assertions, changed + the order of includes, fixed formatting, removed unnecessary comments. + Tomasz Flendrich +* sntp/tests/sntptest.h fixed formatting. Tomasz Flendrich +* sntp/tests/fileHandlingTest.h.in fixed a possible buffer overflow problem, + made one function do its job, deleted unnecessary prints, fixed formatting. + Tomasz Flendrich +* sntp/unity/Makefile.am added a missing header. Tomasz Flendrich +* sntp/unity/unity_config.h: Distribute it. Harlan Stenn. +* sntp/libevent/evconfig-private.h: remove generated filefrom SCM. H.Stenn. +* sntp/unity/Makefile.am: fix some broken paths. Harlan Stenn. +* sntp/unity/unity.c: Clean up a printf(). Harlan Stenn. +* Phase 1 deprecation of google test in tests/libntp/. Harlan Stenn. +* Don't build sntp/libevent/sample/. Harlan Stenn. +* tests/libntp/test_caltontp needs -lpthread. Harlan Stenn. +* br-flock: --enable-local-libevent. Harlan Stenn. +* Wrote tests for ntpd/ntp_prio_q.c. Tomasz Flendrich +* scripts/lib/NTP/Util.pm: stratum output is version-dependent. Harlan Stenn. +* Get rid of the NTP_ prefix on our assertion macros. Harlan Stenn. +* Code cleanup. Harlan Stenn. +* libntp/icom.c: Typo fix. Harlan Stenn. +* util/ntptime.c: initialization nit. Harlan Stenn. +* ntpd/ntp_peer.c:newpeer(): added a DEBUG_REQUIRE(srcadr). Harlan Stenn. +* Add std_unity_tests to various Makefile.am files. Harlan Stenn. +* ntpd/ntp_restrict.c: added a few assertions, created tests for this file. + Tomasz Flendrich +* Changed progname to be const in many files - now it's consistent. Tomasz + Flendrich +* Typo fix for GCC warning suppression. Harlan Stenn. +* Added tests/ntpd/ntp_scanner.c test. Damir Tomić. +* Added declarations to all Unity tests, and did minor fixes to them. + Reduced the number of warnings by half. Damir Tomić. +* Updated generate_test_runner.rb and updated the sntp/unity/auto directory + with the latest Unity updates from Mark. Damir Tomić. +* Retire google test - phase I. Harlan Stenn. +* Unity test cleanup: move declaration of 'initializing'. Harlan Stenn. +* Update the NEWS file. Harlan Stenn. +* Autoconf cleanup. Harlan Stenn. +* Unit test dist cleanup. Harlan Stenn. +* Cleanup various test Makefile.am files. Harlan Stenn. +* Pthread autoconf macro cleanup. Harlan Stenn. +* Fix progname definition in unity runner scripts. Harlan Stenn. +* Clean trailing whitespace in tests/ntpd/Makefile.am. Harlan Stenn. +* Update the patch for bug 2817. Harlan Stenn. +* More updates for bug 2817. Harlan Stenn. +* Fix bugs in tests/ntpd/ntp_prio_q.c. Harlan Stenn. +* gcc on older HPUX may need +allowdups. Harlan Stenn. +* Adding missing MCAST protection. Harlan Stenn. +* Disable certain test programs on certain platforms. Harlan Stenn. +* Implement --enable-problem-tests (on by default). Harlan Stenn. +* build system tweaks. Harlan Stenn. + --- NTP 4.2.8p3 (Harlan Stenn , 2015/06/29) diff --git a/contrib/ntp/aclocal.m4 b/contrib/ntp/aclocal.m4 index bbc54be40406..0c81f43706bb 100644 --- a/contrib/ntp/aclocal.m4 +++ b/contrib/ntp/aclocal.m4 @@ -1355,6 +1355,7 @@ m4_include([sntp/m4/ntp_lineeditlibs.m4]) m4_include([sntp/m4/ntp_locinfo.m4]) m4_include([sntp/m4/ntp_openssl.m4]) m4_include([sntp/m4/ntp_pkg_config.m4]) +m4_include([sntp/m4/ntp_problemtests.m4]) m4_include([sntp/m4/ntp_prog_cc.m4]) m4_include([sntp/m4/ntp_rlimit.m4]) m4_include([sntp/m4/ntp_sntp.m4]) diff --git a/contrib/ntp/adjtimed/Makefile.in b/contrib/ntp/adjtimed/Makefile.in index 716b9401e542..7a546ef2fe3c 100644 --- a/contrib/ntp/adjtimed/Makefile.in +++ b/contrib/ntp/adjtimed/Makefile.in @@ -124,6 +124,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -229,6 +230,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -237,6 +239,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -298,6 +301,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/adjtimed/adjtimed.c b/contrib/ntp/adjtimed/adjtimed.c index f38e66dd0f75..fd28dfb1be07 100644 --- a/contrib/ntp/adjtimed/adjtimed.c +++ b/contrib/ntp/adjtimed/adjtimed.c @@ -58,7 +58,7 @@ void Exit (int); /* emacs cc-mode goes nuts if we split the next line... */ #define tvtod(tv) ((double)tv.tv_sec + ((double)tv.tv_usec / (double)MILLION)) -char *progname = NULL; +char const *progname = NULL; int verbose = 0; int sysdebug = 0; static int mqid; diff --git a/contrib/ntp/clockstuff/Makefile.in b/contrib/ntp/clockstuff/Makefile.in index 0236354805cf..e75f4c047409 100644 --- a/contrib/ntp/clockstuff/Makefile.in +++ b/contrib/ntp/clockstuff/Makefile.in @@ -117,6 +117,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -224,6 +225,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -232,6 +234,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -293,6 +296,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/clockstuff/chutest.c b/contrib/ntp/clockstuff/chutest.c index 488a0d16e0ff..78f6c5fe9818 100644 --- a/contrib/ntp/clockstuff/chutest.c +++ b/contrib/ntp/clockstuff/chutest.c @@ -56,7 +56,7 @@ struct chucode { #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) -char *progname; +char const *progname; int dofilter = 0; /* set to 1 when we should run filter algorithm */ int showtimes = 0; /* set to 1 when we should show char arrival times */ diff --git a/contrib/ntp/clockstuff/propdelay.c b/contrib/ntp/clockstuff/propdelay.c index 52c20320cdc4..a3b9fc0b2850 100644 --- a/contrib/ntp/clockstuff/propdelay.c +++ b/contrib/ntp/clockstuff/propdelay.c @@ -117,7 +117,7 @@ int Cflag = 0; int Gflag = 0; int height; -char *progname; +char const *progname; static void doit (double, double, double, double, double, char *); static double latlong (char *, int); diff --git a/contrib/ntp/configure b/contrib/ntp/configure index 1d686cbdcba8..04813a8d5245 100755 --- a/contrib/ntp/configure +++ b/contrib/ntp/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ntp 4.2.8p3. +# Generated by GNU Autoconf 2.69 for ntp 4.2.8p4. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ntp' PACKAGE_TARNAME='ntp' -PACKAGE_VERSION='4.2.8p3' -PACKAGE_STRING='ntp 4.2.8p3' +PACKAGE_VERSION='4.2.8p4' +PACKAGE_STRING='ntp 4.2.8p4' PACKAGE_BUGREPORT='http://bugs.ntp.org./' PACKAGE_URL='http://www.ntp.org./' @@ -639,6 +639,12 @@ LTLIBOBJS subdirs PERLLIBDIR NTP_KEYSDIR +BUILD_TEST_NTP_SIGND_FALSE +BUILD_TEST_NTP_SIGND_TRUE +BUILD_TEST_NTP_SCANNER_FALSE +BUILD_TEST_NTP_SCANNER_TRUE +BUILD_TEST_NTP_RESTRICT_FALSE +BUILD_TEST_NTP_RESTRICT_TRUE GTEST_AVAILABLE_FALSE GTEST_AVAILABLE_TRUE GTEST_CPPFLAGS @@ -689,6 +695,8 @@ PTHREADS_FALSE PTHREADS_TRUE LIBISC_PTHREADS_NOTHREADS PTHREAD_LIBS +LTHREAD_LIBS +BUILD_THREAD HAVE_INLINE LDADD_LIBUTIL ALLOCA @@ -701,6 +709,7 @@ BUILD_LIBEVENT_FALSE BUILD_LIBEVENT_TRUE LDADD_LIBEVENT CPPFLAGS_LIBEVENT +CFLAGS_LIBEVENT PKG_CONFIG LIBOPTS_DIR LIBOPTS_CFLAGS @@ -1050,6 +1059,7 @@ enable_getifaddrs enable_saveconfig enable_leap_smear with_gtest +enable_problem_tests ' ac_precious_vars='build_alias host_alias @@ -1606,7 +1616,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ntp 4.2.8p3 to adapt to many kinds of systems. +\`configure' configures ntp 4.2.8p4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1676,7 +1686,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ntp 4.2.8p3:";; + short | recursive ) echo "Configuration of ntp 4.2.8p4:";; esac cat <<\_ACEOF @@ -1724,7 +1734,7 @@ Optional Features and Packages: --enable-libseccomp EXPERIMENTAL: enable support for libseccomp sandboxing (default is no) --with-stack-limit ? =50 (200 for openbsd) 4k pages - --with-memlock ? =32 (megabytes) + --with-memlock ? =32 (-1 on linux) megabytes --enable-debug-timing - include processing time debugging code (costs performance) --enable-dst-minutes =60 minutes per DST adjustment @@ -1821,6 +1831,7 @@ Optional Features and Packages: --enable-saveconfig + saveconfig mechanism --enable-leap-smear - experimental leap smear code --with-gtest Use the gtest framework (Default: if it's available) + --enable-problem-tests + enable tests with undiagnosed problems Some influential environment variables: CC C compiler command @@ -1908,7 +1919,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ntp configure 4.2.8p3 +ntp configure 4.2.8p4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2738,7 +2749,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ntp $as_me 4.2.8p3, which was +It was created by ntp $as_me 4.2.8p4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3117,6 +3128,12 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + @@ -3733,7 +3750,7 @@ fi # Define the identity of the package. PACKAGE='ntp' - VERSION='4.2.8p3' + VERSION='4.2.8p4' cat >>confdefs.h <<_ACEOF @@ -6768,7 +6785,7 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking additional compiler flags" >&5 $as_echo_n "checking additional compiler flags... " >&6; } - # allow ntp_os_flags to be preset to skip this stuff + # allow ntp_os_cflags to be preset to skip this stuff case "${ntp_os_cflags+set}" in set) ;; @@ -6856,7 +6873,7 @@ $as_echo_n "checking additional compiler flags... " >&6; } ;; esac esac - case "$ntp_os_flags" in + case "$ntp_os_cflags" in '') ntp_os_cflags_msg="none needed" ;; @@ -6867,6 +6884,38 @@ $as_echo_n "checking additional compiler flags... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_os_cflags_msg" >&5 $as_echo "$ntp_os_cflags_msg" >&6; } { ntp_os_cflags_msg=; unset ntp_os_cflags_msg;} + ### + { $as_echo "$as_me:${as_lineno-$LINENO}: checking additional linker flags" >&5 +$as_echo_n "checking additional linker flags... " >&6; } + # HMS: The following might still need tweaking + # allow ntp_os_ldflags to be preset to skip this stuff + case "${ntp_os_ldflags+set}" in + set) + ;; + *) + ntp_os_ldflags= + case "$host_os" in + hpux*) + case "$GCC" in + yes) + ntp_os_ldflags="-Wl,+allowdups" + ;; + esac + ;; + esac + ;; + esac + case "$ntp_os_ldflags" in + '') + ntp_os_ldflags_msg="none needed" + ;; + *) + ntp_os_ldflags_msg="$ntp_os_ldflags" + esac + LDFLAGS_NTP="$LDFLAGS_NTP $ntp_os_ldflags" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_os_ldflags_msg" >&5 +$as_echo "$ntp_os_ldflags_msg" >&6; } + { ntp_os_ldflags_msg=; unset ntp_os_ldflags_msg;} @@ -19945,6 +19994,7 @@ ntp_libevent_tearoff=sntp/libevent + case "$ntp_use_local_libevent" in yes) ;; @@ -19958,6 +20008,7 @@ $as_echo_n "checking if libevent $ntp_libevent_min_version or later is installed ntp_use_local_libevent=no { $as_echo "$as_me:${as_lineno-$LINENO}: Using the installed libevent" >&5 $as_echo "$as_me: Using the installed libevent" >&6;} + CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads` CPPFLAGS_LIBEVENT=`$PKG_CONFIG --cflags-only-I libevent` # HMS: I hope the following is accurate. # We don't need -levent, we only need -levent_core. @@ -19987,6 +20038,9 @@ $as_echo "$as_me: Using the installed libevent" >&6;} $as_echo "yes" >&6; } else ntp_use_local_libevent=yes + # HMS: do we only need to do this if LIBISC_PTHREADS_NOTHREADS + # is "pthreads"? + CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads` { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -20012,6 +20066,7 @@ $as_echo "$as_me: Using libevent tearoff" >&6;} esac esac + if test "x$ntp_use_local_libevent" = "xyes"; then BUILD_LIBEVENT_TRUE= BUILD_LIBEVENT_FALSE='#' @@ -22941,7 +22996,8 @@ fi have_pthreads=no case "$enable_thread_support" in - yes) + no) ;; + *) ol_found_pthreads=no @@ -26358,6 +26414,9 @@ $as_echo "$ol_cv_pthread_lib_lpthreads" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: ol_link_threads: <$ol_link_threads> ol_link_pthreads <$ol_link_pthreads>" >&5 +$as_echo "$as_me: ol_link_threads: <$ol_link_threads> ol_link_pthreads <$ol_link_pthreads>" >&6;} + if test $ol_link_threads != no ; then LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads" @@ -27398,6 +27457,10 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + case "$ol_found_pthreads" in yes) saved_LIBS="$LIBS" @@ -27423,56 +27486,6 @@ done yes) PTHREAD_LIBS="$LTHREAD_LIBS" have_pthreads=yes - # Bug 2332: With GCC we need to force a reference to libgcc_s - # (if libgcc_s exists) or the combination of - # threads + setuid + mlockall does not work on linux because - # thread cancellation fails to load libgcc_s with dlopen(). - # We have to pass this all as linker options to avoid argument - # reordering by libtool. - case "$GCC$with_gnu_ld" in - yesyes) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for exit in -lgcc_s" >&5 -$as_echo_n "checking for exit in -lgcc_s... " >&6; } -if ${ac_cv_lib_gcc_s_exit+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgcc_s $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char exit (); -int -main () -{ -return exit (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_gcc_s_exit=yes -else - ac_cv_lib_gcc_s_exit=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcc_s_exit" >&5 -$as_echo "$ac_cv_lib_gcc_s_exit" >&6; } -if test "x$ac_cv_lib_gcc_s_exit" = xyes; then : - PTHREAD_LIBS="$LTHREAD_LIBS -Wl,--no-as-needed,-lgcc_s,--as-needed" -fi - - ;; - esac esac esac esac @@ -31236,10 +31249,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_rlimit_memlock" >&5 $as_echo "$ntp_cv_rlimit_memlock" >&6; } +case "$host" in + *-*-*linux*) + ntp_dflt_rlimit_memlock="-1" ;; + *) ntp_dflt_rlimit_memlock="32" ;; +esac case "$ntp_cv_rlimit_memlock" in yes) - HAVE_RLIMIT_MEMLOCK=" memlock 32" + HAVE_RLIMIT_MEMLOCK=" memlock $ntp_dflt_rlimit_memlock" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for RLIMIT_STACK" >&5 @@ -31288,8 +31306,6 @@ case "$ntp_cv_rlimit_stack" in HAVE_RLIMIT_STACK=" stacksize 50" esac - - # HMS: Only if we are doing the MLOCKALL stuff... { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the default number of 4k stack pages" >&5 $as_echo_n "checking for the default number of 4k stack pages... " >&6; } @@ -31339,7 +31355,7 @@ fi case "$ans" in yes | no) - ans=32 + ans=$ntp_dflt_rlimit_memlock ;; [1-9][0-9]*) ;; *) as_fn_error $? "\"--with-memlock requires an integer argument.\"" "$LINENO" 5 @@ -31354,6 +31370,7 @@ _ACEOF + # some OSes prefer _exit() in forked children to exit() for ac_func in _exit do : @@ -36995,6 +37012,81 @@ fi + +case "$build" in + $host) cross=0 ;; + *) cross=1 ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to enable tests with undiagnosed problems" >&5 +$as_echo_n "checking if we want to enable tests with undiagnosed problems... " >&6; } +# Check whether --enable-problem-tests was given. +if test "${enable_problem_tests+set}" = set; then : + enableval=$enable_problem_tests; ntp_ept=$enableval +else + ntp_ept=yes + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ept" >&5 +$as_echo "$ntp_ept" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can run test-ntp_restrict" >&5 +$as_echo_n "checking if we can run test-ntp_restrict... " >&6; } +ntp_test_ntp_restrict="no" +case "$ntp_ept:$cross:$host" in + no:0:*-*-solaris*) ;; + no:0:*-*-hpux-11.23*) ;; + *) ntp_test_ntp_restrict="yes" ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_restrict" >&5 +$as_echo "$ntp_test_ntp_restrict" >&6; } + if test x$ntp_test_ntp_restrict = xyes; then + BUILD_TEST_NTP_RESTRICT_TRUE= + BUILD_TEST_NTP_RESTRICT_FALSE='#' +else + BUILD_TEST_NTP_RESTRICT_TRUE='#' + BUILD_TEST_NTP_RESTRICT_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can run test-ntp_scanner" >&5 +$as_echo_n "checking if we can run test-ntp_scanner... " >&6; } +ntp_test_ntp_scanner="no" +case "$ntp_ept:$cross:$host" in + no:0:*-*-solaris*) ;; + *) ntp_test_ntp_scanner="yes" ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_scanner" >&5 +$as_echo "$ntp_test_ntp_scanner" >&6; } + if test x$ntp_test_ntp_scanner = xyes; then + BUILD_TEST_NTP_SCANNER_TRUE= + BUILD_TEST_NTP_SCANNER_FALSE='#' +else + BUILD_TEST_NTP_SCANNER_TRUE='#' + BUILD_TEST_NTP_SCANNER_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can run test-ntp_signd" >&5 +$as_echo_n "checking if we can run test-ntp_signd... " >&6; } +ntp_test_ntp_signd="no" +case "$ntp_ept:$cross:$host" in + no:0:*-*-solaris*) ;; + *) ntp_test_ntp_signd="yes" ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_signd" >&5 +$as_echo "$ntp_test_ntp_signd" >&6; } + if test x$ntp_test_ntp_signd = xyes; then + BUILD_TEST_NTP_SIGND_TRUE= + BUILD_TEST_NTP_SIGND_FALSE='#' +else + BUILD_TEST_NTP_SIGND_TRUE='#' + BUILD_TEST_NTP_SIGND_FALSE= +fi + + + ### @@ -37091,6 +37183,8 @@ ac_config_files="$ac_config_files tests/libntp/Makefile" ac_config_files="$ac_config_files tests/ntpd/Makefile" +ac_config_files="$ac_config_files tests/ntpq/Makefile" + ac_config_files="$ac_config_files tests/sandbox/Makefile" ac_config_files="$ac_config_files tests/sec-2853/Makefile" @@ -37333,6 +37427,18 @@ if test -z "${GTEST_AVAILABLE_TRUE}" && test -z "${GTEST_AVAILABLE_FALSE}"; then as_fn_error $? "conditional \"GTEST_AVAILABLE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${BUILD_TEST_NTP_RESTRICT_TRUE}" && test -z "${BUILD_TEST_NTP_RESTRICT_FALSE}"; then + as_fn_error $? "conditional \"BUILD_TEST_NTP_RESTRICT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${BUILD_TEST_NTP_SCANNER_TRUE}" && test -z "${BUILD_TEST_NTP_SCANNER_FALSE}"; then + as_fn_error $? "conditional \"BUILD_TEST_NTP_SCANNER\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${BUILD_TEST_NTP_SIGND_TRUE}" && test -z "${BUILD_TEST_NTP_SIGND_FALSE}"; then + as_fn_error $? "conditional \"BUILD_TEST_NTP_SIGND\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -37730,7 +37836,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ntp $as_me 4.2.8p3, which was +This file was extended by ntp $as_me 4.2.8p4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -37797,7 +37903,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ntp config.status 4.2.8p3 +ntp config.status 4.2.8p4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -38344,6 +38450,7 @@ do "tests/bug-2803/Makefile") CONFIG_FILES="$CONFIG_FILES tests/bug-2803/Makefile" ;; "tests/libntp/Makefile") CONFIG_FILES="$CONFIG_FILES tests/libntp/Makefile" ;; "tests/ntpd/Makefile") CONFIG_FILES="$CONFIG_FILES tests/ntpd/Makefile" ;; + "tests/ntpq/Makefile") CONFIG_FILES="$CONFIG_FILES tests/ntpq/Makefile" ;; "tests/sandbox/Makefile") CONFIG_FILES="$CONFIG_FILES tests/sandbox/Makefile" ;; "tests/sec-2853/Makefile") CONFIG_FILES="$CONFIG_FILES tests/sec-2853/Makefile" ;; "util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;; diff --git a/contrib/ntp/configure.ac b/contrib/ntp/configure.ac index de6043015b17..42e18a49fe37 100644 --- a/contrib/ntp/configure.ac +++ b/contrib/ntp/configure.ac @@ -11,6 +11,7 @@ AC_INIT( ) AC_CONFIG_MACRO_DIR([sntp/m4]) AC_CONFIG_AUX_DIR([sntp/libevent/build-aux]) +AC_LANG([C]) AC_PRESERVE_HELP_ORDER @@ -928,60 +929,6 @@ esac NTP_RLIMIT_ITEMS -# HMS: Only if we are doing the MLOCKALL stuff... -AC_MSG_CHECKING([for the default number of 4k stack pages]) -AC_ARG_WITH( - [stack-limit], - [AS_HELP_STRING( - [--with-stack-limit], - [? =50 (200 for openbsd) 4k pages] - )], - [ans=$withval], - [ans=yes] -) -case "$ans" in - yes | no) - case "$host" in - *-*-openbsd*) - ans=200 - ;; - *) ans=50 - ;; - esac - ;; - [[1-9]][[0-9]]*) - ;; - *) AC_MSG_ERROR(["--with-stack-limit requires an integer argument."]) - ;; -esac -AC_MSG_RESULT([$ans]) -AC_DEFINE_UNQUOTED([DFLT_RLIMIT_STACK], [$ans], - [Default number of 4k pages for RLIMIT_STACK]) - -# HMS: only if we have RLIMIT_MEMLOCK -AC_MSG_CHECKING([for the default number of megabytes to MEMLOCK]) -AC_ARG_WITH( - [memlock], - [AS_HELP_STRING( - [--with-memlock], - [? =32 (megabytes)] - )], - [ans=$withval], - [ans=yes] -) -case "$ans" in - yes | no) - ans=32 - ;; - [[1-9]][[0-9]]*) ;; - *) AC_MSG_ERROR(["--with-memlock requires an integer argument."]) - ;; -esac -AC_MSG_RESULT([$ans]) -AC_DEFINE_UNQUOTED([DFLT_RLIMIT_MEMLOCK], [$ans], - [Default number of megabytes for RLIMIT_MEMLOCK]) - - # some OSes prefer _exit() in forked children to exit() AC_CHECK_FUNCS([_exit]) ntp_worker_child_exit=exit @@ -4382,6 +4329,8 @@ dnl require a C++ compiler only if we will use gtest, but AC_PROG_CXX dnl can't be conditionalized. NTP_GOOGLETEST +NTP_PROBLEM_TESTS + ### AC_DEFINE_DIR([NTP_KEYSDIR], [sysconfdir], @@ -4425,6 +4374,7 @@ AC_CONFIG_FILES([tests/Makefile]) AC_CONFIG_FILES([tests/bug-2803/Makefile]) AC_CONFIG_FILES([tests/libntp/Makefile]) AC_CONFIG_FILES([tests/ntpd/Makefile]) +AC_CONFIG_FILES([tests/ntpq/Makefile]) AC_CONFIG_FILES([tests/sandbox/Makefile]) AC_CONFIG_FILES([tests/sec-2853/Makefile]) AC_CONFIG_FILES([util/Makefile]) diff --git a/contrib/ntp/html/decode.html b/contrib/ntp/html/decode.html index 51603ad67aae..a15046f3f22b 100644 --- a/contrib/ntp/html/decode.html +++ b/contrib/ntp/html/decode.html @@ -11,7 +11,7 @@ giffrom Alice's Adventures in Wonderland, Lewis Carroll

Caterpillar knows all the error codes, which is more than most of us do.

Last update: - 16-Jul-2014 04:48 + 26-Jul-2015 06:26 UTC


@@ -296,7 +296,7 @@ 3 - sel_outlyer + sel_outlier - discarded by the cluster algorithm diff --git a/contrib/ntp/html/miscopt.html b/contrib/ntp/html/miscopt.html index ac32419df08a..c6190222bf96 100644 --- a/contrib/ntp/html/miscopt.html +++ b/contrib/ntp/html/miscopt.html @@ -11,7 +11,7 @@ giffrom Pogo, Walt Kelly

We have three, now looking for more.

Last update: - 29-Jun-2015 05:56 + 23-Sep-2015 10:20 UTC


Related Links

@@ -105,7 +105,7 @@
memlock Nmegabytes
-
Specify the number of megabytes of memory that can be allocated. Probably only available under Linux, this option is useful when dropping root (the -i option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
+
Specify the number of megabytes of memory that should be allocated and locked. Probably only available under Linux, this option may be useful when dropping root (the -i option). The default is 32 megabytes on non-Linux machines, and -1 under Linux. -1 means "do not lock the process into memory". 0 means "lock whatever memory the process wants into memory".
stacksize N4kPages
Specifies the maximum size of the process stack on systems with the mlockall() function. Defaults to 50 4k pages (200 4k pages in OpenBSD).
filenum Nfiledescriptors
diff --git a/contrib/ntp/html/stats.html b/contrib/ntp/html/stats.html index 943851773c17..c5bc34c41612 100644 --- a/contrib/ntp/html/stats.html +++ b/contrib/ntp/html/stats.html @@ -7,9 +7,9 @@ -

Performance Metrics

+

Performance Metrics

Last update: - 10-Mar-2014 05:23 + 26-Jul-2015 06:29 UTC

Related Links

@@ -25,45 +25,45 @@

This page describes several statistics provided in the NTP specification and reference implementation and how they determine the accuracy and error measured during routine and exceptional operation. These statistics provide the following information.

    -
  • Nominal estimate of the server clock time relative to the client clock time. This is called clock offset symbolized by the Greek letter θ.
  • -
  • Roundtrip system and network delay measured by the on-wire protocol. This is call roundtrip delay symbolized by the Greek letter δ.
  • -
  • Potential clock offset error due to the maximum uncorrected system clock frequency error. This is called dispersion symbolized by the Greek letter ε.
  • -
  • Expected error, consisting of the root mean square (RMS) nominal clock offset sample differencess in a sliding window of several samples. This is called jitter symbolized by the Greek letter φ.
  • +
  • Nominal estimate of the server clock time relative to the client clock time. This is called clock offset symbolized by the Greek letter θ.
  • +
  • Roundtrip system and network delay measured by the on-wire protocol. This is call roundtrip delay symbolized by the Greek letter δ.
  • +
  • Potential clock offset error due to the maximum uncorrected system clock frequency error. This is called dispersion symbolized by the Greek letter ε.
  • +
  • Expected error, consisting of the root mean square (RMS) nominal clock offset sample differencess in a sliding window of several samples. This is called jitter symbolized by the Greek letter φ.

Figure 1 shows how the various measured statistics are collected and compiled to calibrate NTP performance.

gif

Figure 1. Statistics Budget

-

The data represented in boxes labeled Server are contained in fields in packet received from the server. The data represented in boxes labeled Peer are computed by the on-wire protocol, as described below. The algorithms of the box labeled Selection and Combining Algorithms process the peer data to select a system peer. The System box represents summary data inherited from the system peer. These data are available to application programs and dependent downstream clients.

+

The data represented in boxes labeled Server are contained in fields in packet received from the server. The data represented in boxes labeled Peer are computed by the on-wire protocol, as described below. The algorithms of the box labeled Selection and Combining Algorithms process the peer data to select a system peer. The System box represents summary data inherited from the system peer. These data are available to application programs and dependent downstream clients.

2. Statistics Summary

-

Each NTP synchronization source is characterized by the offset θ and delay δ samples measured by the on-wire protocol, as described on the How NTP Works page. In addition, the dispersion ε sample is initialized with the sum of the source precision ρR and the client precision ρ (not shown) as each source packet is received. The dispersion increases at a rate of 15 μs/s after that. For this purpose, the precision is equal to the latency to read the system clock. The offset, delay and dispersion are called the sample statistics.

+

Each NTP synchronization source is characterized by the offset θ and delay δ samples measured by the on-wire protocol, as described on the How NTP Works page. In addition, the dispersion ε sample is initialized with the sum of the source precision ρR and the client precision ρ (not shown) as each source packet is received. The dispersion increases at a rate of 15 μs/s after that. For this purpose, the precision is equal to the latency to read the system clock. The offset, delay and dispersion are called the sample statistics.

-

Note. In very fast networks where the client clock frequency is not within 1 PPM or so of the the server clock frequency, the roundtrip delay may have small negative values. This is usually a temporary condition when the client is first started. When using the roundtrip delay in calculations, negative values are assumed zero.

+

Note. In very fast networks where the client clock frequency is not within 1 PPM or so of the the server clock frequency, the roundtrip delay may have small negative values. This is usually a temporary condition when the client is first started. When using the roundtrip delay in calculations, negative values are assumed zero.

-

In a window of eight (offset, delay, dispersion) samples, the algorithm described on the Clock Filter Algorithm page selects the sample with minimum delay, which generally represents the most accurate offset statistic. The selected offset sample determines the peer offset and peer delay statistics. The peer dispersion is a weighted average of the dispersion samples in the window. These quantities are recalculated as each update is received from the source. Between updates, both the sample dispersion and peer dispersion continue to grow at the same rate, 15 μs/s. Finally, the peer jitter φ is determined as the RMS differences between the offset samples in the window relative to the selected offset sample. The peer statistics are recorded by the peerstats option of the filegen command. Peer variables are displayed by the rv command of the ntpq program.

-

The clock filter algorithm continues to process updates in this way until the source is no longer reachable. Reachability is determined by an eight-bit shift register, which is shifted left by one bit as each poll packet is sent, with 0 replacing the vacated rightmost bit. Each time a valid update is received, the rightmost bit is set to 1. The source is considered reachable if any bit is set to 1 in the register; otherwise, it is considered unreachable. When a source becomes unreachable, a dummy sample with "infinite" dispersion is inserted in the filter window at each poll, thus displacing old samples. This causes the peer dispersion to increase eventually to infinity.

-

The composition of the source population and the system peer selection is redetermined as each update from each source is received. The system peer and system variables are determined as described on the Mitigation Rules and the prefer Keyword page. The system variables Θ, Δ, Ε and Φ are updated from the system peer variables of the same name and the system stratum set one greater than the system peer stratum. The system statistics are recorded by the loopstats option of the filegen command. System variables are displayed by the rv command of the ntpq program.

-

Although it might seem counterintuitive, a cardinal rule in the selection process is, once a sample has been selected by the clock filter algorithm, older samples are no longer selectable. This applies also to the clock select algorithm. Once the peer variables for a source have been selected, older variables of the same or other sources are no longer selectable. The reason for these rules is to limit the time delay in the clock discipline algorithm. This is necessary to preserve the optimum impulse response and thus the risetime and overshoot.

+

In a window of eight (offset, delay, dispersion) samples, the algorithm described on the Clock Filter Algorithm page selects the sample with minimum delay, which generally represents the most accurate offset statistic. The selected offset sample determines the peer offset and peer delay statistics. The peer dispersion is a weighted average of the dispersion samples in the window. These quantities are recalculated as each update is received from the source. Between updates, both the sample dispersion and peer dispersion continue to grow at the same rate, 15 μs/s. Finally, the peer jitter φ is determined as the RMS differences between the offset samples in the window relative to the selected offset sample. The peer statistics are recorded by the peerstats option of the filegen command. Peer variables are displayed by the rv command of the ntpq program.

+

The clock filter algorithm continues to process updates in this way until the source is no longer reachable. Reachability is determined by an eight-bit shift register, which is shifted left by one bit as each poll packet is sent, with 0 replacing the vacated rightmost bit. Each time a valid update is received, the rightmost bit is set to 1. The source is considered reachable if any bit is set to 1 in the register; otherwise, it is considered unreachable. When a source becomes unreachable, a dummy sample with "infinite" dispersion is inserted in the filter window at each poll, thus displacing old samples. This causes the peer dispersion to increase eventually to infinity.

+

The composition of the source population and the system peer selection is redetermined as each update from each source is received. The system peer and system variables are determined as described on the Mitigation Rules and the prefer Keyword page. The system variables Θ, Δ, Ε and Φ are updated from the system peer variables of the same name and the system stratum set one greater than the system peer stratum. The system statistics are recorded by the loopstats option of the filegen command. System variables are displayed by the rv command of the ntpq program.

+

Although it might seem counterintuitive, a cardinal rule in the selection process is, once a sample has been selected by the clock filter algorithm, older samples are no longer selectable. This applies also to the clock select algorithm. Once the peer variables for a source have been selected, older variables of the same or other sources are no longer selectable. The reason for these rules is to limit the time delay in the clock discipline algorithm. This is necessary to preserve the optimum impulse response and thus the risetime and overshoot.

This means that not every sample can be used to update the peer variables, and up to seven samples can be ignored between selected samples. This fact has been carefully considered in the discipline algorithm design with due consideration for feedback loop delay and minimum sampling rate. In engineering terms, even if only one sample in eight survives, the resulting sample rate is twice the Nyquist rate at any time constant and poll interval.

3. Quality of Service

-

This section discusses how an NTP client determines the system performance using a peer population including reference clocks and remote servers. This is determined for each peer from two statistics, peer jitter and root distance. Peer jitter is determined from various jitter components as described above. It represents the expected error in determining the clock offset estimate. Root distance represents the maximum error of the estimate due to all causes.

-

The root distance statistic is computed as one-half the root delay of the primary source of time; i.e., the reference clock, plus the root dispersion of that source. The root variables are included in the NTP packet header received from each source. At each update the root delay is recomputed as the sum of the root delay in the packet plus the peer delay, while the root dispersion is recomputed as the sum of the root dispersion in the packet plus the peer dispersion.

+

This section discusses how an NTP client determines the system performance using a peer population including reference clocks and remote servers. This is determined for each peer from two statistics, peer jitter and root distance. Peer jitter is determined from various jitter components as described above. It represents the expected error in determining the clock offset estimate. Root distance represents the maximum error of the estimate due to all causes.

+

The root distance statistic is computed as one-half the root delay of the primary source of time; i.e., the reference clock, plus the root dispersion of that source. The root variables are included in the NTP packet header received from each source. At each update the root delay is recomputed as the sum of the root delay in the packet plus the peer delay, while the root dispersion is recomputed as the sum of the root dispersion in the packet plus the peer dispersion.

-

Note. In order to avoid timing loops, the root distance is adjusted to the maximum of the above computation and a minimum threshold. The minimum threshold defaults to 1 ms, but can be changed according to client preference using the mindist option of the tos command.

+

Note. In order to avoid timing loops, the root distance is adjusted to the maximum of the above computation and a minimum threshold. The minimum threshold defaults to 1 ms, but can be changed according to client preference using the mindist option of the tos command.

-

A source is considered selectable only if its root distance is less than the select threshold, by default 1.5 s, but can be changed according to client preference using the maxdist option of the tos command. When an upstream server loses all sources, its root distance apparent to dependent clients continues to increase. The clients are not aware of this condition and continue to accept synchronization as long as the root distance is less than the select threshold.

-

The root distance statistic is used by the select, cluster and mitigation algorithms. In this respect, it is sometimes called the synchronization distance often shortened simply to distance. The root distance is also used in the following ways.

+

A source is considered selectable only if its root distance is less than the select threshold, by default 1.5 s, but can be changed according to client preference using the maxdist option of the tos command. When an upstream server loses all sources, its root distance apparent to dependent clients continues to increase. The clients are not aware of this condition and continue to accept synchronization as long as the root distance is less than the select threshold.

+

The root distance statistic is used by the select, cluster and mitigation algorithms. In this respect, it is sometimes called the synchronization distance often shortened simply to distance. The root distance is also used in the following ways.

  • Root distance defines the maximum error of the clock offset estimate due to all causes as long as the source remains reachable..
  • -
  • Root distance defines the upper and lower limits of the correctness interval. This interval represents the maximum clock offset for each of possibly several sources. The clock select algorithm computes the intersection of the correctness intervals to determine the truechimers from the selectable source population.
  • -
  • Root distance is used by the clock cluster algorithm as a weight factor when pruning outlyers from the truechimer population.
  • +
  • Root distance defines the upper and lower limits of the correctness interval. This interval represents the maximum clock offset for each of possibly several sources. The clock select algorithm computes the intersection of the correctness intervals to determine the truechimers from the selectable source population.
  • +
  • Root distance is used by the clock cluster algorithm as a weight factor when pruning outliers from the truechimer population.
  • The (normalized) reciprocal of the root distance is used as a weight factor by the combine algorithm when computing the system clock offset and system jitter.
  • -
  • Root distance is used by the mitigation algorithm to select the system peer from among the cluster algorithm survivors.
  • +
  • Root distance is used by the mitigation algorithm to select the system peer from among the cluster algorithm survivors.
-

The root distance thus functions as a metric in the selection and weighting of the various available sources. The strategy is to select the system peer as the source with the minimum root distance and thus the minimum maximum error. The reference implementation uses the Bellman-Ford algorithm described in the literature, where the goal is to minimize the root distance. The algorithm selects the system peer, from which the system root delay and system root dispersion are inherited.

-

The algorithms described on the Mitigation Rules and the prefer Keyword page deliver several important statistics. The system offset and system jitter are weighted averages computed by the clock combine algorithm. System offset is best interpreted as the maximum-likelihood estimate of the system clock offset, while system jitter, also called estimated error, is best interpreted as the expected error of this estimate. System delay is the root delay inherited from the system peer, while system dispersion is the root dispersion plus contributions due to jitter and the absolute value of the system offset.

-

The maximum system error, or system distance, is computed as one-half the system delay plus the system dispersion. In order to simplify discussion, certain minor contributions to the maximum error statistic are ignored. If the precision time kernel support is available, both the estimated error and maximum error are reported to user programs via the ntp_adjtime() kernel system call. See the Kernel Model for Precision Timekeeping page for further information.

+

The root distance thus functions as a metric in the selection and weighting of the various available sources. The strategy is to select the system peer as the source with the minimum root distance and thus the minimum maximum error. The reference implementation uses the Bellman-Ford algorithm described in the literature, where the goal is to minimize the root distance. The algorithm selects the system peer, from which the system root delay and system root dispersion are inherited.

+

The algorithms described on the Mitigation Rules and the prefer Keyword page deliver several important statistics. The system offset and system jitter are weighted averages computed by the clock combine algorithm. System offset is best interpreted as the maximum-likelihood estimate of the system clock offset, while system jitter, also called estimated error, is best interpreted as the expected error of this estimate. System delay is the root delay inherited from the system peer, while system dispersion is the root dispersion plus contributions due to jitter and the absolute value of the system offset.

+

The maximum system error, or system distance, is computed as one-half the system delay plus the system dispersion. In order to simplify discussion, certain minor contributions to the maximum error statistic are ignored. If the precision time kernel support is available, both the estimated error and maximum error are reported to user programs via the ntp_adjtime() kernel system call. See the Kernel Model for Precision Timekeeping page for further information.


diff --git a/contrib/ntp/include/Makefile.am b/contrib/ntp/include/Makefile.am index 8b063c3c66f5..f032c97e792d 100644 --- a/contrib/ntp/include/Makefile.am +++ b/contrib/ntp/include/Makefile.am @@ -62,6 +62,7 @@ noinst_HEADERS = \ ntpsim.h \ parse.h \ parse_conf.h \ + rc_cmdlength.h \ recvbuff.h \ refclock_atom.h \ refidsmear.h \ diff --git a/contrib/ntp/include/Makefile.in b/contrib/ntp/include/Makefile.in index 408118b99bde..8f0968bf77b5 100644 --- a/contrib/ntp/include/Makefile.in +++ b/contrib/ntp/include/Makefile.in @@ -116,6 +116,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -227,6 +228,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -235,6 +237,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -296,6 +299,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ @@ -543,6 +547,7 @@ noinst_HEADERS = \ ntpsim.h \ parse.h \ parse_conf.h \ + rc_cmdlength.h \ recvbuff.h \ refclock_atom.h \ refidsmear.h \ diff --git a/contrib/ntp/include/isc/Makefile.in b/contrib/ntp/include/isc/Makefile.in index 7cbcae303707..5bd25d615fd0 100644 --- a/contrib/ntp/include/isc/Makefile.in +++ b/contrib/ntp/include/isc/Makefile.in @@ -116,6 +116,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -185,6 +186,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -193,6 +195,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -254,6 +257,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/include/ntp_assert.h b/contrib/ntp/include/ntp_assert.h index 2f3bbc8a0b9b..42d78acab0db 100644 --- a/contrib/ntp/include/ntp_assert.h +++ b/contrib/ntp/include/ntp_assert.h @@ -88,10 +88,6 @@ extern void calysto_assert(unsigned char cnd); /* check whether this holds */ * We initially used NTP_REQUIRE() instead of REQUIRE() etc, but that * is unneccesarily verbose, as libisc use of REQUIRE() etc shows. */ -#define NTP_REQUIRE(x) REQUIRE(x) -#define NTP_INSIST(x) INSIST(x) -#define NTP_INVARIANT(x) INVARIANT(x) -#define NTP_ENSURE(x) ENSURE(x) # ifdef DEBUG #define DEBUG_REQUIRE(x) REQUIRE(x) diff --git a/contrib/ntp/include/ntp_calendar.h b/contrib/ntp/include/ntp_calendar.h index 3afb627d2594..6f36c0777aba 100644 --- a/contrib/ntp/include/ntp_calendar.h +++ b/contrib/ntp/include/ntp_calendar.h @@ -157,6 +157,12 @@ ntpcal_daysplit(const vint64 *); extern vint64 ntpcal_dayjoin(int32_t /* days */, int32_t /* seconds */); +/* Get the number of leap years since epoch for the number of elapsed + * full years + */ +extern int32_t +ntpcal_leapyears_in_years(int32_t /* years */); + /* * Convert elapsed years in Era into elapsed days in Era. */ @@ -220,6 +226,9 @@ ntpcal_date_to_rd(const struct calendar * /* jt */); * * if 'isleapyear' is not NULL, it will receive an integer that is 0 * for regular years and a non-zero value for leap years. + * + * The input is limited to [-2^30, 2^30-1]. If the days exceed this + * range, errno is set to EDOM and the result is saturated. */ extern ntpcal_split ntpcal_split_eradays(int32_t /* days */, int/*BOOL*/ * /* isleapyear */); @@ -330,6 +339,10 @@ ntpcal_date_to_time(const struct calendar * /* jd */); extern int32_t isocal_weeks_in_years(int32_t /* years */); +/* + * The input is limited to [-2^30, 2^30-1]. If the weeks exceed this + * range, errno is set to EDOM and the result is saturated. + */ extern ntpcal_split isocal_split_eraweeks(int32_t /* weeks */); diff --git a/contrib/ntp/include/ntp_config.h b/contrib/ntp/include/ntp_config.h index a74cd552b85d..bd8f595d94f3 100644 --- a/contrib/ntp/include/ntp_config.h +++ b/contrib/ntp/include/ntp_config.h @@ -46,8 +46,8 @@ extern int cmdline_server_count; extern char ** cmdline_servers; -/* set to zero if admin doesn't want memory locked */ -extern int do_memlock; +/* set to zero if we're not locking memory */ +extern int cur_memlock; typedef struct int_range_tag { int first; diff --git a/contrib/ntp/include/ntp_control.h b/contrib/ntp/include/ntp_control.h index be5b16d80ead..85f41056c7b1 100644 --- a/contrib/ntp/include/ntp_control.h +++ b/contrib/ntp/include/ntp_control.h @@ -104,7 +104,7 @@ struct ntp_control { #define CTL_PST_SEL_REJECT 0 /* reject */ #define CTL_PST_SEL_SANE 1 /* x falsetick */ #define CTL_PST_SEL_CORRECT 2 /* . excess */ -#define CTL_PST_SEL_SELCAND 3 /* - outlyer */ +#define CTL_PST_SEL_SELCAND 3 /* - outlier */ #define CTL_PST_SEL_SYNCCAND 4 /* + candidate */ #define CTL_PST_SEL_EXCESS 5 /* # backup */ #define CTL_PST_SEL_SYSPEER 6 /* * sys.peer */ diff --git a/contrib/ntp/include/ntp_lists.h b/contrib/ntp/include/ntp_lists.h index 2b6e616965a7..d741974943ef 100644 --- a/contrib/ntp/include/ntp_lists.h +++ b/contrib/ntp/include/ntp_lists.h @@ -215,9 +215,9 @@ do { \ \ for (pentry = (listhead); \ pentry != NULL; \ - pentry = pentry->nextlink){ \ - NTP_INSIST(pentry != pentry->nextlink); \ - NTP_INSIST((listhead) != pentry->nextlink); \ + pentry = pentry->nextlink) { \ + INSIST(pentry != pentry->nextlink); \ + INSIST((listhead) != pentry->nextlink); \ } \ } while (FALSE) diff --git a/contrib/ntp/include/ntp_stdlib.h b/contrib/ntp/include/ntp_stdlib.h index bad2697d06fd..a2e62dabefd9 100644 --- a/contrib/ntp/include/ntp_stdlib.h +++ b/contrib/ntp/include/ntp_stdlib.h @@ -31,6 +31,7 @@ extern int mvsnprintf(char *, size_t, const char *, va_list) extern int msnprintf(char *, size_t, const char *, ...) NTP_PRINTF(3, 4); extern void msyslog(int, const char *, ...) NTP_PRINTF(2, 3); +extern void mvsyslog(int, const char *, va_list) NTP_PRINTF(2, 0); extern void init_logging (const char *, u_int32, int); extern int change_logfile (const char *, int); extern void setup_logfile (const char *); diff --git a/contrib/ntp/include/ntp_syslog.h b/contrib/ntp/include/ntp_syslog.h index a0152b53d9ca..ecc6346796e8 100644 --- a/contrib/ntp/include/ntp_syslog.h +++ b/contrib/ntp/include/ntp_syslog.h @@ -9,6 +9,7 @@ #ifdef VMS extern void msyslog(); +extern void mvsyslog(); #else # ifndef SYS_VXWORKS # include diff --git a/contrib/ntp/include/ntp_types.h b/contrib/ntp/include/ntp_types.h index 1c66165b3b38..a947f30575e5 100644 --- a/contrib/ntp/include/ntp_types.h +++ b/contrib/ntp/include/ntp_types.h @@ -15,7 +15,8 @@ #include #if defined(HAVE_INTTYPES_H) # include -#elif defined(HAVE_STDINT_H) +#endif +#if defined(HAVE_STDINT_H) # include #endif diff --git a/contrib/ntp/include/rc_cmdlength.h b/contrib/ntp/include/rc_cmdlength.h new file mode 100644 index 000000000000..87947573d634 --- /dev/null +++ b/contrib/ntp/include/rc_cmdlength.h @@ -0,0 +1,2 @@ + +extern size_t remoteconfig_cmdlength( const char *src_buf, const char *src_end ); diff --git a/contrib/ntp/kernel/Makefile.in b/contrib/ntp/kernel/Makefile.in index d66d99438737..dd00144745df 100644 --- a/contrib/ntp/kernel/Makefile.in +++ b/contrib/ntp/kernel/Makefile.in @@ -115,6 +115,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -224,6 +225,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -232,6 +234,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -293,6 +296,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/kernel/sys/Makefile.in b/contrib/ntp/kernel/sys/Makefile.in index a9cefad760b7..58b0b6eee0f6 100644 --- a/contrib/ntp/kernel/sys/Makefile.in +++ b/contrib/ntp/kernel/sys/Makefile.in @@ -116,6 +116,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -185,6 +186,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -193,6 +195,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -254,6 +257,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/libntp/Makefile.in b/contrib/ntp/libntp/Makefile.in index b4b1d818d547..6e40cd4cddc5 100644 --- a/contrib/ntp/libntp/Makefile.in +++ b/contrib/ntp/libntp/Makefile.in @@ -117,6 +117,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -345,6 +346,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -353,6 +355,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -414,6 +417,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/libntp/atolfp.c b/contrib/ntp/libntp/atolfp.c index 3a65f6bcb2f7..9a2f6917873a 100644 --- a/contrib/ntp/libntp/atolfp.c +++ b/contrib/ntp/libntp/atolfp.c @@ -40,7 +40,7 @@ atolfp( int isneg; static const char *digits = "0123456789"; - NTP_REQUIRE(str != NULL); + REQUIRE(str != NULL); isneg = 0; dec_i = dec_f = 0; diff --git a/contrib/ntp/libntp/audio.c b/contrib/ntp/libntp/audio.c index 6f2262c991f3..726dfa94d819 100644 --- a/contrib/ntp/libntp/audio.c +++ b/contrib/ntp/libntp/audio.c @@ -377,7 +377,9 @@ audio_gain( #ifdef PCM_STYLE_SOUND int l, r; - rval = 0; +# ifdef GCC + rval = 0; /* GCC thinks rval is used uninitialized */ +# endif r = l = 100 * gain / 255; /* Normalize to 0-100 */ # ifdef DEBUG @@ -392,10 +394,11 @@ audio_gain( if (cf_agc[0] != '\0') rval = ioctl(ctl_fd, agc, &l); else - if (2 == port) - rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_LINE, &l); - else - rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_MIC, &l); + rval = ioctl(ctl_fd + , (2 == port) + ? SOUND_MIXER_WRITE_LINE + : SOUND_MIXER_WRITE_MIC + , &l); if (-1 == rval) { printf("audio_gain: agc write: %s\n", strerror(errno)); return rval; diff --git a/contrib/ntp/libntp/authkeys.c b/contrib/ntp/libntp/authkeys.c index 68771ffb339f..667ca298b96f 100644 --- a/contrib/ntp/libntp/authkeys.c +++ b/contrib/ntp/libntp/authkeys.c @@ -534,6 +534,12 @@ MD5auth_setkey( bucket = &key_hash[KEYHASH(keyno)]; for (sk = *bucket; sk != NULL; sk = sk->hlink) { if (keyno == sk->keyid) { + /* TALOS-CAN-0054: make sure we have a new buffer! */ + if (NULL != sk->secret) { + memset(sk->secret, 0, sk->secretsize); + free(sk->secret); + } + sk->secret = emalloc(len); sk->type = (u_short)keytype; secretsize = len; sk->secretsize = (u_short)secretsize; @@ -593,12 +599,14 @@ auth_delkeys(void) } /* - * Don't lose info as to which keys are trusted. + * Don't lose info as to which keys are trusted. Make + * sure there are no dangling pointers! */ if (KEY_TRUSTED & sk->flags) { if (sk->secret != NULL) { - memset(sk->secret, '\0', sk->secretsize); + memset(sk->secret, 0, sk->secretsize); free(sk->secret); + sk->secret = NULL; /* TALOS-CAN-0054 */ } sk->secretsize = 0; sk->lifetime = 0; diff --git a/contrib/ntp/libntp/authreadkeys.c b/contrib/ntp/libntp/authreadkeys.c index e8ddc942a665..1c4c07ca5926 100644 --- a/contrib/ntp/libntp/authreadkeys.c +++ b/contrib/ntp/libntp/authreadkeys.c @@ -62,6 +62,40 @@ nexttok( } +/* TALOS-CAN-0055: possibly DoS attack by setting the key file to the + * log file. This is hard to prevent (it would need to check two files + * to be the same on the inode level, which will not work so easily with + * Windows or VMS) but we can avoid the self-amplification loop: We only + * log the first 5 errors, silently ignore the next 10 errors, and give + * up when when we have found more than 15 errors. + * + * This avoids the endless file iteration we will end up with otherwise, + * and also avoids overflowing the log file. + * + * Nevertheless, once this happens, the keys are gone since this would + * require a save/swap strategy that is not easy to apply due to the + * data on global/static level. + */ + +static const size_t nerr_loglimit = 5u; +static const size_t nerr_maxlimit = 15; + +static void log_maybe(size_t*, const char*, ...) NTP_PRINTF(2, 3); + +static void +log_maybe( + size_t *pnerr, + const char *fmt , + ...) +{ + va_list ap; + if (++(*pnerr) <= nerr_loglimit) { + va_start(ap, fmt); + mvsyslog(LOG_ERR, fmt, ap); + va_end(ap); + } +} + /* * authreadkeys - (re)read keys from a file. */ @@ -79,7 +113,7 @@ authreadkeys( u_char keystr[32]; /* Bug 2537 */ size_t len; size_t j; - + size_t nerr; /* * Open file. Complain and return if it can't be opened. */ @@ -99,7 +133,10 @@ authreadkeys( /* * Now read lines from the file, looking for key entries */ + nerr = 0; while ((line = fgets(buf, sizeof buf, fp)) != NULL) { + if (nerr > nerr_maxlimit) + break; token = nexttok(&line); if (token == NULL) continue; @@ -109,15 +146,16 @@ authreadkeys( */ keyno = atoi(token); if (keyno == 0) { - msyslog(LOG_ERR, - "authreadkeys: cannot change key %s", token); + log_maybe(&nerr, + "authreadkeys: cannot change key %s", + token); continue; } if (keyno > NTP_MAXKEY) { - msyslog(LOG_ERR, - "authreadkeys: key %s > %d reserved for Autokey", - token, NTP_MAXKEY); + log_maybe(&nerr, + "authreadkeys: key %s > %d reserved for Autokey", + token, NTP_MAXKEY); continue; } @@ -126,8 +164,9 @@ authreadkeys( */ token = nexttok(&line); if (token == NULL) { - msyslog(LOG_ERR, - "authreadkeys: no key type for key %d", keyno); + log_maybe(&nerr, + "authreadkeys: no key type for key %d", + keyno); continue; } #ifdef OPENSSL @@ -139,13 +178,15 @@ authreadkeys( */ keytype = keytype_from_text(token, NULL); if (keytype == 0) { - msyslog(LOG_ERR, - "authreadkeys: invalid type for key %d", keyno); + log_maybe(&nerr, + "authreadkeys: invalid type for key %d", + keyno); continue; } if (EVP_get_digestbynid(keytype) == NULL) { - msyslog(LOG_ERR, - "authreadkeys: no algorithm for key %d", keyno); + log_maybe(&nerr, + "authreadkeys: no algorithm for key %d", + keyno); continue; } #else /* !OPENSSL follows */ @@ -155,8 +196,9 @@ authreadkeys( * 'm' for compatibility. */ if (!(*token == 'M' || *token == 'm')) { - msyslog(LOG_ERR, - "authreadkeys: invalid type for key %d", keyno); + log_maybe(&nerr, + "authreadkeys: invalid type for key %d", + keyno); continue; } keytype = KEY_TYPE_MD5; @@ -170,8 +212,8 @@ authreadkeys( */ token = nexttok(&line); if (token == NULL) { - msyslog(LOG_ERR, - "authreadkeys: no key for key %d", keyno); + log_maybe(&nerr, + "authreadkeys: no key for key %d", keyno); continue; } len = strlen(token); @@ -195,13 +237,24 @@ authreadkeys( keystr[j / 2] = temp << 4; } if (j < jlim) { - msyslog(LOG_ERR, - "authreadkeys: invalid hex digit for key %d", keyno); + log_maybe(&nerr, + "authreadkeys: invalid hex digit for key %d", + keyno); continue; } MD5auth_setkey(keyno, keytype, keystr, jlim / 2); } } fclose(fp); + if (nerr > nerr_maxlimit) { + msyslog(LOG_ERR, + "authreadkeys: emergency break after %u errors", + nerr); + return (0); + } else if (nerr > nerr_loglimit) { + msyslog(LOG_ERR, + "authreadkeys: found %u more error(s)", + nerr - nerr_loglimit); + } return (1); } diff --git a/contrib/ntp/libntp/caljulian.c b/contrib/ntp/libntp/caljulian.c index 6463699b152a..4a306033ad70 100644 --- a/contrib/ntp/libntp/caljulian.c +++ b/contrib/ntp/libntp/caljulian.c @@ -28,7 +28,7 @@ caljulian( ntpcal_split split; - NTP_INSIST(NULL != jt); + INSIST(NULL != jt); /* * Unfold ntp time around current time into NTP domain. Split diff --git a/contrib/ntp/libntp/caltontp.c b/contrib/ntp/libntp/caltontp.c index 4246a6a5431c..808c94c64afd 100644 --- a/contrib/ntp/libntp/caltontp.c +++ b/contrib/ntp/libntp/caltontp.c @@ -40,14 +40,14 @@ caltontp( int32_t eraday; /* CE Rata Die number */ vint64 ntptime;/* resulting NTP time */ - NTP_INSIST(jt != NULL); + REQUIRE(jt != NULL); - NTP_REQUIRE(jt->month <= 13); /* permit month 0..13! */ - NTP_REQUIRE(jt->monthday <= 32); - NTP_REQUIRE(jt->yearday <= 366); - NTP_REQUIRE(jt->hour <= 24); - NTP_REQUIRE(jt->minute <= MINSPERHR); - NTP_REQUIRE(jt->second <= SECSPERMIN); + REQUIRE(jt->month <= 13); /* permit month 0..13! */ + REQUIRE(jt->monthday <= 32); + REQUIRE(jt->yearday <= 366); + REQUIRE(jt->hour <= 24); + REQUIRE(jt->minute <= MINSPERHR); + REQUIRE(jt->second <= SECSPERMIN); /* * First convert the date to he corresponding RataDie diff --git a/contrib/ntp/libntp/decodenetnum.c b/contrib/ntp/libntp/decodenetnum.c index 187d5cae7e5b..35b908f39478 100644 --- a/contrib/ntp/libntp/decodenetnum.c +++ b/contrib/ntp/libntp/decodenetnum.c @@ -35,8 +35,11 @@ decodenetnum( char *np; char name[80]; - NTP_REQUIRE(num != NULL); - NTP_REQUIRE(strlen(num) < sizeof(name)); + REQUIRE(num != NULL); + + if (strlen(num) >= sizeof(name)) { + return 0; + } port_str = NULL; if ('[' != num[0]) { @@ -72,7 +75,7 @@ decodenetnum( err = getaddrinfo(cp, "ntp", &hints, &ai); if (err != 0) return 0; - NTP_INSIST(ai->ai_addrlen <= sizeof(*netnum)); + INSIST(ai->ai_addrlen <= sizeof(*netnum)); ZERO(*netnum); memcpy(netnum, ai->ai_addr, ai->ai_addrlen); freeaddrinfo(ai); diff --git a/contrib/ntp/libntp/emalloc.c b/contrib/ntp/libntp/emalloc.c index 95d293f1c3dc..8b7ef990c6b6 100644 --- a/contrib/ntp/libntp/emalloc.c +++ b/contrib/ntp/libntp/emalloc.c @@ -76,8 +76,6 @@ ereallocz( * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - /* * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW diff --git a/contrib/ntp/libntp/icom.c b/contrib/ntp/libntp/icom.c index 80700114255e..2e95db5eb3f4 100644 --- a/contrib/ntp/libntp/icom.c +++ b/contrib/ntp/libntp/icom.c @@ -6,14 +6,16 @@ * frequency. All other parameters must be manually set before use. */ #include -#include "icom.h" +#include +#include +#include +#include + #include #include #include #include -#include "ntp_tty.h" -#include "l_stdlib.h" #ifdef SYS_WINNT #undef write /* ports/winnt/include/config.h: #define write _write */ @@ -60,9 +62,14 @@ static void doublefreq (double, u_char *, int); /* * icom_freq(fd, ident, freq) - load radio frequency + * + * returns: + * 0 (ok) + * -1 (error) + * 1 (short write to device) */ int -icom_freq( /* returns 0 (ok), EIO (error) */ +icom_freq( int fd, /* file descriptor */ int ident, /* ICOM radio identifier */ double freq /* frequency (MHz) */ @@ -71,6 +78,7 @@ icom_freq( /* returns 0 (ok), EIO (error) */ u_char cmd[] = {PAD, PR, PR, 0, TX, V_SFREQ, 0, 0, 0, 0, FI, FI}; int temp; + int rc; cmd[3] = (char)ident; if (ident == IC735) @@ -78,9 +86,17 @@ icom_freq( /* returns 0 (ok), EIO (error) */ else temp = 5; doublefreq(freq * 1e6, &cmd[6], temp); - temp = write(fd, cmd, temp + 7); + rc = write(fd, cmd, temp + 7); + if (rc == -1) { + msyslog(LOG_ERR, "icom_freq: write() failed: %m"); + return -1; + } else if (rc != temp + 7) { + msyslog(LOG_ERR, "icom_freq: only wrote %d of %d bytes.", + rc, temp+7); + return 1; + } - return (0); + return 0; } diff --git a/contrib/ntp/libntp/machines.c b/contrib/ntp/libntp/machines.c index 43944f9edb3f..7a29ac07ea5f 100644 --- a/contrib/ntp/libntp/machines.c +++ b/contrib/ntp/libntp/machines.c @@ -40,7 +40,7 @@ struct hostent *gethostbyname(char *name) { struct hostent *host1; h_errno = 0; /* we are always successful!!! */ - host1 = (struct hostent *) malloc (sizeof(struct hostent)); + host1 = (struct hostent *) emalloc (sizeof(struct hostent)); host1->h_name = name; host1->h_addrtype = AF_INET; host1->h_aliases = name; @@ -54,7 +54,7 @@ struct hostent *gethostbyaddr(char *name, int size, int addr_type) { struct hostent *host1; h_errno = 0; /* we are always successful!!! */ - host1 = (struct hostent *) malloc (sizeof(struct hostent)); + host1 = (struct hostent *) emalloc (sizeof(struct hostent)); host1->h_name = name; host1->h_addrtype = AF_INET; host1->h_aliases = name; @@ -66,7 +66,7 @@ struct hostent *gethostbyaddr(char *name, int size, int addr_type) struct servent *getservbyname (char *name, char *type) { struct servent *serv1; - serv1 = (struct servent *) malloc (sizeof(struct servent)); + serv1 = (struct servent *) emalloc (sizeof(struct servent)); serv1->s_name = "ntp"; /* official service name */ serv1->s_aliases = NULL; /* alias list */ serv1->s_port = 123; /* port # */ diff --git a/contrib/ntp/libntp/msyslog.c b/contrib/ntp/libntp/msyslog.c index 283414d74423..cc8868f8e7b8 100644 --- a/contrib/ntp/libntp/msyslog.c +++ b/contrib/ntp/libntp/msyslog.c @@ -38,7 +38,7 @@ char * syslog_abs_fname; #define INIT_NTP_SYSLOGMASK ~(u_int32)0 u_int32 ntp_syslogmask = INIT_NTP_SYSLOGMASK; -extern char * progname; +extern char const * progname; /* Declare the local functions */ void addto_syslog (int, const char *); @@ -145,8 +145,8 @@ addto_syslog( const char * msg ) { - static char * prevcall_progname; - static char * prog; + static char const * prevcall_progname; + static char const * prog; const char nl[] = "\n"; const char empty[] = ""; FILE * term_file; @@ -357,6 +357,18 @@ msyslog( addto_syslog(level, buf); } +void +mvsyslog( + int level, + const char * fmt, + va_list ap + ) +{ + char buf[1024]; + mvsnprintf(buf, sizeof(buf), fmt, ap); + addto_syslog(level, buf); +} + /* * Initialize the logging @@ -371,7 +383,7 @@ init_logging( ) { static int was_daemon; - const char * cp; + char * cp; const char * pname; /* @@ -402,7 +414,7 @@ init_logging( #ifdef SYS_WINNT /* strip ".exe" */ cp = strrchr(progname, '.'); if (NULL != cp && !strcasecmp(cp, ".exe")) - progname[cp - progname] = '\0'; + *cp = '\0'; #endif #if !defined(VMS) @@ -454,7 +466,7 @@ change_logfile( size_t octets; #endif /* POSIX */ - NTP_REQUIRE(fname != NULL); + REQUIRE(fname != NULL); log_fname = fname; /* diff --git a/contrib/ntp/libntp/ntp_calendar.c b/contrib/ntp/libntp/ntp_calendar.c index ff91fcfc678d..ff6ead364e5a 100644 --- a/contrib/ntp/libntp/ntp_calendar.c +++ b/contrib/ntp/libntp/ntp_calendar.c @@ -3,7 +3,55 @@ * * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project. * The contents of 'html/copyright.html' apply. + * + * -------------------------------------------------------------------- + * Some notes on the implementation: + * + * Calendar algorithms thrive on the division operation, which is one of + * the slowest numerical operations in any CPU. What saves us here from + * abysmal performance is the fact that all divisions are divisions by + * constant numbers, and most compilers can do this by a multiplication + * operation. But this might not work when using the div/ldiv/lldiv + * function family, because many compilers are not able to do inline + * expansion of the code with following optimisation for the + * constant-divider case. + * + * Also div/ldiv/lldiv are defined in terms of int/long/longlong, which + * are inherently target dependent. Nothing that could not be cured with + * autoconf, but still a mess... + * + * Furthermore, we need floor division in many places. C either leaves + * the division behaviour undefined (< C99) or demands truncation to + * zero (>= C99), so additional steps are required to make sure the + * algorithms work. The {l,ll}div function family is requested to + * truncate towards zero, which is also the wrong direction for our + * purpose. + * + * For all this, all divisions by constant are coded manually, even when + * there is a joined div/mod operation: The optimiser should sort that + * out, if possible. Most of the calculations are done with unsigned + * types, explicitely using two's complement arithmetics where + * necessary. This minimises the dependecies to compiler and target, + * while still giving reasonable to good performance. + * + * The implementation uses a few tricks that exploit properties of the + * two's complement: Floor division on negative dividents can be + * executed by using the one's complement of the divident. One's + * complement can be easily created using XOR and a mask. + * + * Finally, check for overflow conditions is minimal. There are only two + * calculation steps in the whole calendar that suffer from an internal + * overflow, and these conditions are checked: errno is set to EDOM and + * the results are clamped/saturated in this case. All other functions + * do not suffer from internal overflow and simply return the result + * truncated to 32 bits. + * + * This is a sacrifice made for execution speed. Since a 32-bit day + * counter covers +/- 5,879,610 years and the clamp limits the effective + * range to +/-2.9 million years, this should not pose a problem here. + * */ + #include #include @@ -13,6 +61,33 @@ #include "ntp_fp.h" #include "ntp_unixtime.h" +/* For now, let's take the conservative approach: if the target property + * macros are not defined, check a few well-known compiler/architecture + * settings. Default is to assume that the representation of signed + * integers is unknown and shift-arithmetic-right is not available. + */ +#ifndef TARGET_HAS_2CPL +# if defined(__GNUC__) +# if defined(__i386__) || defined(__x86_64__) || defined(__arm__) +# define TARGET_HAS_2CPL 1 +# else +# define TARGET_HAS_2CPL 0 +# endif +# elif defined(_MSC_VER) +# if defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) +# define TARGET_HAS_2CPL 1 +# else +# define TARGET_HAS_2CPL 0 +# endif +# else +# define TARGET_HAS_2CPL 0 +# endif +#endif + +#ifndef TARGET_HAS_SAR +# define TARGET_HAS_SAR 0 +#endif + /* *--------------------------------------------------------------------- * replacing the 'time()' function @@ -45,6 +120,117 @@ now(void) return (*systime_func)(NULL); } +/* + *--------------------------------------------------------------------- + * Get sign extension mask and unsigned 2cpl rep for a signed integer + *--------------------------------------------------------------------- + */ + +static inline uint32_t +int32_sflag( + const int32_t v) +{ +# if TARGET_HAS_2CPL && TARGET_HAS_SAR && SIZEOF_INT >= 4 + + /* Let's assume that shift is the fastest way to get the sign + * extension of of a signed integer. This might not always be + * true, though -- On 8bit CPUs or machines without barrel + * shifter this will kill the performance. So we make sure + * we do this only if 'int' has at least 4 bytes. + */ + return (uint32_t)(v >> 31); + +# else + + /* This should be a rather generic approach for getting a sign + * extension mask... + */ + return UINT32_C(0) - (uint32_t)(v < 0); + +# endif +} + +static inline uint32_t +int32_to_uint32_2cpl( + const int32_t v) +{ + uint32_t vu; + +# if TARGET_HAS_2CPL + + /* Just copy through the 32 bits from the signed value if we're + * on a two's complement target. + */ + vu = (uint32_t)v; + +# else + + /* Convert from signed int to unsigned int two's complement. Do + * not make any assumptions about the representation of signed + * integers, but make sure signed integer overflow cannot happen + * here. A compiler on a two's complement target *might* find + * out that this is just a complicated cast (as above), but your + * mileage might vary. + */ + if (v < 0) + vu = ~(uint32_t)(-(v + 1)); + else + vu = (uint32_t)v; + +# endif + + return vu; +} + +static inline int32_t +uint32_2cpl_to_int32( + const uint32_t vu) +{ + int32_t v; + +# if TARGET_HAS_2CPL + + /* Just copy through the 32 bits from the unsigned value if + * we're on a two's complement target. + */ + v = (int32_t)vu; + +# else + + /* Convert to signed integer, making sure signed integer + * overflow cannot happen. Again, the optimiser might or might + * not find out that this is just a copy of 32 bits on a target + * with two's complement representation for signed integers. + */ + if (vu > INT32_MAX) + v = -(int32_t)(~vu) - 1; + else + v = (int32_t)vu; + +# endif + + return v; +} + +/* Some of the calculations need to multiply the input by 4 before doing + * a division. This can cause overflow and strange results. Therefore we + * clamp / saturate the input operand. And since we do the calculations + * in unsigned int with an extra sign flag/mask, we only loose one bit + * of the input value range. + */ +static inline uint32_t +uint32_saturate( + uint32_t vu, + uint32_t mu) +{ + static const uint32_t limit = UINT32_MAX/4u; + if ((mu ^ vu) > limit) { + vu = mu ^ limit; + errno = EDOM; + } + return vu; +} + /* *--------------------------------------------------------------------- * Convert between 'time_t' and 'vint64' @@ -60,7 +246,7 @@ time_to_vint64( tt = *ptt; -#if SIZEOF_TIME_T <= 4 +# if SIZEOF_TIME_T <= 4 res.D_s.hi = 0; if (tt < 0) { @@ -70,11 +256,11 @@ time_to_vint64( res.D_s.lo = (uint32_t)tt; } -#elif defined(HAVE_INT64) +# elif defined(HAVE_INT64) res.q_s = tt; -#else +# else /* * shifting negative signed quantities is compiler-dependent, so * we better avoid it and do it all manually. And shifting more @@ -90,7 +276,7 @@ time_to_vint64( res.D_s.hi = (uint32_t)(tt >> 32); } -#endif +# endif return res; } @@ -103,19 +289,19 @@ vint64_to_time( { time_t res; -#if SIZEOF_TIME_T <= 4 +# if SIZEOF_TIME_T <= 4 res = (time_t)tv->D_s.lo; -#elif defined(HAVE_INT64) +# elif defined(HAVE_INT64) res = (time_t)tv->q_s; -#else +# else res = ((time_t)tv->d_s.hi << 32) | tv->D_s.lo; -#endif +# endif return res; } @@ -153,11 +339,11 @@ ntpcal_get_build_date( * problem. * */ -#ifdef MKREPRO_DATE +# ifdef MKREPRO_DATE static const char build[] = MKREPRO_TIME "/" MKREPRO_DATE; -#else +# else static const char build[] = __TIME__ "/" __DATE__; -#endif +# endif static const char mlist[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; char monstr[4]; @@ -167,16 +353,16 @@ ntpcal_get_build_date( * so using 'uint16_t' is contra-indicated! */ -#ifdef DEBUG +# ifdef DEBUG static int ignore = 0; -#endif +# endif ZERO(*jd); jd->year = 1970; jd->month = 1; jd->monthday = 1; -#ifdef DEBUG +# ifdef DEBUG /* check environment if build date should be ignored */ if (0 == ignore) { const char * envstr; @@ -185,7 +371,7 @@ ntpcal_get_build_date( } if (ignore > 1) return FALSE; -#endif +# endif if (6 == sscanf(build, "%hu:%hu:%hu/%3s %hu %hu", &hour, &minute, &second, monstr, &day, &year)) { @@ -254,37 +440,8 @@ static const uint16_t real_month_table[2][13] = { * (day number). This is the number of days elapsed since 0000-12-31 * in the proleptic Gregorian calendar. The begin of the Christian Era * (0001-01-01) is RD(1). - * - * - * Some notes on the implementation: - * - * Calendar algorithms thrive on the division operation, which is one of - * the slowest numerical operations in any CPU. What saves us here from - * abysmal performance is the fact that all divisions are divisions by - * constant numbers, and most compilers can do this by a multiplication - * operation. But this might not work when using the div/ldiv/lldiv - * function family, because many compilers are not able to do inline - * expansion of the code with following optimisation for the - * constant-divider case. - * - * Also div/ldiv/lldiv are defined in terms of int/long/longlong, which - * are inherently target dependent. Nothing that could not be cured with - * autoconf, but still a mess... - * - * Furthermore, we need floor division while C demands truncation to - * zero, so additional steps are required to make sure the algorithms - * work. - * - * For all this, all divisions by constant are coded manually, even when - * there is a joined div/mod operation: The optimiser should sort that - * out, if possible. - * - * Finally, the functions do not check for overflow conditions. This - * is a sacrifice made for execution speed; since a 32-bit day counter - * covers +/- 5,879,610 years, this should not pose a problem here. */ - /* * ================================================================== * @@ -363,22 +520,23 @@ ntpcal_periodic_extend( * Get absolute difference as unsigned quantity and * the complement flag. This is done by always * subtracting the smaller value from the bigger - * one. This implementation works only on a two's - * complement machine! + * one. */ if (value >= pivot) { - diff = (uint32_t)value - (uint32_t)pivot; + diff = int32_to_uint32_2cpl(value) + - int32_to_uint32_2cpl(pivot); } else { - diff = (uint32_t)pivot - (uint32_t)value; + diff = int32_to_uint32_2cpl(pivot) + - int32_to_uint32_2cpl(value); cpl ^= 1; } diff %= (uint32_t)cycle; if (diff) { if (cpl) - diff = cycle - diff; + diff = (uint32_t)cycle - diff; if (neg) diff = ~diff + 1; - pivot += diff; + pivot += uint32_2cpl_to_int32(diff); } } return pivot; @@ -405,7 +563,7 @@ ntpcal_ntp_to_time( { vint64 res; -#ifdef HAVE_INT64 +# if defined(HAVE_INT64) res.q_s = (pivot != NULL) ? *pivot @@ -415,7 +573,7 @@ ntpcal_ntp_to_time( ntp -= res.D_s.lo; /* cycle difference */ res.Q_s += (uint64_t)ntp; /* get expanded time */ -#else /* no 64bit scalars */ +# else /* no 64bit scalars */ time_t tmp; @@ -428,7 +586,7 @@ ntpcal_ntp_to_time( ntp -= res.D_s.lo; /* cycle difference */ M_ADD(res.D_s.hi, res.D_s.lo, 0, ntp); -#endif /* no 64bit scalars */ +# endif /* no 64bit scalars */ return res; } @@ -454,7 +612,7 @@ ntpcal_ntp_to_ntp( { vint64 res; -#ifdef HAVE_INT64 +# if defined(HAVE_INT64) res.q_s = (pivot) ? *pivot @@ -464,7 +622,7 @@ ntpcal_ntp_to_ntp( ntp -= res.D_s.lo; /* cycle difference */ res.Q_s += (uint64_t)ntp; /* get expanded time */ -#else /* no 64bit scalars */ +# else /* no 64bit scalars */ time_t tmp; @@ -477,7 +635,7 @@ ntpcal_ntp_to_ntp( ntp -= res.D_s.lo; /* cycle difference */ M_ADD(res.D_s.hi, res.D_s.lo, 0, ntp); -#endif /* no 64bit scalars */ +# endif /* no 64bit scalars */ return res; } @@ -505,78 +663,75 @@ ntpcal_daysplit( ) { ntpcal_split res; + uint32_t Q; -#ifdef HAVE_INT64 - - /* manual floor division by SECSPERDAY */ - res.hi = (int32_t)(ts->q_s / SECSPERDAY); - res.lo = (int32_t)(ts->q_s % SECSPERDAY); - if (res.lo < 0) { - res.hi -= 1; - res.lo += SECSPERDAY; - } - -#else - - /* - * since we do not have 64bit ops, we have to this by hand. - * Luckily SECSPERDAY is 86400 is 675*128, so we do the division - * using chained 32/16 bit divisions and shifts. +# if defined(HAVE_INT64) + + /* Manual floor division by SECSPERDAY. This uses the one's + * complement trick, too, but without an extra flag value: The + * flag would be 64bit, and that's a bit of overkill on a 32bit + * target that has to use a register pair for a 64bit number. */ - vint64 op; - uint32_t q, r, a; - int isneg; + if (ts->q_s < 0) + Q = ~(uint32_t)(~ts->Q_s / SECSPERDAY); + else + Q = (uint32_t)(ts->Q_s / SECSPERDAY); - memcpy(&op, ts, sizeof(op)); - /* fix sign */ - isneg = M_ISNEG(op.D_s.hi); - if (isneg) - M_NEG(op.D_s.hi, op.D_s.lo); +# else - /* save remainder of DIV 128, shift for divide */ - r = op.D_s.lo & 127; /* save remainder bits */ - op.D_s.lo = (op.D_s.lo >> 7) | (op.D_s.hi << 25); - op.D_s.hi = (op.D_s.hi >> 7); + uint32_t ah, al, sflag, A; - /* now do a mnual division, trying to remove as many ops as - * possible -- division is always slow! An since we do not have - * the advantage of a specific 64/32 bit or even a specific 32/16 - * bit division op, but must use the general 32/32bit division - * even if we *know* the divider fits into unsigned 16 bits, the - * exra code pathes should pay off. + /* get operand into ah/al (either ts or ts' one's complement, + * for later floor division) */ - a = op.D_s.hi; - if (a > 675u) - a = a % 675u; - if (a) { - a = (a << 16) | op.W_s.lh; - q = a / 675u; - a = a % 675u; + sflag = int32_sflag(ts->d_s.hi); + ah = sflag ^ ts->D_s.hi; + al = sflag ^ ts->D_s.lo; - a = (a << 16) | op.W_s.ll; - q = (q << 16) | (a / 675u); - } else { - a = op.D_s.lo; - q = a / 675u; - } - a = a % 675u; + /* Since 86400 == 128*675 we can drop the least 7 bits and + * divide by 675 instead of 86400. Then the maximum remainder + * after each devision step is 674, and we need 10 bits for + * that. So in the next step we can shift in 22 bits from the + * numerator. + * + * Therefore we load the accu with the top 13 bits (51..63) in + * the first shot. We don't have to remember the quotient -- it + * would be shifted out anyway. + */ + A = ah >> 19; + if (A >= 675) + A = (A % 675u); - /* assemble remainder */ - r |= a << 7; + /* Now assemble the remainder with bits 29..50 from the + * numerator and divide. This creates the upper ten bits of the + * quotient. (Well, the top 22 bits of a 44bit result. But that + * will be truncated to 32 bits anyway.) + */ + A = (A << 19) | (ah & 0x0007FFFFu); + A = (A << 3) | (al >> 29); + Q = A / 675u; + A = A % 675u; - /* fix sign of result */ - if (isneg) { - if (r) { - r = SECSPERDAY - r; - q = ~q; - } else - q = ~q + 1; - } + /* Now assemble the remainder with bits 7..28 from the numerator + * and do a final division step. + */ + A = (A << 22) | ((al >> 7) & 0x003FFFFFu); + Q = (Q << 22) | (A / 675u); - res.hi = q; - res.lo = r; + /* The last 7 bits get simply dropped, as they have no affect on + * the quotient when dividing by 86400. + */ + + /* apply sign correction and calculate the true floor + * remainder. + */ + Q ^= sflag; + +# endif + + res.hi = uint32_2cpl_to_int32(Q); + res.lo = ts->D_s.lo - Q * SECSPERDAY; -#endif return res; } @@ -593,25 +748,28 @@ priv_timesplit( int32_t ts ) { - int32_t days = 0; + /* Do 3 chained floor divisions by positive constants, using the + * one's complement trick and factoring out the intermediate XOR + * ops to reduce the number of operations. + */ + uint32_t us, um, uh, ud, sflag; - /* make sure we have a positive offset into a day */ - if (ts < 0 || ts >= SECSPERDAY) { - days = ts / SECSPERDAY; - ts = ts % SECSPERDAY; - if (ts < 0) { - days -= 1; - ts += SECSPERDAY; - } - } + sflag = int32_sflag(ts); + us = int32_to_uint32_2cpl(ts); - /* get secs, mins, hours */ - split[2] = (uint8_t)(ts % SECSPERMIN); - ts /= SECSPERMIN; - split[1] = (uint8_t)(ts % MINSPERHR); - split[0] = (uint8_t)(ts / MINSPERHR); + um = (sflag ^ us) / SECSPERMIN; + uh = um / MINSPERHR; + ud = uh / HRSPERDAY; - return days; + um ^= sflag; + uh ^= sflag; + ud ^= sflag; + + split[0] = (int32_t)(uh - ud * HRSPERDAY ); + split[1] = (int32_t)(um - uh * MINSPERHR ); + split[2] = (int32_t)(us - um * SECSPERMIN); + + return uint32_2cpl_to_int32(ud); } /* @@ -630,46 +788,45 @@ ntpcal_split_eradays( int *isleapyear ) { + /* Use the fast cyclesplit algorithm here, to calculate the + * centuries and years in a century with one division each. This + * reduces the number of division operations to two, but is + * susceptible to internal range overflow. We make sure the + * input operands are in the safe range; this still gives us + * approx +/-2.9 million years. + */ ntpcal_split res; - int32_t n400, n100, n004, n001, yday; /* calendar year cycles */ + int32_t n100, n001; /* calendar year cycles */ + uint32_t uday, Q, sflag; - /* - * Split off calendar cycles, using floor division in the first - * step. After that first step, simple division does it because - * all operands are positive; alas, we have to be aware of the - * possibe cycle overflows for 100 years and 1 year, caused by - * the additional leap day. + /* split off centuries first */ + sflag = int32_sflag(days); + uday = uint32_saturate(int32_to_uint32_2cpl(days), sflag); + uday = (4u * uday) | 3u; + Q = sflag ^ ((sflag ^ uday) / GREGORIAN_CYCLE_DAYS); + uday = uday - Q * GREGORIAN_CYCLE_DAYS; + n100 = uint32_2cpl_to_int32(Q); + + /* Split off years in century -- days >= 0 here, and we're far + * away from integer overflow trouble now. */ + uday |= 3; + n001 = uday / GREGORIAN_NORMAL_LEAP_CYCLE_DAYS; + uday = uday % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS; + + /* Assemble the year and day in year */ + res.hi = n100 * 100 + n001; + res.lo = uday / 4u; + + /* Eventually set the leap year flag. Note: 0 <= n001 <= 99 and + * Q is still the two's complement representation of the + * centuries: The modulo 4 ops can be done with masking here. + * We also shift the year and the century by one, so the tests + * can be done against zero instead of 3. */ - n400 = days / GREGORIAN_CYCLE_DAYS; - yday = days % GREGORIAN_CYCLE_DAYS; - if (yday < 0) { - n400 -= 1; - yday += GREGORIAN_CYCLE_DAYS; - } - n100 = yday / GREGORIAN_NORMAL_CENTURY_DAYS; - yday = yday % GREGORIAN_NORMAL_CENTURY_DAYS; - n004 = yday / GREGORIAN_NORMAL_LEAP_CYCLE_DAYS; - yday = yday % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS; - n001 = yday / DAYSPERYEAR; - yday = yday % DAYSPERYEAR; - - /* - * check for leap cycle overflows and calculate the leap flag - * if needed - */ - if ((n001 | n100) > 3) { - /* hit last day of leap year */ - n001 -= 1; - yday += DAYSPERYEAR; - if (isleapyear) - *isleapyear = 1; - } else if (isleapyear) - *isleapyear = (n001 == 3) && ((n004 != 24) || (n100 == 3)); - - /* now merge the cycles to elapsed years, using horner scheme */ - res.hi = ((4*n400 + n100)*25 + n004)*4 + n001; - res.lo = yday; - + if (isleapyear) + *isleapyear = !((n001+1) & 3) + && ((n001 != 99) || !((Q+1) & 3)); + return res; } @@ -719,11 +876,9 @@ ntpcal_rd_to_date( ) { ntpcal_split split; - int leaps; - int retv; + int leapy; + u_int ymask; - leaps = 0; - retv = 0; /* Get day-of-week first. Since rd is signed, the remainder can * be in the range [-6..+6], but the assignment to an unsigned * variable maps the negative values to positive values >=7. @@ -731,26 +886,28 @@ ntpcal_rd_to_date( * causes the needed wrap-around into the desired value range of * zero to six, both inclusive. */ - jd->weekday = rd % 7; - if (jd->weekday >= 7) /* unsigned! */ - jd->weekday += 7; + jd->weekday = rd % DAYSPERWEEK; + if (jd->weekday >= DAYSPERWEEK) /* weekday is unsigned! */ + jd->weekday += DAYSPERWEEK; - split = ntpcal_split_eradays(rd - 1, &leaps); - retv = leaps; - /* get year and day-of-year */ - jd->year = (uint16_t)split.hi + 1; - if (jd->year != split.hi + 1) { - jd->year = 0; - retv = -1; /* bletch. overflow trouble. */ - } + split = ntpcal_split_eradays(rd - 1, &leapy); + /* Get year and day-of-year, with overflow check. If any of the + * upper 16 bits is set after shifting to unity-based years, we + * will have an overflow when converting to an unsigned 16bit + * year. Shifting to the right is OK here, since it does not + * matter if the shift is logic or arithmetic. + */ + split.hi += 1; + ymask = 0u - ((split.hi >> 16) == 0); + jd->year = (uint16_t)(split.hi & ymask); jd->yearday = (uint16_t)split.lo + 1; /* convert to month and mday */ - split = ntpcal_split_yeardays(split.lo, leaps); + split = ntpcal_split_yeardays(split.lo, leapy); jd->month = (uint8_t)split.hi + 1; jd->monthday = (uint8_t)split.lo + 1; - return retv ? retv : leaps; + return ymask ? leapy : -1; } /* @@ -765,25 +922,24 @@ ntpcal_rd_to_tm( ) { ntpcal_split split; - int leaps; + int leapy; - leaps = 0; /* get day-of-week first */ - utm->tm_wday = rd % 7; + utm->tm_wday = rd % DAYSPERWEEK; if (utm->tm_wday < 0) - utm->tm_wday += 7; + utm->tm_wday += DAYSPERWEEK; /* get year and day-of-year */ - split = ntpcal_split_eradays(rd - 1, &leaps); + split = ntpcal_split_eradays(rd - 1, &leapy); utm->tm_year = split.hi - 1899; utm->tm_yday = split.lo; /* 0-based */ /* convert to month and mday */ - split = ntpcal_split_yeardays(split.lo, leaps); + split = ntpcal_split_yeardays(split.lo, leapy); utm->tm_mon = split.hi; /* 0-based */ utm->tm_mday = split.lo + 1; /* 1-based */ - return leaps; + return leapy; } /* @@ -918,13 +1074,13 @@ ntpcal_dayjoin( { vint64 res; -#ifdef HAVE_INT64 +# if defined(HAVE_INT64) res.q_s = days; res.q_s *= SECSPERDAY; res.q_s += secs; -#else +# else uint32_t p1, p2; int isneg; @@ -963,21 +1119,49 @@ ntpcal_dayjoin( } M_ADD(res.D_s.hi, res.D_s.lo, p2, p1); -#endif +# endif return res; } +/* + *--------------------------------------------------------------------- + * get leap years since epoch in elapsed years + *--------------------------------------------------------------------- + */ +int32_t +ntpcal_leapyears_in_years( + int32_t years + ) +{ + /* We use the in-out-in algorithm here, using the one's + * complement division trick for negative numbers. The chained + * division sequence by 4/25/4 gives the compiler the chance to + * get away with only one true division and doing shifts otherwise. + */ + + uint32_t sflag, sum, uyear; + + sflag = int32_sflag(years); + uyear = int32_to_uint32_2cpl(years); + uyear ^= sflag; + + sum = (uyear /= 4u); /* 4yr rule --> IN */ + sum -= (uyear /= 25u); /* 100yr rule --> OUT */ + sum += (uyear /= 4u); /* 400yr rule --> IN */ + + /* Thanks to the alternation of IN/OUT/IN we can do the sum + * directly and have a single one's complement operation + * here. (Only if the years are negative, of course.) Otherwise + * the one's complement would have to be done when + * adding/subtracting the terms. + */ + return uint32_2cpl_to_int32(sflag ^ sum); +} + /* *--------------------------------------------------------------------- * Convert elapsed years in Era into elapsed days in Era. - * - * To accomodate for negative values of years, floor division would be - * required for all division operations. This can be eased by first - * splitting the years into full 400-year cycles and years in the - * cycle. Only this operation must be coded as a full floor division; as - * the years in the cycle is a non-negative number, all other divisions - * can be regular truncated divisions. *--------------------------------------------------------------------- */ int32_t @@ -985,25 +1169,7 @@ ntpcal_days_in_years( int32_t years ) { - int32_t cycle; /* full gregorian cycle */ - - /* split off full calendar cycles, using floor division */ - cycle = years / 400; - years = years % 400; - if (years < 0) { - cycle -= 1; - years += 400; - } - - /* - * Calculate days in cycle. years now is a non-negative number, - * holding the number of years in the 400-year cycle. - */ - return cycle * GREGORIAN_CYCLE_DAYS - + years * DAYSPERYEAR /* days inregular years */ - + years / 4 /* 4 year leap rule */ - - years / 100; /* 100 year leap rule */ - /* the 400-year rule does not apply due to full-cycle split-off */ + return years * DAYSPERYEAR + ntpcal_leapyears_in_years(years); } /* @@ -1029,26 +1195,22 @@ ntpcal_days_in_months( { ntpcal_split res; - /* normalize month into range */ - res.hi = 0; - res.lo = m; + /* Add ten months and correct if needed. (It likely is...) */ + res.lo = m + 10; + res.hi = (res.lo >= 12); + if (res.hi) + res.lo -= 12; + + /* if still out of range, normalise by floor division ... */ if (res.lo < 0 || res.lo >= 12) { - res.hi = res.lo / 12; - res.lo = res.lo % 12; - if (res.lo < 0) { - res.hi -= 1; - res.lo += 12; - } + uint32_t mu, Q, sflag; + sflag = int32_sflag(res.lo); + mu = int32_to_uint32_2cpl(res.lo); + Q = sflag ^ ((sflag ^ mu) / 12u); + res.hi += uint32_2cpl_to_int32(Q); + res.lo = mu - Q * 12u; } - - /* add 10 month for year starting with march */ - if (res.lo < 2) - res.lo += 10; - else { - res.hi += 1; - res.lo -= 2; - } - + /* get cummulated days in year with unshift */ res.lo = shift_month_table[res.lo] - 306; @@ -1451,37 +1613,42 @@ int32_t isocal_weeks_in_years( int32_t years ) -{ +{ /* * use: w = (y * 53431 + b[c]) / 1024 as interpolation */ - static const int32_t bctab[4] = { 449, 157, 889, 597 }; - int32_t cycle; /* full gregorian cycle */ - int32_t cents; /* full centuries */ - int32_t weeks; /* accumulated weeks */ + static const uint16_t bctab[4] = { 157, 449, 597, 889 }; - /* split off full calendar cycles, using floor division */ - cycle = years / 400; - years = years % 400; - if (years < 0) { - cycle -= 1; - years += 400; - } + int32_t cs, cw; + uint32_t cc, ci, yu, sflag; - /* split off full centuries */ - cents = years / 100; - years = years % 100; + sflag = int32_sflag(years); + yu = int32_to_uint32_2cpl(years); + + /* split off centuries, using floor division */ + cc = sflag ^ ((sflag ^ yu) / 100u); + yu -= cc * 100u; - /* - * calculate elapsed weeks, taking into account that the - * first, third and fourth century have 5218 weeks but the - * second century falls short by one week. + /* calculate century cycles shift and cycle index: + * Assuming a century is 5217 weeks, we have to add a cycle + * shift that is 3 for every 4 centuries, because 3 of the four + * centuries have 5218 weeks. So '(cc*3 + 1) / 4' is the actual + * correction, and the second century is the defective one. + * + * Needs floor division by 4, which is done with masking and + * shifting. */ - weeks = (years * 53431 + bctab[cents]) / 1024; + ci = cc * 3u + 1; + cs = uint32_2cpl_to_int32(sflag ^ ((sflag ^ ci) / 4u)); + ci = ci % 4u; + + /* Get weeks in century. Can use plain division here as all ops + * are >= 0, and let the compiler sort out the possible + * optimisations. + */ + cw = (yu * 53431u + bctab[ci]) / 1024u; - return cycle * GREGORIAN_CYCLE_WEEKS - + cents * 5218 - (cents > 1) - + weeks; + return uint32_2cpl_to_int32(cc) * 5217 + cs + cw; } /* @@ -1498,35 +1665,41 @@ isocal_split_eraweeks( /* * use: y = (w * 157 + b[c]) / 8192 as interpolation */ - static const int32_t bctab[4] = { 85, 131, 17, 62 }; + + static const uint16_t bctab[4] = { 85, 130, 17, 62 }; + ntpcal_split res; - int32_t cents; + int32_t cc, ci; + uint32_t sw, cy, Q, sflag; - /* - * split off 400-year cycles, using the fact that a 400-year - * cycle has 146097 days, which is exactly 20871 weeks. + /* Use two fast cycle-split divisions here. This is again + * susceptible to internal overflow, so we check the range. This + * still permits more than +/-20 million years, so this is + * likely a pure academical problem. + * + * We want to execute '(weeks * 4 + 2) /% 20871' under floor + * division rules in the first step. */ - res.hi = weeks / GREGORIAN_CYCLE_WEEKS; - res.lo = weeks % GREGORIAN_CYCLE_WEEKS; - if (res.lo < 0) { - res.hi -= 1; - res.lo += GREGORIAN_CYCLE_WEEKS; - } - res.hi *= 400; + sflag = int32_sflag(weeks); + sw = uint32_saturate(int32_to_uint32_2cpl(weeks), sflag); + sw = 4u * sw + 2; + Q = sflag ^ ((sflag ^ sw) / GREGORIAN_CYCLE_WEEKS); + sw -= Q * GREGORIAN_CYCLE_WEEKS; + ci = Q % 4u; + cc = uint32_2cpl_to_int32(Q); - /* - * split off centuries, taking into account that the first, - * third and fourth century have 5218 weeks but that the - * second century falls short by one week. + /* Split off years; sw >= 0 here! The scaled weeks in the years + * are scaled up by 157 afterwards. + */ + sw = (sw / 4u) * 157u + bctab[ci]; + cy = sw / 8192u; /* ws >> 13 , let the compiler sort it out */ + sw = sw % 8192u; /* ws & 8191, let the compiler sort it out */ + + /* assemble elapsed years and downscale the elapsed weeks in + * the year. */ - res.lo += (res.lo >= 10435); - cents = res.lo / 5218; - res.lo %= 5218; /* res.lo is weeks in century now */ - - /* convert elapsed weeks in century to elapsed years and weeks */ - res.lo = res.lo * 157 + bctab[cents]; - res.hi += cents * 100 + res.lo / 8192; - res.lo = (res.lo % 8192) / 157; + res.hi = 100*cc + cy; + res.lo = sw / 157u; return res; } @@ -1544,6 +1717,7 @@ isocal_ntp64_to_date( { ntpcal_split ds; int32_t ts[3]; + uint32_t uw, ud, sflag; /* * Split NTP time into days and seconds, shift days into CE @@ -1557,16 +1731,18 @@ isocal_ntp64_to_date( id->minute = (uint8_t)ts[1]; id->second = (uint8_t)ts[2]; - /* split date part */ - ds.lo = ds.hi + DAY_NTP_STARTS - 1; /* elapsed era days */ - ds.hi = ds.lo / 7; /* elapsed era weeks */ - ds.lo = ds.lo % 7; /* elapsed week days */ - if (ds.lo < 0) { /* floor division! */ - ds.hi -= 1; - ds.lo += 7; - } + /* split days into days and weeks, using floor division in unsigned */ + ds.hi += DAY_NTP_STARTS - 1; /* shift from NTP to RDN */ + sflag = int32_sflag(ds.hi); + ud = int32_to_uint32_2cpl(ds.hi); + uw = sflag ^ ((sflag ^ ud) / DAYSPERWEEK); + ud -= uw * DAYSPERWEEK; + ds.hi = uint32_2cpl_to_int32(uw); + ds.lo = ud; + id->weekday = (uint8_t)ds.lo + 1; /* weekday result */ + /* get year and week in year */ ds = isocal_split_eraweeks(ds.hi); /* elapsed years&week*/ id->year = (uint16_t)ds.hi + 1; /* shift to current */ id->week = (uint8_t )ds.lo + 1; diff --git a/contrib/ntp/libntp/ntp_intres.c b/contrib/ntp/libntp/ntp_intres.c index eea88a127378..b0f562036a00 100644 --- a/contrib/ntp/libntp/ntp_intres.c +++ b/contrib/ntp/libntp/ntp_intres.c @@ -249,12 +249,12 @@ getaddrinfo_sometime( size_t servsize; time_t now; - NTP_REQUIRE(NULL != node); + REQUIRE(NULL != node); if (NULL != hints) { - NTP_REQUIRE(0 == hints->ai_addrlen); - NTP_REQUIRE(NULL == hints->ai_addr); - NTP_REQUIRE(NULL == hints->ai_canonname); - NTP_REQUIRE(NULL == hints->ai_next); + REQUIRE(0 == hints->ai_addrlen); + REQUIRE(NULL == hints->ai_addr); + REQUIRE(NULL == hints->ai_canonname); + REQUIRE(NULL == hints->ai_next); } idx = get_dnschild_ctx(); @@ -420,7 +420,7 @@ blocking_getaddrinfo( ai = ai_res; while (NULL != ai) { - NTP_INSIST(ai->ai_addrlen <= sizeof(sockaddr_u)); + INSIST(ai->ai_addrlen <= sizeof(sockaddr_u)); memcpy(cp, ai->ai_addr, ai->ai_addrlen); cp += sizeof(sockaddr_u); @@ -568,7 +568,7 @@ getaddrinfo_sometime_complete( ai[i].ai_canonname += (size_t)canon_start; } - NTP_ENSURE((char *)psau == canon_start); + ENSURE((char *)psau == canon_start); if (!gai_resp->ai_count) ai = NULL; @@ -634,8 +634,8 @@ getnameinfo_sometime( dnschild_ctx * child_ctx; time_t time_now; - NTP_REQUIRE(hostoctets); - NTP_REQUIRE(hostoctets + servoctets < 1024); + REQUIRE(hostoctets); + REQUIRE(hostoctets + servoctets < 1024); idx = get_dnschild_ctx(); child_ctx = dnschild_contexts[idx]; @@ -699,7 +699,7 @@ blocking_getnameinfo( * large allocations. We only need room for the host * and service names. */ - NTP_REQUIRE(octets < sizeof(host)); + REQUIRE(octets < sizeof(host)); service = host + gni_req->hostoctets; worker_ctx = get_worker_context(c, gni_req->dns_idx); @@ -775,8 +775,8 @@ blocking_getnameinfo( cp += gni_resp->servoctets; } - NTP_INSIST((size_t)(cp - (char *)resp) == resp_octets); - NTP_INSIST(resp_octets - sizeof(*resp) == gni_resp->octets); + INSIST((size_t)(cp - (char *)resp) == resp_octets); + INSIST(resp_octets - sizeof(*resp) == gni_resp->octets); rc = queue_blocking_response(c, resp, resp_octets, req); if (rc) diff --git a/contrib/ntp/libntp/ntp_lineedit.c b/contrib/ntp/libntp/ntp_lineedit.c index e3bc0022a292..a2b2d2934705 100644 --- a/contrib/ntp/libntp/ntp_lineedit.c +++ b/contrib/ntp/libntp/ntp_lineedit.c @@ -36,7 +36,7 @@ * external references */ -extern char * progname; +extern char const * progname; /* * globals, private prototypes diff --git a/contrib/ntp/libntp/ntp_rfc2553.c b/contrib/ntp/libntp/ntp_rfc2553.c index f267999c5e3f..a9ebb4b35363 100644 --- a/contrib/ntp/libntp/ntp_rfc2553.c +++ b/contrib/ntp/libntp/ntp_rfc2553.c @@ -221,7 +221,7 @@ copy_addrinfo_common( } ++ai_cpy; } - NTP_ENSURE(pcanon == ((char *)dst + octets)); + ENSURE(pcanon == ((char *)dst + octets)); return dst; } diff --git a/contrib/ntp/libntp/ntp_worker.c b/contrib/ntp/libntp/ntp_worker.c index bb1cb87e44a0..32970da0d124 100644 --- a/contrib/ntp/libntp/ntp_worker.c +++ b/contrib/ntp/libntp/ntp_worker.c @@ -278,7 +278,7 @@ blocking_child_common( req = receive_blocking_req_internal(c); if (NULL == req) { say_bye = TRUE; - break; + continue; } DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == req->magic_sig); diff --git a/contrib/ntp/libntp/prettydate.c b/contrib/ntp/libntp/prettydate.c index 5da5ecc50a69..25b085ef28fb 100644 --- a/contrib/ntp/libntp/prettydate.c +++ b/contrib/ntp/libntp/prettydate.c @@ -141,7 +141,7 @@ get_struct_tm( return NULL; /* That's truly pathological! */ /* 'tm' surely not NULL here! */ - NTP_INSIST(tm != NULL); + INSIST(tm != NULL); if (folds != 0) { tm->tm_year += folds * SOLAR_CYCLE_YEARS; if (tm->tm_year <= 0 || tm->tm_year >= 200) diff --git a/contrib/ntp/libntp/recvbuff.c b/contrib/ntp/libntp/recvbuff.c index 83a9ee193a3b..73ebe886d9a7 100644 --- a/contrib/ntp/libntp/recvbuff.c +++ b/contrib/ntp/libntp/recvbuff.c @@ -216,7 +216,7 @@ get_free_recv_buffer_alloc(void) create_buffers(RECV_INC); buffer = get_free_recv_buffer(); } - NTP_ENSURE(buffer != NULL); + ENSURE(buffer != NULL); return (buffer); } #endif diff --git a/contrib/ntp/libntp/socket.c b/contrib/ntp/libntp/socket.c index de678c6340b4..11fb004690c4 100644 --- a/contrib/ntp/libntp/socket.c +++ b/contrib/ntp/libntp/socket.c @@ -78,7 +78,7 @@ move_fd( static SOCKET socket_boundary = -1; SOCKET newfd; - NTP_REQUIRE((int)fd >= 0); + REQUIRE((int)fd >= 0); /* * check whether boundary has be set up @@ -115,7 +115,7 @@ move_fd( socket_boundary)); } while (socket_boundary > 0); #else - NTP_REQUIRE((int)fd >= 0); + ENSURE((int)fd >= 0); #endif /* !defined(SYS_WINNT) && defined(F_DUPFD) */ return fd; } diff --git a/contrib/ntp/libntp/socktohost.c b/contrib/ntp/libntp/socktohost.c index c61e57148a65..3d9ab960e8a1 100644 --- a/contrib/ntp/libntp/socktohost.c +++ b/contrib/ntp/libntp/socktohost.c @@ -79,7 +79,7 @@ socktohost( if (a_info) goto forward_fail; - NTP_INSIST(alist != NULL); + INSIST(alist != NULL); for (ai = alist; ai != NULL; ai = ai->ai_next) { /* diff --git a/contrib/ntp/libntp/statestr.c b/contrib/ntp/libntp/statestr.c index cd98eb3951a3..313cd46bebfe 100644 --- a/contrib/ntp/libntp/statestr.c +++ b/contrib/ntp/libntp/statestr.c @@ -60,7 +60,7 @@ static const struct codestring select_codes[] = { { CTL_PST_SEL_REJECT, "sel_reject" }, { CTL_PST_SEL_SANE, "sel_falsetick" }, { CTL_PST_SEL_CORRECT, "sel_excess" }, - { CTL_PST_SEL_SELCAND, "sel_outlyer" }, + { CTL_PST_SEL_SELCAND, "sel_outlier" }, { CTL_PST_SEL_SYNCCAND, "sel_candidate" }, { CTL_PST_SEL_EXCESS, "sel_backup" }, { CTL_PST_SEL_SYSPEER, "sel_sys.peer" }, diff --git a/contrib/ntp/libparse/Makefile.in b/contrib/ntp/libparse/Makefile.in index 4b15dd685cf3..2f13e1f47f1c 100644 --- a/contrib/ntp/libparse/Makefile.in +++ b/contrib/ntp/libparse/Makefile.in @@ -118,6 +118,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -252,6 +253,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -260,6 +262,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -321,6 +324,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ diff --git a/contrib/ntp/ntpd/Makefile.am b/contrib/ntp/ntpd/Makefile.am index c94f7c09edf6..a5690b70d391 100644 --- a/contrib/ntp/ntpd/Makefile.am +++ b/contrib/ntp/ntpd/Makefile.am @@ -432,6 +432,9 @@ version.c: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/ version.o: version.c env CCACHE_DISABLE=1 $(COMPILE) -c version.c -o version.o +$(srcdir)/Makefile.am: + @: do-nothing + include $(top_srcdir)/bincheck.mf include $(top_srcdir)/check-libopts.mf include $(top_srcdir)/sntp/check-libntp.mf diff --git a/contrib/ntp/ntpd/Makefile.in b/contrib/ntp/ntpd/Makefile.in index 7f3084693593..2304e33d1f0f 100644 --- a/contrib/ntp/ntpd/Makefile.in +++ b/contrib/ntp/ntpd/Makefile.in @@ -125,6 +125,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \ + $(top_srcdir)/sntp/m4/ntp_problemtests.m4 \ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ @@ -343,6 +344,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_THREAD = @BUILD_THREAD@ CALC_TICKADJ_DB = @CALC_TICKADJ_DB@ CALC_TICKADJ_DL = @CALC_TICKADJ_DL@ CALC_TICKADJ_DS = @CALC_TICKADJ_DS@ @@ -351,6 +353,7 @@ CALC_TICKADJ_NI = @CALC_TICKADJ_NI@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@ CFLAGS_NTP = @CFLAGS_NTP@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ @@ -412,6 +415,7 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIPO = @LIPO@ LN_S = @LN_S@ LSCF = @LSCF@ +LTHREAD_LIBS = @LTHREAD_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MAKE_ADJTIMED = @MAKE_ADJTIMED@ @@ -1827,6 +1831,9 @@ version.c: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/ version.o: version.c env CCACHE_DISABLE=1 $(COMPILE) -c version.c -o version.o +$(srcdir)/Makefile.am: + @: do-nothing + install-exec-hook: @test -z "${bin_PROGRAMS}${bin_SCRIPTS}" \ || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do \ diff --git a/contrib/ntp/ntpd/invoke-ntp.conf.texi b/contrib/ntp/ntpd/invoke-ntp.conf.texi index d7a9d13a2d99..37427d679d45 100644 --- a/contrib/ntp/ntpd/invoke-ntp.conf.texi +++ b/contrib/ntp/ntpd/invoke-ntp.conf.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi) # -# It has been AutoGen-ed June 29, 2015 at 04:30:28 PM by AutoGen 5.18.5 +# It has been AutoGen-ed October 21, 2015 at 12:38:16 PM by AutoGen 5.18.5 # From the definitions ntp.conf.def # and the template file agtexi-file.tpl @end ignore @@ -1837,7 +1837,7 @@ re-associate accordingly. Some administrators prefer to avoid running @code{ntpd(1ntpdmdoc)} continuously and run either -@code{ntpdate(8)} +@code{sntp(1sntpmdoc)} or @code{ntpd(1ntpdmdoc)} @code{-q} @@ -1921,7 +1921,7 @@ peers remaining. This value defaults to 1, but can be changed to any number from 1 to 15. @item @code{minclock} @kbd{minclock} -The clustering algorithm repeatedly casts out outlyer +The clustering algorithm repeatedly casts out outlier associations until no more than @code{minclock} associations remain. @@ -2578,12 +2578,15 @@ pulses will not be suppressed. @item @code{rlimit} @code{[@code{memlock} @kbd{Nmegabytes} | @code{stacksize} @kbd{N4kPages} @code{filenum} @kbd{Nfiledescriptors}]} @table @asis @item @code{memlock} @kbd{Nmegabytes} -Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the @code{-i} option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non-Linux machines, and -1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory". @item @code{stacksize} @kbd{N4kPages} Specifies the maximum size of the process stack on systems with the @code{mlockall()} diff --git a/contrib/ntp/ntpd/invoke-ntp.keys.texi b/contrib/ntp/ntpd/invoke-ntp.keys.texi index 622c4ffe03c2..33fdb8938ed6 100644 --- a/contrib/ntp/ntpd/invoke-ntp.keys.texi +++ b/contrib/ntp/ntpd/invoke-ntp.keys.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi) # -# It has been AutoGen-ed June 29, 2015 at 04:30:31 PM by AutoGen 5.18.5 +# It has been AutoGen-ed October 21, 2015 at 12:38:19 PM by AutoGen 5.18.5 # From the definitions ntp.keys.def # and the template file agtexi-file.tpl @end ignore diff --git a/contrib/ntp/ntpd/invoke-ntpd.texi b/contrib/ntp/ntpd/invoke-ntpd.texi index 6936dda91f04..a781b26681f8 100644 --- a/contrib/ntp/ntpd/invoke-ntpd.texi +++ b/contrib/ntp/ntpd/invoke-ntpd.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi) # -# It has been AutoGen-ed June 29, 2015 at 04:30:33 PM by AutoGen 5.18.5 +# It has been AutoGen-ed October 21, 2015 at 12:38:21 PM by AutoGen 5.18.5 # From the definitions ntpd-opts.def # and the template file agtexi-cmd.tpl @end ignore @@ -142,7 +142,7 @@ with a status code of 0. @exampleindent 0 @example -ntpd - NTP daemon program - Ver. 4.2.8p3 +ntpd - NTP daemon program - Ver. 4.2.8p4 Usage: ntpd [ - [] | --[@{=| @}] ]... \ [ ... ] Flg Arg Option-Name Description diff --git a/contrib/ntp/ntpd/ntp.conf.5man b/contrib/ntp/ntpd/ntp.conf.5man index 14438bdc7da1..ee457df4c8bb 100644 --- a/contrib/ntp/ntpd/ntp.conf.5man +++ b/contrib/ntp/ntpd/ntp.conf.5man @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5man "29 Jun 2015" "4.2.8p3" "File Formats" +.TH ntp.conf 5man "21 Oct 2015" "4.2.8p4" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-R0aO7B/ag-30aG6B) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-9oaqYI/ag-OpaiXI) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:16 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:01 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME @@ -2080,7 +2080,7 @@ re-associate accordingly. Some administrators prefer to avoid running \fCntpd\f[]\fR(1ntpdmdoc)\f[] continuously and run either -\fCntpdate\f[]\fR(8)\f[] +\fCsntp\f[]\fR(1sntpmdoc)\f[] or \fCntpd\f[]\fR(1ntpdmdoc)\f[] \f\*[B-Font]\-q\f[] @@ -2170,7 +2170,7 @@ This value defaults to 1, but can be changed to any number from 1 to 15. .TP 7 .NOP \f\*[B-Font]minclock\f[] \f\*[I-Font]minclock\f[] -The clustering algorithm repeatedly casts out outlyer +The clustering algorithm repeatedly casts out outlier associations until no more than \f\*[B-Font]minclock\f[] associations remain. @@ -2897,12 +2897,15 @@ pulses will not be suppressed. .RS .TP 7 .NOP \f\*[B-Font]memlock\f[] \f\*[I-Font]Nmegabytes\f[] -Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the \f\*[B-Font]\-i\f[] option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non-Linux machines, and \-1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory". .TP 7 .NOP \f\*[B-Font]stacksize\f[] \f\*[I-Font]N4kPages\f[] Specifies the maximum size of the process stack on systems with the diff --git a/contrib/ntp/ntpd/ntp.conf.5mdoc b/contrib/ntp/ntpd/ntp.conf.5mdoc index 938acf6d6a13..a883aabaa8cb 100644 --- a/contrib/ntp/ntpd/ntp.conf.5mdoc +++ b/contrib/ntp/ntpd/ntp.conf.5mdoc @@ -1,9 +1,9 @@ -.Dd June 29 2015 +.Dd October 21 2015 .Dt NTP_CONF 5mdoc File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:36 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:24 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -1903,7 +1903,7 @@ re\-associate accordingly. Some administrators prefer to avoid running .Xr ntpd 1ntpdmdoc continuously and run either -.Xr ntpdate 8 +.Xr sntp 1sntpmdoc or .Xr ntpd 1ntpdmdoc .Fl q @@ -1995,7 +1995,7 @@ peers remaining. This value defaults to 1, but can be changed to any number from 1 to 15. .It Cm minclock Ar minclock -The clustering algorithm repeatedly casts out outlyer +The clustering algorithm repeatedly casts out outlier associations until no more than .Cm minclock associations remain. @@ -2725,12 +2725,15 @@ pulses will not be suppressed. .Xc .Bl -tag -width indent .It Cm memlock Ar Nmegabytes -Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the .Fl i option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non\-Linux machines, and \-1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory". .It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .Fn mlockall diff --git a/contrib/ntp/ntpd/ntp.conf.def b/contrib/ntp/ntpd/ntp.conf.def index 7e09c0306946..43835bc7632e 100644 --- a/contrib/ntp/ntpd/ntp.conf.def +++ b/contrib/ntp/ntpd/ntp.conf.def @@ -1905,7 +1905,7 @@ re-associate accordingly. Some administrators prefer to avoid running .Xr ntpd 1ntpdmdoc continuously and run either -.Xr ntpdate 8 +.Xr sntp 1sntpmdoc or .Xr ntpd 1ntpdmdoc .Fl q @@ -1997,7 +1997,7 @@ peers remaining. This value defaults to 1, but can be changed to any number from 1 to 15. .It Cm minclock Ar minclock -The clustering algorithm repeatedly casts out outlyer +The clustering algorithm repeatedly casts out outlier associations until no more than .Cm minclock associations remain. @@ -2727,12 +2727,15 @@ pulses will not be suppressed. .Xc .Bl -tag -width indent .It Cm memlock Ar Nmegabytes -Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the .Fl i option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non-Linux machines, and -1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory". .It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .Fn mlockall diff --git a/contrib/ntp/ntpd/ntp.conf.html b/contrib/ntp/ntpd/ntp.conf.html index ad643556ea1f..1f0c81908a05 100644 --- a/contrib/ntp/ntpd/ntp.conf.html +++ b/contrib/ntp/ntpd/ntp.conf.html @@ -33,7 +33,7 @@ Up: (dir)

This document describes the configuration file for the NTP Project's ntpd program. -

This document applies to version 4.2.8p3 of ntp.conf. +

This document applies to version 4.2.8p4 of ntp.conf.

Short Contents

@@ -1839,7 +1839,7 @@ re-associate accordingly.

Some administrators prefer to avoid running ntpd(1ntpdmdoc) continuously and run either -ntpdate(8) +sntp(1sntpmdoc) or ntpd(1ntpdmdoc) -q @@ -1922,7 +1922,7 @@ will be discarded if there are at least peers remaining. This value defaults to 1, but can be changed to any number from 1 to 15. -

minclock minclock
The clustering algorithm repeatedly casts out outlyer +
minclock minclock
The clustering algorithm repeatedly casts out outlier associations until no more than minclock associations remain. @@ -2546,12 +2546,15 @@ pulses will not be suppressed.

rlimit [memlock Nmegabytes | stacksize N4kPages filenum Nfiledescriptors]
-
memlock Nmegabytes
Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +
memlock Nmegabytes
Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the -i option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non-Linux machines, and -1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory".
stacksize N4kPages
Specifies the maximum size of the process stack on systems with the mlockall() function. diff --git a/contrib/ntp/ntpd/ntp.conf.man.in b/contrib/ntp/ntpd/ntp.conf.man.in index ef9e14dfe770..7c8a39f46588 100644 --- a/contrib/ntp/ntpd/ntp.conf.man.in +++ b/contrib/ntp/ntpd/ntp.conf.man.in @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntp.conf 5 "29 Jun 2015" "4.2.8p3" "File Formats" +.TH ntp.conf 5 "21 Oct 2015" "4.2.8p4" "File Formats" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-R0aO7B/ag-30aG6B) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-9oaqYI/ag-OpaiXI) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:16 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:01 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .SH NAME @@ -2080,7 +2080,7 @@ re-associate accordingly. Some administrators prefer to avoid running \fCntpd\f[]\fR(@NTPD_MS@)\f[] continuously and run either -\fCntpdate\f[]\fR(8)\f[] +\fCsntp\f[]\fR(@SNTP_MS@)\f[] or \fCntpd\f[]\fR(@NTPD_MS@)\f[] \f\*[B-Font]\-q\f[] @@ -2170,7 +2170,7 @@ This value defaults to 1, but can be changed to any number from 1 to 15. .TP 7 .NOP \f\*[B-Font]minclock\f[] \f\*[I-Font]minclock\f[] -The clustering algorithm repeatedly casts out outlyer +The clustering algorithm repeatedly casts out outlier associations until no more than \f\*[B-Font]minclock\f[] associations remain. @@ -2897,12 +2897,15 @@ pulses will not be suppressed. .RS .TP 7 .NOP \f\*[B-Font]memlock\f[] \f\*[I-Font]Nmegabytes\f[] -Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the \f\*[B-Font]\-i\f[] option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non-Linux machines, and \-1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory". .TP 7 .NOP \f\*[B-Font]stacksize\f[] \f\*[I-Font]N4kPages\f[] Specifies the maximum size of the process stack on systems with the diff --git a/contrib/ntp/ntpd/ntp.conf.mdoc.in b/contrib/ntp/ntpd/ntp.conf.mdoc.in index 93c638d6edff..613ee7a84aed 100644 --- a/contrib/ntp/ntpd/ntp.conf.mdoc.in +++ b/contrib/ntp/ntpd/ntp.conf.mdoc.in @@ -1,9 +1,9 @@ -.Dd June 29 2015 +.Dd October 21 2015 .Dt NTP_CONF 5 File Formats .Os .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:36 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:24 PM by AutoGen 5.18.5 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -1903,7 +1903,7 @@ re\-associate accordingly. Some administrators prefer to avoid running .Xr ntpd @NTPD_MS@ continuously and run either -.Xr ntpdate 8 +.Xr sntp @SNTP_MS@ or .Xr ntpd @NTPD_MS@ .Fl q @@ -1995,7 +1995,7 @@ peers remaining. This value defaults to 1, but can be changed to any number from 1 to 15. .It Cm minclock Ar minclock -The clustering algorithm repeatedly casts out outlyer +The clustering algorithm repeatedly casts out outlier associations until no more than .Cm minclock associations remain. @@ -2725,12 +2725,15 @@ pulses will not be suppressed. .Xc .Bl -tag -width indent .It Cm memlock Ar Nmegabytes -Specify the number of megabytes of memory that can be allocated. -Probably only available under Linux, this option is useful +Specify the number of megabytes of memory that should be +allocated and locked. +Probably only available under Linux, this option may be useful when dropping root (the .Fl i option). -The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. +The default is 32 megabytes on non\-Linux machines, and \-1 under Linux. +-1 means "do not lock the process into memory". +0 means "lock whatever memory the process wants into memory". .It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .Fn mlockall diff --git a/contrib/ntp/ntpd/ntp.keys.5man b/contrib/ntp/ntpd/ntp.keys.5man index 63d4553852ae..3e5cb54d91a6 100644 --- a/contrib/ntp/ntpd/ntp.keys.5man +++ b/contrib/ntp/ntpd/ntp.keys.5man @@ -1,8 +1,8 @@ -.TH ntp.keys 5man "29 Jun 2015" "4.2.8p3" "File Formats" +.TH ntp.keys 5man "21 Oct 2015" "4.2.8p4" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:21 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:08 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agman-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.5mdoc b/contrib/ntp/ntpd/ntp.keys.5mdoc index 47e5f81d258a..6355a39ca016 100644 --- a/contrib/ntp/ntpd/ntp.keys.5mdoc +++ b/contrib/ntp/ntpd/ntp.keys.5mdoc @@ -1,9 +1,9 @@ -.Dd June 29 2015 +.Dd October 21 2015 .Dt NTP_KEYS 5mdoc File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:39 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:28 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.html b/contrib/ntp/ntpd/ntp.keys.html index f096f63fc837..3671aaaace7a 100644 --- a/contrib/ntp/ntpd/ntp.keys.html +++ b/contrib/ntp/ntpd/ntp.keys.html @@ -33,7 +33,7 @@ Up: (dir)

This document describes the symmetric key file for the NTP Project's ntpd program. -

This document applies to version 4.2.8p3 of ntp.keys. +

This document applies to version 4.2.8p4 of ntp.keys.

Short Contents

diff --git a/contrib/ntp/ntpd/ntp.keys.man.in b/contrib/ntp/ntpd/ntp.keys.man.in index 1080b91bf0ed..bd64756a01c0 100644 --- a/contrib/ntp/ntpd/ntp.keys.man.in +++ b/contrib/ntp/ntpd/ntp.keys.man.in @@ -1,8 +1,8 @@ -.TH ntp.keys 5 "29 Jun 2015" "4.2.8p3" "File Formats" +.TH ntp.keys 5 "21 Oct 2015" "4.2.8p4" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:21 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:08 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agman-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp.keys.mdoc.in b/contrib/ntp/ntpd/ntp.keys.mdoc.in index 6bd1c0987c2c..6600d57d5ea4 100644 --- a/contrib/ntp/ntpd/ntp.keys.mdoc.in +++ b/contrib/ntp/ntpd/ntp.keys.mdoc.in @@ -1,9 +1,9 @@ -.Dd June 29 2015 +.Dd October 21 2015 .Dt NTP_KEYS 5 File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:39 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:28 PM by AutoGen 5.18.5 .\" From the definitions ntp.keys.def .\" and the template file agmdoc-file.tpl .Sh NAME diff --git a/contrib/ntp/ntpd/ntp_config.c b/contrib/ntp/ntpd/ntp_config.c index 300773240c74..1c754bd1613d 100644 --- a/contrib/ntp/ntpd/ntp_config.c +++ b/contrib/ntp/ntpd/ntp_config.c @@ -53,13 +53,21 @@ #include "ntp_parser.h" #include "ntpd-opts.h" +/* Bug 2817 */ +#if defined(HAVE_SYS_MMAN_H) +# include +#endif /* list of servers from command line for config_peers() */ int cmdline_server_count; char ** cmdline_servers; -/* set to zero if admin doesn't want memory locked */ -int do_memlock = 1; +/* Current state of memory locking: + * -1: default + * 0: memory locking disabled + * 1: Memory locking enabled + */ +int cur_memlock = -1; /* * "logconfig" building blocks @@ -1152,9 +1160,8 @@ create_address_node( { address_node *my_node; - NTP_REQUIRE(NULL != addr); - NTP_REQUIRE(AF_INET == type || - AF_INET6 == type || AF_UNSPEC == type); + REQUIRE(NULL != addr); + REQUIRE(AF_INET == type || AF_INET6 == type || AF_UNSPEC == type); my_node = emalloc_zero(sizeof(*my_node)); my_node->address = addr; my_node->type = (u_short)type; @@ -1170,7 +1177,7 @@ destroy_address_node( { if (NULL == my_node) return; - NTP_REQUIRE(NULL != my_node->address); + REQUIRE(NULL != my_node->address); free(my_node->address); free(my_node); @@ -1567,7 +1574,7 @@ create_nic_rule_node( { nic_rule_node *my_node; - NTP_REQUIRE(match_class != 0 || if_name != NULL); + REQUIRE(match_class != 0 || if_name != NULL); my_node = emalloc_zero(sizeof(*my_node)); my_node->match_class = match_class; @@ -1826,7 +1833,9 @@ config_auth( /* Crypto Command */ #ifdef AUTOKEY +# ifdef __GNUC__ item = -1; /* quiet warning */ +# endif my_val = HEAD_PFIFO(ptree->auth.crypto_cmd_list); for (; my_val != NULL; my_val = my_val->link) { switch (my_val->attr) { @@ -1979,7 +1988,9 @@ config_tos( int item; double val; +#ifdef __GNUC__ item = -1; /* quiet warning */ +#endif tos = HEAD_PFIFO(ptree->orphan_cmds); for (; tos != NULL; tos = tos->link) { val = tos->value.d; @@ -2610,18 +2621,36 @@ config_rlimit( break; case T_Memlock: - if (rlimit_av->value.i != 0) { + /* What if we HAVE_OPT(SAVECONFIGQUIT) ? */ + if (rlimit_av->value.i == -1) { +# if defined(HAVE_MLOCKALL) + if (cur_memlock != 0) { + if (-1 == munlockall()) { + msyslog(LOG_ERR, "munlockall() failed: %m"); + } + } + cur_memlock = 0; +# endif /* HAVE_MLOCKALL */ + } else if (rlimit_av->value.i >= 0) { #if defined(RLIMIT_MEMLOCK) +# if defined(HAVE_MLOCKALL) + if (cur_memlock != 1) { + if (-1 == mlockall(MCL_CURRENT|MCL_FUTURE)) { + msyslog(LOG_ERR, "mlockall() failed: %m"); + } + } +# endif /* HAVE_MLOCKALL */ ntp_rlimit(RLIMIT_MEMLOCK, (rlim_t)(rlimit_av->value.i * 1024 * 1024), 1024 * 1024, "MB"); + cur_memlock = 1; #else /* STDERR as well would be fine... */ msyslog(LOG_WARNING, "'rlimit memlock' specified but is not available on this system."); #endif /* RLIMIT_MEMLOCK */ } else { - do_memlock = 0; + msyslog(LOG_WARNING, "'rlimit memlock' value of %d is unexpected!", rlimit_av->value.i); } break; @@ -2662,7 +2691,9 @@ config_tinker( attr_val * tinker; int item; +#ifdef __GNUC__ item = -1; /* quiet warning */ +#endif tinker = HEAD_PFIFO(ptree->tinker); for (; tinker != NULL; tinker = tinker->link) { switch (tinker->attr) { @@ -2776,12 +2807,14 @@ config_nic_rules( switch (curr_node->match_class) { default: +#ifdef __GNUC__ /* * this assignment quiets a gcc "may be used * uninitialized" warning and is here for no * other reason. */ match_type = MATCH_ALL; +#endif INSIST(FALSE); break; @@ -2834,12 +2867,14 @@ config_nic_rules( switch (curr_node->action) { default: +#ifdef __GNUC__ /* * this assignment quiets a gcc "may be used * uninitialized" warning and is here for no * other reason. */ action = ACTION_LISTEN; +#endif INSIST(FALSE); break; @@ -4880,9 +4915,9 @@ getnetnum( enum gnn_type a_type /* ignored */ ) { - NTP_REQUIRE(AF_UNSPEC == AF(addr) || - AF_INET == AF(addr) || - AF_INET6 == AF(addr)); + REQUIRE(AF_UNSPEC == AF(addr) || + AF_INET == AF(addr) || + AF_INET6 == AF(addr)); if (!is_ip_address(num, AF(addr), addr)) return 0; diff --git a/contrib/ntp/ntpd/ntp_control.c b/contrib/ntp/ntpd/ntp_control.c index 43d2b275767f..77363117bda4 100644 --- a/contrib/ntp/ntpd/ntp_control.c +++ b/contrib/ntp/ntpd/ntp_control.c @@ -3,10 +3,6 @@ * traps. Provides service to ntpq and others. */ -/* - * $FreeBSD: head/contrib/ntp/ntpd/ntp_control.c 276071 2014-12-22 18:54:55Z delphij $ - */ - #ifdef HAVE_CONFIG_H # include #endif @@ -32,15 +28,11 @@ #include "ntp_leapsec.h" #include "ntp_md5.h" /* provides OpenSSL digest API */ #include "lib_strbuf.h" +#include #ifdef KERNEL_PLL # include "ntp_syscall.h" #endif -extern size_t remoteconfig_cmdlength( const char *src_buf, const char *src_end ); - -#ifndef MIN -#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) -#endif /* * Structure to hold request procedure information @@ -428,10 +420,10 @@ static const struct ctl_var sys_var[] = { { CS_TIMER_XMTS, RO, "timer_xmts" }, /* 87 */ { CS_FUZZ, RO, "fuzz" }, /* 88 */ { CS_WANDER_THRESH, RO, "clk_wander_threshold" }, /* 89 */ -#ifdef LEAP_SMEAR + { CS_LEAPSMEARINTV, RO, "leapsmearinterval" }, /* 90 */ { CS_LEAPSMEAROFFS, RO, "leapsmearoffset" }, /* 91 */ -#endif /* LEAP_SMEAR */ + #ifdef AUTOKEY { CS_FLAGS, RO, "flags" }, /* 1 + CS_MAX_NOAUTOKEY */ { CS_HOST, RO, "host" }, /* 2 + CS_MAX_NOAUTOKEY */ @@ -892,6 +884,28 @@ save_config( int restrict_mask ) { + /* block directory traversal by searching for characters that + * indicate directory components in a file path. + * + * Conceptually we should be searching for DIRSEP in filename, + * however Windows actually recognizes both forward and + * backslashes as equivalent directory separators at the API + * level. On POSIX systems we could allow '\\' but such + * filenames are tricky to manipulate from a shell, so just + * reject both types of slashes on all platforms. + */ + /* TALOS-CAN-0062: block directory traversal for VMS, too */ + static const char * illegal_in_filename = +#if defined(VMS) + ":[]" /* do not allow drive and path components here */ +#elif defined(SYS_WINNT) + ":\\/" /* path and drive separators */ +#else + "\\/" /* separator and critical char for POSIX */ +#endif + ; + + char reply[128]; #ifdef SAVECONFIG char filespec[128]; @@ -946,15 +960,9 @@ save_config( localtime(&now))) strlcpy(filename, filespec, sizeof(filename)); - /* - * Conceptually we should be searching for DIRSEP in filename, - * however Windows actually recognizes both forward and - * backslashes as equivalent directory separators at the API - * level. On POSIX systems we could allow '\\' but such - * filenames are tricky to manipulate from a shell, so just - * reject both types of slashes on all platforms. - */ - if (strchr(filename, '\\') || strchr(filename, '/')) { + /* block directory/drive traversal */ + /* TALOS-CAN-0062: block directory traversal for VMS, too */ + if (NULL != strpbrk(filename, illegal_in_filename)) { snprintf(reply, sizeof(reply), "saveconfig does not allow directory in filename"); ctl_putdata(reply, strlen(reply), 0); @@ -1409,7 +1417,7 @@ ctl_putstr( memcpy(buffer, tag, tl); cp = buffer + tl; if (len > 0) { - NTP_INSIST(tl + 3 + len <= sizeof(buffer)); + INSIST(tl + 3 + len <= sizeof(buffer)); *cp++ = '='; *cp++ = '"'; memcpy(cp, data, len); @@ -1444,7 +1452,7 @@ ctl_putunqstr( memcpy(buffer, tag, tl); cp = buffer + tl; if (len > 0) { - NTP_INSIST(tl + 1 + len <= sizeof(buffer)); + INSIST(tl + 1 + len <= sizeof(buffer)); *cp++ = '='; memcpy(cp, data, len); cp += len; @@ -1473,7 +1481,7 @@ ctl_putdblf( while (*cq != '\0') *cp++ = *cq++; *cp++ = '='; - NTP_INSIST((size_t)(cp - buffer) < sizeof(buffer)); + INSIST((size_t)(cp - buffer) < sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), use_f ? "%.*f" : "%.*g", precision, d); cp += strlen(cp); @@ -1499,7 +1507,7 @@ ctl_putuint( *cp++ = *cq++; *cp++ = '='; - NTP_INSIST((cp - buffer) < (int)sizeof(buffer)); + INSIST((cp - buffer) < (int)sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), "%lu", uval); cp += strlen(cp); ctl_putdata(buffer, (unsigned)( cp - buffer ), 0); @@ -1526,7 +1534,7 @@ ctl_putcal( pcal->hour, pcal->minute ); - NTP_INSIST(numch < sizeof(buffer)); + INSIST(numch < sizeof(buffer)); ctl_putdata(buffer, numch, 0); return; @@ -1557,7 +1565,7 @@ ctl_putfs( tm = gmtime(&fstamp); if (NULL == tm) return; - NTP_INSIST((cp - buffer) < (int)sizeof(buffer)); + INSIST((cp - buffer) < (int)sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), "%04d%02d%02d%02d%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min); @@ -1586,7 +1594,7 @@ ctl_puthex( *cp++ = *cq++; *cp++ = '='; - NTP_INSIST((cp - buffer) < (int)sizeof(buffer)); + INSIST((cp - buffer) < (int)sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), "0x%lx", uval); cp += strlen(cp); ctl_putdata(buffer,(unsigned)( cp - buffer ), 0); @@ -1612,7 +1620,7 @@ ctl_putint( *cp++ = *cq++; *cp++ = '='; - NTP_INSIST((cp - buffer) < (int)sizeof(buffer)); + INSIST((cp - buffer) < (int)sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), "%ld", ival); cp += strlen(cp); ctl_putdata(buffer, (unsigned)( cp - buffer ), 0); @@ -1638,7 +1646,7 @@ ctl_putts( *cp++ = *cq++; *cp++ = '='; - NTP_INSIST((size_t)(cp - buffer) < sizeof(buffer)); + INSIST((size_t)(cp - buffer) < sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), "0x%08x.%08x", (u_int)ts->l_ui, (u_int)ts->l_uf); cp += strlen(cp); @@ -1670,7 +1678,7 @@ ctl_putadr( cq = numtoa(addr32); else cq = stoa(addr); - NTP_INSIST((cp - buffer) < (int)sizeof(buffer)); + INSIST((cp - buffer) < (int)sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), "%s", cq); cp += strlen(cp); ctl_putdata(buffer, (unsigned)(cp - buffer), 0); @@ -1741,7 +1749,7 @@ ctl_putarray( if (i == 0) i = NTP_SHIFT; i--; - NTP_INSIST((cp - buffer) < (int)sizeof(buffer)); + INSIST((cp - buffer) < (int)sizeof(buffer)); snprintf(cp, sizeof(buffer) - (cp - buffer), " %.2f", arr[i] * 1e3); cp += strlen(cp); @@ -2410,6 +2418,9 @@ ctl_putsys( ntohl(hostval.tstamp)); break; #endif /* AUTOKEY */ + + default: + break; } } @@ -2933,7 +2944,6 @@ ctl_getitem( * Look for a first character match on the tag. If we find * one, see if it is a full match. */ - v = var_list; cp = reqpt; for (v = var_list; !(EOV & v->flags); v++) { if (!(PADDING & v->flags) && *cp == *(v->text)) { @@ -3115,7 +3125,7 @@ read_peervars(void) ctl_error(CERR_UNKNOWNVAR); return; } - NTP_INSIST(v->code < COUNTOF(wants)); + INSIST(v->code < COUNTOF(wants)); wants[v->code] = 1; gotvar = 1; } @@ -3158,19 +3168,19 @@ read_sysvars(void) gotvar = 0; while (NULL != (v = ctl_getitem(sys_var, &valuep))) { if (!(EOV & v->flags)) { - NTP_INSIST(v->code < wants_count); + INSIST(v->code < wants_count); wants[v->code] = 1; gotvar = 1; } else { v = ctl_getitem(ext_sys_var, &valuep); - NTP_INSIST(v != NULL); + INSIST(v != NULL); if (EOV & v->flags) { ctl_error(CERR_UNKNOWNVAR); free(wants); return; } n = v->code + CS_MAXCODE + 1; - NTP_INSIST(n < wants_count); + INSIST(n < wants_count); wants[n] = 1; gotvar = 1; } @@ -4404,7 +4414,7 @@ read_clockstatus( gotvar = TRUE; } else { v = ctl_getitem(kv, &valuep); - NTP_INSIST(NULL != v); + INSIST(NULL != v); if (EOV & v->flags) { ctl_error(CERR_UNKNOWNVAR); free(wants); @@ -4800,7 +4810,7 @@ report_event( for (i = 1; i <= CS_VARLIST; i++) ctl_putsys(i); } else { - NTP_INSIST(peer != NULL); + INSIST(peer != NULL); rpkt.associd = htons(peer->associd); rpkt.status = htons(ctlpeerstatus(peer)); @@ -4905,7 +4915,7 @@ count_var( while (!(EOV & (k++)->flags)) c++; - NTP_ENSURE(c <= USHRT_MAX); + ENSURE(c <= USHRT_MAX); return (u_short)c; } diff --git a/contrib/ntp/ntpd/ntp_crypto.c b/contrib/ntp/ntpd/ntp_crypto.c index 2be501d15695..376b5b50514e 100644 --- a/contrib/ntp/ntpd/ntp_crypto.c +++ b/contrib/ntp/ntpd/ntp_crypto.c @@ -202,6 +202,7 @@ static void cert_free (struct cert_info *); static struct pkey_info *crypto_key (char *, char *, sockaddr_u *); static void bighash (BIGNUM *, BIGNUM *); static struct cert_info *crypto_cert (char *); +static u_int exten_payload_size(const struct exten *); #ifdef SYS_WINNT int @@ -380,7 +381,7 @@ make_keylist( EVP_SignUpdate(&ctx, (u_char *)vp, 12); EVP_SignUpdate(&ctx, vp->ptr, sizeof(struct autokey)); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); peer->flags |= FLAG_ASSOC; } @@ -419,7 +420,7 @@ crypto_recv( struct autokey *ap, *bp; /* autokey pointer */ struct exten *ep, *fp; /* extension pointers */ struct cert_info *xinfo; /* certificate info pointer */ - int has_mac; /* length of MAC field */ + int macbytes; /* length of MAC field, signed by intention */ int authlen; /* offset of MAC field */ associd_t associd; /* association ID */ tstamp_t fstamp = 0; /* filestamp */ @@ -446,7 +447,11 @@ crypto_recv( */ authlen = LEN_PKT_NOMAC; hismode = (int)PKT_MODE((&rbufp->recv_pkt)->li_vn_mode); - while ((has_mac = rbufp->recv_length - authlen) > (int)MAX_MAC_LEN) { + while ((macbytes = rbufp->recv_length - authlen) > (int)MAX_MAC_LEN) { + /* We can be reasonably sure that we can read at least + * the opcode and the size field here. More stringent + * checks follow up shortly. + */ pkt = (u_int32 *)&rbufp->recv_pkt + authlen / 4; ep = (struct exten *)pkt; code = ntohl(ep->opcode) & 0xffff0000; @@ -467,6 +472,18 @@ crypto_recv( code |= CRYPTO_ERROR; } + /* Check if the declared size fits into the remaining + * buffer. + */ + if (len > macbytes) { + DPRINTF(1, ("crypto_recv: possible attack detected, associd %d\n", + associd)); + return XEVNT_LEN; + } + + /* Check if the paylod of the extension fits into the + * declared frame. + */ if (len >= VALUE_LEN) { fstamp = ntohl(ep->fstamp); vallen = ntohl(ep->vallen); @@ -508,6 +525,7 @@ crypto_recv( rval = XEVNT_ERR; break; } + free(peer->cmmd); /* will be set again! */ } fp = emalloc(len); memcpy(fp, ep, len); @@ -1153,9 +1171,8 @@ crypto_xmit( * choice. */ case CRYPTO_CERT | CRYPTO_RESP: - vallen = ntohl(ep->vallen); /* Must be <64k */ - if (vallen == 0 || vallen > MAXHOSTNAME || - len - VALUE_LEN < vallen) { + vallen = exten_payload_size(ep); /* Must be <64k */ + if (vallen == 0 || vallen >= sizeof(certname) ) { rval = XEVNT_LEN; break; } @@ -1591,7 +1608,7 @@ crypto_encrypt( EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, vallen); if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) { - NTP_INSIST(vallen <= sign_siglen); + INSIST(vallen <= sign_siglen); vp->siglen = htonl(vallen); } return (XEVNT_OK); @@ -1770,7 +1787,7 @@ crypto_send( if (j * 4 < siglen) ep->pkt[i + j++] = 0; memcpy(&ep->pkt[i], vp->sig, siglen); - i += j; + /* i += j; */ /* We don't use i after this */ } opcode = ntohl(ep->opcode); ep->opcode = htonl((opcode & 0xffff0000) | len); @@ -1825,7 +1842,7 @@ crypto_update(void) EVP_SignUpdate(&ctx, (u_char *)&pubkey, 12); EVP_SignUpdate(&ctx, pubkey.ptr, ntohl(pubkey.vallen)); if (EVP_SignFinal(&ctx, pubkey.sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); pubkey.siglen = htonl(len); } } @@ -1846,7 +1863,7 @@ crypto_update(void) EVP_SignUpdate(&ctx, cp->cert.ptr, ntohl(cp->cert.vallen)); if (EVP_SignFinal(&ctx, cp->cert.sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); cp->cert.siglen = htonl(len); } } @@ -1896,7 +1913,7 @@ crypto_update(void) EVP_SignUpdate(&ctx, (u_char *)&tai_leap, 12); EVP_SignUpdate(&ctx, tai_leap.ptr, len); if (EVP_SignFinal(&ctx, tai_leap.sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); tai_leap.siglen = htonl(len); } crypto_flags |= CRYPTO_FLAG_TAI; @@ -1997,9 +2014,9 @@ asn_to_calendar ( * 100. Dontcha love ASN.1? Better than MIL-188. */ len = asn1time->length; - NTP_REQUIRE(len < sizeof(v)); + REQUIRE(len < sizeof(v)); (void)strncpy(v, (char *)(asn1time->data), len); - NTP_REQUIRE(len >= 13); + REQUIRE(len >= 13); temp = strtoul(v+len-3, NULL, 10); pjd->second = temp; v[len-3] = '\0'; @@ -2169,7 +2186,7 @@ crypto_alice( EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); } return (XEVNT_OK); @@ -2197,8 +2214,7 @@ crypto_bob( tstamp_t tstamp; /* NTP timestamp */ BIGNUM *bn, *bk, *r; u_char *ptr; - u_int len; /* extension field length */ - u_int vallen = 0; /* value length */ + u_int len; /* extension field value length */ /* * If the IFF parameters are not valid, something awful @@ -2213,11 +2229,10 @@ crypto_bob( /* * Extract r from the challenge. */ - vallen = ntohl(ep->vallen); - len = ntohl(ep->opcode) & 0x0000ffff; - if (vallen == 0 || len < VALUE_LEN || len - VALUE_LEN < vallen) - return XEVNT_LEN; - if ((r = BN_bin2bn((u_char *)ep->pkt, vallen, NULL)) == NULL) { + len = exten_payload_size(ep); + if (len == 0 || len > MAX_VALLEN) + return (XEVNT_LEN); + if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { msyslog(LOG_ERR, "crypto_bob: %s", ERR_error_string(ERR_get_error(), NULL)); return (XEVNT_ERR); @@ -2229,7 +2244,7 @@ crypto_bob( */ bctx = BN_CTX_new(); bk = BN_new(); bn = BN_new(); sdsa = DSA_SIG_new(); - BN_rand(bk, vallen * 8, -1, 1); /* k */ + BN_rand(bk, len * 8, -1, 1); /* k */ BN_mod_mul(bn, dsa->priv_key, r, dsa->q, bctx); /* b r mod q */ BN_add(bn, bn, bk); BN_mod(bn, bn, dsa->q, bctx); /* k + b r mod q */ @@ -2248,16 +2263,16 @@ crypto_bob( * Encode the values in ASN.1 and sign. The filestamp is from * the local file. */ - vallen = i2d_DSA_SIG(sdsa, NULL); - if (vallen == 0) { + len = i2d_DSA_SIG(sdsa, NULL); + if (len == 0) { msyslog(LOG_ERR, "crypto_bob: %s", ERR_error_string(ERR_get_error(), NULL)); DSA_SIG_free(sdsa); return (XEVNT_ERR); } - if (vallen > MAX_VALLEN) { - msyslog(LOG_ERR, "crypto_bob: signature is too big: %d", - vallen); + if (len > MAX_VALLEN) { + msyslog(LOG_ERR, "crypto_bob: signature is too big: %u", + len); DSA_SIG_free(sdsa); return (XEVNT_LEN); } @@ -2265,8 +2280,8 @@ crypto_bob( tstamp = crypto_time(); vp->tstamp = htonl(tstamp); vp->fstamp = htonl(iffkey_info->fstamp); - vp->vallen = htonl(vallen); - ptr = emalloc(vallen); + vp->vallen = htonl(len); + ptr = emalloc(len); vp->ptr = ptr; i2d_DSA_SIG(sdsa, &ptr); DSA_SIG_free(sdsa); @@ -2277,10 +2292,10 @@ crypto_bob( vp->sig = emalloc(sign_siglen); EVP_SignInit(&ctx, sign_digest); EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); - EVP_SignUpdate(&ctx, vp->ptr, vallen); - if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) { - NTP_INSIST(vallen <= sign_siglen); - vp->siglen = htonl(vallen); + EVP_SignUpdate(&ctx, vp->ptr, len); + if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { + INSIST(len <= sign_siglen); + vp->siglen = htonl(len); } return (XEVNT_OK); } @@ -2486,7 +2501,7 @@ crypto_alice2( EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); } return (XEVNT_OK); @@ -2530,7 +2545,9 @@ crypto_bob2( /* * Extract r from the challenge. */ - len = ntohl(ep->vallen); + len = exten_payload_size(ep); + if (len == 0 || len > MAX_VALLEN) + return (XEVNT_LEN); if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { msyslog(LOG_ERR, "crypto_bob2: %s", ERR_error_string(ERR_get_error(), NULL)); @@ -2586,7 +2603,7 @@ crypto_bob2( EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); } return (XEVNT_OK); @@ -2817,7 +2834,7 @@ crypto_alice3( EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); } return (XEVNT_OK); @@ -2859,7 +2876,9 @@ crypto_bob3( /* * Extract r from the challenge. */ - len = ntohl(ep->vallen); + len = exten_payload_size(ep); + if (len == 0 || len > MAX_VALLEN) + return (XEVNT_LEN); if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { msyslog(LOG_ERR, "crypto_bob3: %s", ERR_error_string(ERR_get_error(), NULL)); @@ -2919,7 +2938,7 @@ crypto_bob3( EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); } return (XEVNT_OK); @@ -3078,8 +3097,11 @@ cert_sign( if (tstamp == 0) return (XEVNT_TSP); + len = exten_payload_size(ep); + if (len == 0 || len > MAX_VALLEN) + return (XEVNT_LEN); cptr = (void *)ep->pkt; - if ((req = d2i_X509(NULL, &cptr, ntohl(ep->vallen))) == NULL) { + if ((req = d2i_X509(NULL, &cptr, len)) == NULL) { msyslog(LOG_ERR, "cert_sign: %s", ERR_error_string(ERR_get_error(), NULL)); return (XEVNT_CRT); @@ -3158,7 +3180,7 @@ cert_sign( EVP_SignUpdate(&ctx, (u_char *)vp, 12); EVP_SignUpdate(&ctx, vp->ptr, len); if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) { - NTP_INSIST(len <= sign_siglen); + INSIST(len <= sign_siglen); vp->siglen = htonl(len); } } @@ -4028,6 +4050,36 @@ crypto_config( break; } } + +/* + * Get the payload size (internal value length) of an extension packet. + * If the inner value size does not match the outer packet size (that + * is, the value would end behind the frame given by the opcode/size + * field) the function will effectively return UINT_MAX. If the frame is + * too short to hold a variable-sized value, the return value is zero. + */ +static u_int +exten_payload_size( + const struct exten * ep) +{ + typedef const u_char *BPTR; + + size_t extn_size; + size_t data_size; + size_t head_size; + + data_size = 0; + if (NULL != ep) { + head_size = (BPTR)(&ep->vallen + 1) - (BPTR)ep; + extn_size = (uint16_t)(ntohl(ep->opcode) & 0x0000ffff); + if (extn_size >= head_size) { + data_size = (uint32_t)ntohl(ep->vallen); + if (data_size > extn_size - head_size) + data_size = ~(size_t)0u; + } + } + return (u_int)data_size; +} # else /* !AUTOKEY follows */ int ntp_crypto_bs_pubkey; # endif /* !AUTOKEY */ diff --git a/contrib/ntp/ntpd/ntp_io.c b/contrib/ntp/ntpd/ntp_io.c index 2b5a003e0061..5fc6ed52acae 100644 --- a/contrib/ntp/ntpd/ntp_io.c +++ b/contrib/ntp/ntpd/ntp_io.c @@ -216,7 +216,7 @@ static int is_wildcard_addr (const sockaddr_u *); * Multicast functions */ static isc_boolean_t addr_ismulticast (sockaddr_u *); -static isc_boolean_t is_not_bindable (sockaddr_u *, +static isc_boolean_t is_anycast (sockaddr_u *, const char *); /* @@ -371,7 +371,7 @@ maintain_activefds( maxactivefd = i; break; } - NTP_INSIST(fd != maxactivefd); + INSIST(fd != maxactivefd); } } } @@ -687,8 +687,8 @@ addr_samesubnet( const u_int32 * pm; size_t loops; - NTP_REQUIRE(AF(a) == AF(a_mask)); - NTP_REQUIRE(AF(b) == AF(b_mask)); + REQUIRE(AF(a) == AF(a_mask)); + REQUIRE(AF(b) == AF(b_mask)); /* * With address and mask families verified to match, comparing * the masks also validates the address's families match. @@ -735,8 +735,8 @@ is_ip_address( char tmpbuf[128]; char *pch; - NTP_REQUIRE(host != NULL); - NTP_REQUIRE(addr != NULL); + REQUIRE(host != NULL); + REQUIRE(addr != NULL); ZERO_SOCK(addr); @@ -1250,15 +1250,15 @@ add_nic_rule( rule->action = action; if (MATCH_IFNAME == match_type) { - NTP_REQUIRE(NULL != if_name); + REQUIRE(NULL != if_name); rule->if_name = estrdup(if_name); } else if (MATCH_IFADDR == match_type) { - NTP_REQUIRE(NULL != if_name); + REQUIRE(NULL != if_name); /* set rule->addr */ is_ip = is_ip_address(if_name, AF_UNSPEC, &rule->addr); - NTP_REQUIRE(is_ip); + REQUIRE(is_ip); } else - NTP_REQUIRE(NULL == if_name); + REQUIRE(NULL == if_name); LINK_SLIST(nic_rule_list, rule, next); } @@ -1278,7 +1278,7 @@ action_text( t = "ERROR"; /* quiet uninit warning */ DPRINTF(1, ("fatal: unknown nic_rule_action %d\n", action)); - NTP_ENSURE(0); + ENSURE(0); break; case ACTION_LISTEN: @@ -1666,11 +1666,9 @@ check_flags6( u_int32 flags6 ) { -#if defined(INCLUDE_IPV6_SUPPORT) && defined(SIOCGIFAFLAG_IN6) && \ - (defined(IN6_IFF_ANYCAST) || defined(IN6_IFF_NOTREADY)) +#if defined(INCLUDE_IPV6_SUPPORT) && defined(SIOCGIFAFLAG_IN6) struct in6_ifreq ifr6; int fd; - u_int32 exclude = 0; if (psau->sa.sa_family != AF_INET6) return ISC_FALSE; @@ -1684,21 +1682,14 @@ check_flags6( return ISC_FALSE; } close(fd); - flags6 = ifr6.ifr_ifru.ifru_flags6; -#if defined(IN6_IFF_ANYCAST) - exclude |= IN6_IFF_ANYCAST; -#endif /* !IN6_IFF_ANYCAST */ -#if defined(IN6_IFF_NOTREADY) - exclude |= IN6_IFF_NOTREADY; -#endif /* !IN6_IFF_NOTREADY */ - if ((flags6 & exclude) != 0) + if ((ifr6.ifr_ifru.ifru_flags6 & flags6) != 0) return ISC_TRUE; -#endif /* INCLUDE_IPV6_SUPPORT && SIOCGIFAFLAG_IN6 && (IN6_IFF_ANYCAST && IN6_IFF_NOTREADY) */ +#endif /* INCLUDE_IPV6_SUPPORT && SIOCGIFAFLAG_IN6 */ return ISC_FALSE; } static isc_boolean_t -is_not_bindable( +is_anycast( sockaddr_u *psau, const char *name ) @@ -1859,7 +1850,7 @@ update_interfaces( if (is_wildcard_addr(&enumep.sin)) continue; - if (is_not_bindable(&enumep.sin, isc_if.name)) + if (is_anycast(&enumep.sin, isc_if.name)) continue; /* @@ -2031,6 +2022,7 @@ update_interfaces( if (sys_bclient) io_setbclient(); +#ifdef MCAST /* * Check multicast interfaces and try to join multicast groups if * not joined yet. @@ -2056,6 +2048,7 @@ update_interfaces( } } } +#endif /* MCAST */ return new_interface_found; } @@ -2406,7 +2399,7 @@ enable_multicast_if( u_int off6 = 0; #endif - NTP_REQUIRE(AF(maddr) == AF(&iface->sin)); + REQUIRE(AF(maddr) == AF(&iface->sin)); switch (AF(&iface->sin)) { @@ -2466,9 +2459,9 @@ socket_multicast_enable( ) { struct ip_mreq mreq; -#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT +# ifdef INCLUDE_IPV6_MULTICAST_SUPPORT struct ipv6_mreq mreq6; -#endif +# endif switch (AF(maddr)) { case AF_INET: @@ -2495,7 +2488,7 @@ socket_multicast_enable( break; case AF_INET6: -#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT +# ifdef INCLUDE_IPV6_MULTICAST_SUPPORT /* * Enable reception of multicast packets. * If the address is link-local we can get the @@ -2519,9 +2512,9 @@ socket_multicast_enable( DPRINTF(4, ("Added IPv6 multicast group on socket %d, addr %s for interface %u (%s)\n", iface->fd, stoa(&iface->sin), mreq6.ipv6mr_interface, stoa(maddr))); -#else +# else return ISC_FALSE; -#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */ +# endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */ } iface->flags |= INT_MCASTOPEN; iface->num_mcast++; @@ -2543,9 +2536,9 @@ socket_multicast_disable( sockaddr_u * maddr ) { -#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT +# ifdef INCLUDE_IPV6_MULTICAST_SUPPORT struct ipv6_mreq mreq6; -#endif +# endif struct ip_mreq mreq; ZERO(mreq); @@ -2574,7 +2567,7 @@ socket_multicast_disable( } break; case AF_INET6: -#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT +# ifdef INCLUDE_IPV6_MULTICAST_SUPPORT /* * Disable reception of multicast packets * If the address is link-local we can get the @@ -2596,9 +2589,9 @@ socket_multicast_disable( return ISC_FALSE; } break; -#else +# else return ISC_FALSE; -#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */ +# endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */ } iface->num_mcast--; @@ -2638,7 +2631,7 @@ io_setbclient(void) continue; /* Only IPv4 addresses are valid for broadcast */ - NTP_REQUIRE(IS_IPV4(&interf->sin)); + REQUIRE(IS_IPV4(&interf->sin)); /* Do we already have the broadcast address open? */ if (interf->flags & INT_BCASTOPEN) { @@ -2744,7 +2737,7 @@ io_multicast_add( return; } -#ifndef MULTICAST_NONEWSOCKET +# ifndef MULTICAST_NONEWSOCKET ep = new_interface(NULL); /* @@ -2794,7 +2787,7 @@ io_multicast_add( } { /* in place of the { following for in #else clause */ one_ep = ep; -#else /* MULTICAST_NONEWSOCKET follows */ +# else /* MULTICAST_NONEWSOCKET follows */ /* * For the case where we can't use a separate socket (Windows) * join each applicable endpoint socket to the group address. @@ -2809,7 +2802,7 @@ io_multicast_add( (INT_LOOPBACK | INT_WILDCARD) & ep->flags) continue; one_ep = ep; -#endif /* MULTICAST_NONEWSOCKET */ +# endif /* MULTICAST_NONEWSOCKET */ if (socket_multicast_enable(ep, addr)) msyslog(LOG_INFO, "Joined %s socket to multicast group %s", @@ -3249,7 +3242,7 @@ read_refclock_packet( l_fp ts ) { - int i; + u_int read_count; int buflen; int saved_errno; int consumed; @@ -3268,12 +3261,15 @@ read_refclock_packet( return (buflen); } - i = (rp->datalen == 0 - || rp->datalen > (int)sizeof(rb->recv_space)) - ? (int)sizeof(rb->recv_space) - : rp->datalen; + /* TALOS-CAN-0064: avoid signed/unsigned clashes that can lead + * to buffer overrun and memory corruption + */ + if (rp->datalen <= 0 || rp->datalen > sizeof(rb->recv_space)) + read_count = sizeof(rb->recv_space); + else + read_count = (u_int)rp->datalen; do { - buflen = read(fd, (char *)&rb->recv_space, (u_int)i); + buflen = read(fd, (char *)&rb->recv_space, read_count); } while (buflen < 0 && EINTR == errno); if (buflen <= 0) { @@ -4088,7 +4084,7 @@ calc_addr_distance( int a1_greater; int i; - NTP_REQUIRE(AF(a1) == AF(a2)); + REQUIRE(AF(a1) == AF(a2)); ZERO_SOCK(dist); AF(dist) = AF(a1); @@ -4139,7 +4135,7 @@ cmp_addr_distance( { int i; - NTP_REQUIRE(AF(d1) == AF(d2)); + REQUIRE(AF(d1) == AF(d2)); if (IS_IPV4(d1)) { if (SRCADR(d1) < SRCADR(d2)) @@ -4631,10 +4627,15 @@ process_routing_msgs(struct asyncio_reader *reader) cnt = read(reader->fd, buffer, sizeof(buffer)); if (cnt < 0) { - msyslog(LOG_ERR, - "i/o error on routing socket %m - disabling"); - remove_asyncio_reader(reader); - delete_asyncio_reader(reader); + if (errno == ENOBUFS) { + msyslog(LOG_ERR, + "routing socket reports: %m"); + } else { + msyslog(LOG_ERR, + "routing socket reports: %m - disabling"); + remove_asyncio_reader(reader); + delete_asyncio_reader(reader); + } return; } diff --git a/contrib/ntp/ntpd/ntp_loopfilter.c b/contrib/ntp/ntpd/ntp_loopfilter.c index cb183b934fc8..42c30de5679f 100644 --- a/contrib/ntp/ntpd/ntp_loopfilter.c +++ b/contrib/ntp/ntpd/ntp_loopfilter.c @@ -577,7 +577,7 @@ local_clock( switch (state) { /* - * In SYNC state we ignore the first outlyer and switch + * In SYNC state we ignore the first outlier and switch * to SPIK state. */ case EVNT_SYNC: @@ -588,8 +588,8 @@ local_clock( return (0); /* - * In FREQ state we ignore outlyers and inlyers. At the - * first outlyer after the stepout threshold, compute + * In FREQ state we ignore outliers and inlyers. At the + * first outlier after the stepout threshold, compute * the apparent frequency correction and step the phase. */ case EVNT_FREQ: @@ -601,7 +601,7 @@ local_clock( /* fall through to EVNT_SPIK */ /* - * In SPIK state we ignore succeeding outlyers until + * In SPIK state we ignore succeeding outliers until * either an inlyer is found or the stepout threshold is * exceeded. */ diff --git a/contrib/ntp/ntpd/ntp_monitor.c b/contrib/ntp/ntpd/ntp_monitor.c index 02fd757307da..a07a1aaef196 100644 --- a/contrib/ntp/ntpd/ntp_monitor.c +++ b/contrib/ntp/ntpd/ntp_monitor.c @@ -133,7 +133,7 @@ remove_from_hash( hash = MON_HASH(&mon->rmtadr); UNLINK_SLIST(punlinked, mon_hash[hash], mon, hash_next, mon_entry); - NTP_ENSURE(punlinked == mon); + ENSURE(punlinked == mon); } @@ -325,6 +325,8 @@ ntp_monitor( int leak; /* new headway */ int limit; /* average threshold */ + REQUIRE(rbufp != NULL); + if (mon_enabled == MON_OFF) return ~(RES_LIMITED | RES_KOD) & flags; @@ -466,6 +468,8 @@ ntp_monitor( } } + INSIST(mon != NULL); + /* * Got one, initialize it */ diff --git a/contrib/ntp/ntpd/ntp_parser.c b/contrib/ntp/ntpd/ntp_parser.c index d76ac3374386..6235033feffb 100644 --- a/contrib/ntp/ntpd/ntp_parser.c +++ b/contrib/ntp/ntpd/ntp_parser.c @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 3.0.2. */ /* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.7.12-4996" +#define YYBISON_VERSION "3.0.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -62,8 +62,7 @@ /* Copy the first part of user declarations. */ -/* Line 371 of yacc.c */ -#line 11 "../../ntpd/ntp_parser.y" +#line 11 "../../ntpd/ntp_parser.y" /* yacc.c:339 */ #ifdef HAVE_CONFIG_H # include @@ -97,14 +96,13 @@ # define ONLY_SIM(a) NULL #endif -/* Line 371 of yacc.c */ -#line 102 "ntp_parser.c" +#line 100 "../../ntpd/ntp_parser.c" /* yacc.c:339 */ -# ifndef YY_NULL +# ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# define YY_NULLPTR nullptr # else -# define YY_NULL 0 +# define YY_NULLPTR 0 # endif # endif @@ -118,9 +116,9 @@ /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ -#ifndef YY_YY_NTP_PARSER_H_INCLUDED -# define YY_YY_NTP_PARSER_H_INCLUDED -/* Enabling traces. */ +#ifndef YY_YY__NTPD_NTP_PARSER_H_INCLUDED +# define YY_YY__NTPD_NTP_PARSER_H_INCLUDED +/* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif @@ -128,204 +126,203 @@ extern int yydebug; #endif -/* Tokens. */ +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_Abbrev = 258, - T_Age = 259, - T_All = 260, - T_Allan = 261, - T_Allpeers = 262, - T_Auth = 263, - T_Autokey = 264, - T_Automax = 265, - T_Average = 266, - T_Bclient = 267, - T_Beacon = 268, - T_Broadcast = 269, - T_Broadcastclient = 270, - T_Broadcastdelay = 271, - T_Burst = 272, - T_Calibrate = 273, - T_Ceiling = 274, - T_Clockstats = 275, - T_Cohort = 276, - T_ControlKey = 277, - T_Crypto = 278, - T_Cryptostats = 279, - T_Ctl = 280, - T_Day = 281, - T_Default = 282, - T_Digest = 283, - T_Disable = 284, - T_Discard = 285, - T_Dispersion = 286, - T_Double = 287, - T_Driftfile = 288, - T_Drop = 289, - T_Dscp = 290, - T_Ellipsis = 291, - T_Enable = 292, - T_End = 293, - T_False = 294, - T_File = 295, - T_Filegen = 296, - T_Filenum = 297, - T_Flag1 = 298, - T_Flag2 = 299, - T_Flag3 = 300, - T_Flag4 = 301, - T_Flake = 302, - T_Floor = 303, - T_Freq = 304, - T_Fudge = 305, - T_Host = 306, - T_Huffpuff = 307, - T_Iburst = 308, - T_Ident = 309, - T_Ignore = 310, - T_Incalloc = 311, - T_Incmem = 312, - T_Initalloc = 313, - T_Initmem = 314, - T_Includefile = 315, - T_Integer = 316, - T_Interface = 317, - T_Intrange = 318, - T_Io = 319, - T_Ipv4 = 320, - T_Ipv4_flag = 321, - T_Ipv6 = 322, - T_Ipv6_flag = 323, - T_Kernel = 324, - T_Key = 325, - T_Keys = 326, - T_Keysdir = 327, - T_Kod = 328, - T_Mssntp = 329, - T_Leapfile = 330, - T_Leapsmearinterval = 331, - T_Limited = 332, - T_Link = 333, - T_Listen = 334, - T_Logconfig = 335, - T_Logfile = 336, - T_Loopstats = 337, - T_Lowpriotrap = 338, - T_Manycastclient = 339, - T_Manycastserver = 340, - T_Mask = 341, - T_Maxage = 342, - T_Maxclock = 343, - T_Maxdepth = 344, - T_Maxdist = 345, - T_Maxmem = 346, - T_Maxpoll = 347, - T_Mdnstries = 348, - T_Mem = 349, - T_Memlock = 350, - T_Minclock = 351, - T_Mindepth = 352, - T_Mindist = 353, - T_Minimum = 354, - T_Minpoll = 355, - T_Minsane = 356, - T_Mode = 357, - T_Mode7 = 358, - T_Monitor = 359, - T_Month = 360, - T_Mru = 361, - T_Multicastclient = 362, - T_Nic = 363, - T_Nolink = 364, - T_Nomodify = 365, - T_Nomrulist = 366, - T_None = 367, - T_Nonvolatile = 368, - T_Nopeer = 369, - T_Noquery = 370, - T_Noselect = 371, - T_Noserve = 372, - T_Notrap = 373, - T_Notrust = 374, - T_Ntp = 375, - T_Ntpport = 376, - T_NtpSignDsocket = 377, - T_Orphan = 378, - T_Orphanwait = 379, - T_Panic = 380, - T_Peer = 381, - T_Peerstats = 382, - T_Phone = 383, - T_Pid = 384, - T_Pidfile = 385, - T_Pool = 386, - T_Port = 387, - T_Preempt = 388, - T_Prefer = 389, - T_Protostats = 390, - T_Pw = 391, - T_Randfile = 392, - T_Rawstats = 393, - T_Refid = 394, - T_Requestkey = 395, - T_Reset = 396, - T_Restrict = 397, - T_Revoke = 398, - T_Rlimit = 399, - T_Saveconfigdir = 400, - T_Server = 401, - T_Setvar = 402, - T_Source = 403, - T_Stacksize = 404, - T_Statistics = 405, - T_Stats = 406, - T_Statsdir = 407, - T_Step = 408, - T_Stepback = 409, - T_Stepfwd = 410, - T_Stepout = 411, - T_Stratum = 412, - T_String = 413, - T_Sys = 414, - T_Sysstats = 415, - T_Tick = 416, - T_Time1 = 417, - T_Time2 = 418, - T_Timer = 419, - T_Timingstats = 420, - T_Tinker = 421, - T_Tos = 422, - T_Trap = 423, - T_True = 424, - T_Trustedkey = 425, - T_Ttl = 426, - T_Type = 427, - T_U_int = 428, - T_Unconfig = 429, - T_Unpeer = 430, - T_Version = 431, - T_WanderThreshold = 432, - T_Week = 433, - T_Wildcard = 434, - T_Xleave = 435, - T_Year = 436, - T_Flag = 437, - T_EOC = 438, - T_Simulate = 439, - T_Beep_Delay = 440, - T_Sim_Duration = 441, - T_Server_Offset = 442, - T_Duration = 443, - T_Freq_Offset = 444, - T_Wander = 445, - T_Jitter = 446, - T_Prop_Delay = 447, - T_Proc_Delay = 448 - }; + enum yytokentype + { + T_Abbrev = 258, + T_Age = 259, + T_All = 260, + T_Allan = 261, + T_Allpeers = 262, + T_Auth = 263, + T_Autokey = 264, + T_Automax = 265, + T_Average = 266, + T_Bclient = 267, + T_Beacon = 268, + T_Broadcast = 269, + T_Broadcastclient = 270, + T_Broadcastdelay = 271, + T_Burst = 272, + T_Calibrate = 273, + T_Ceiling = 274, + T_Clockstats = 275, + T_Cohort = 276, + T_ControlKey = 277, + T_Crypto = 278, + T_Cryptostats = 279, + T_Ctl = 280, + T_Day = 281, + T_Default = 282, + T_Digest = 283, + T_Disable = 284, + T_Discard = 285, + T_Dispersion = 286, + T_Double = 287, + T_Driftfile = 288, + T_Drop = 289, + T_Dscp = 290, + T_Ellipsis = 291, + T_Enable = 292, + T_End = 293, + T_False = 294, + T_File = 295, + T_Filegen = 296, + T_Filenum = 297, + T_Flag1 = 298, + T_Flag2 = 299, + T_Flag3 = 300, + T_Flag4 = 301, + T_Flake = 302, + T_Floor = 303, + T_Freq = 304, + T_Fudge = 305, + T_Host = 306, + T_Huffpuff = 307, + T_Iburst = 308, + T_Ident = 309, + T_Ignore = 310, + T_Incalloc = 311, + T_Incmem = 312, + T_Initalloc = 313, + T_Initmem = 314, + T_Includefile = 315, + T_Integer = 316, + T_Interface = 317, + T_Intrange = 318, + T_Io = 319, + T_Ipv4 = 320, + T_Ipv4_flag = 321, + T_Ipv6 = 322, + T_Ipv6_flag = 323, + T_Kernel = 324, + T_Key = 325, + T_Keys = 326, + T_Keysdir = 327, + T_Kod = 328, + T_Mssntp = 329, + T_Leapfile = 330, + T_Leapsmearinterval = 331, + T_Limited = 332, + T_Link = 333, + T_Listen = 334, + T_Logconfig = 335, + T_Logfile = 336, + T_Loopstats = 337, + T_Lowpriotrap = 338, + T_Manycastclient = 339, + T_Manycastserver = 340, + T_Mask = 341, + T_Maxage = 342, + T_Maxclock = 343, + T_Maxdepth = 344, + T_Maxdist = 345, + T_Maxmem = 346, + T_Maxpoll = 347, + T_Mdnstries = 348, + T_Mem = 349, + T_Memlock = 350, + T_Minclock = 351, + T_Mindepth = 352, + T_Mindist = 353, + T_Minimum = 354, + T_Minpoll = 355, + T_Minsane = 356, + T_Mode = 357, + T_Mode7 = 358, + T_Monitor = 359, + T_Month = 360, + T_Mru = 361, + T_Multicastclient = 362, + T_Nic = 363, + T_Nolink = 364, + T_Nomodify = 365, + T_Nomrulist = 366, + T_None = 367, + T_Nonvolatile = 368, + T_Nopeer = 369, + T_Noquery = 370, + T_Noselect = 371, + T_Noserve = 372, + T_Notrap = 373, + T_Notrust = 374, + T_Ntp = 375, + T_Ntpport = 376, + T_NtpSignDsocket = 377, + T_Orphan = 378, + T_Orphanwait = 379, + T_Panic = 380, + T_Peer = 381, + T_Peerstats = 382, + T_Phone = 383, + T_Pid = 384, + T_Pidfile = 385, + T_Pool = 386, + T_Port = 387, + T_Preempt = 388, + T_Prefer = 389, + T_Protostats = 390, + T_Pw = 391, + T_Randfile = 392, + T_Rawstats = 393, + T_Refid = 394, + T_Requestkey = 395, + T_Reset = 396, + T_Restrict = 397, + T_Revoke = 398, + T_Rlimit = 399, + T_Saveconfigdir = 400, + T_Server = 401, + T_Setvar = 402, + T_Source = 403, + T_Stacksize = 404, + T_Statistics = 405, + T_Stats = 406, + T_Statsdir = 407, + T_Step = 408, + T_Stepback = 409, + T_Stepfwd = 410, + T_Stepout = 411, + T_Stratum = 412, + T_String = 413, + T_Sys = 414, + T_Sysstats = 415, + T_Tick = 416, + T_Time1 = 417, + T_Time2 = 418, + T_Timer = 419, + T_Timingstats = 420, + T_Tinker = 421, + T_Tos = 422, + T_Trap = 423, + T_True = 424, + T_Trustedkey = 425, + T_Ttl = 426, + T_Type = 427, + T_U_int = 428, + T_Unconfig = 429, + T_Unpeer = 430, + T_Version = 431, + T_WanderThreshold = 432, + T_Week = 433, + T_Wildcard = 434, + T_Xleave = 435, + T_Year = 436, + T_Flag = 437, + T_EOC = 438, + T_Simulate = 439, + T_Beep_Delay = 440, + T_Sim_Duration = 441, + T_Server_Offset = 442, + T_Duration = 443, + T_Freq_Offset = 444, + T_Wander = 445, + T_Jitter = 446, + T_Prop_Delay = 447, + T_Proc_Delay = 448 + }; #endif /* Tokens. */ #define T_Abbrev 258 @@ -520,13 +517,12 @@ extern int yydebug; #define T_Prop_Delay 447 #define T_Proc_Delay 448 - - +/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE +typedef union YYSTYPE YYSTYPE; +union YYSTYPE { -/* Line 387 of yacc.c */ -#line 51 "../../ntpd/ntp_parser.y" +#line 51 "../../ntpd/ntp_parser.y" /* yacc.c:355 */ char * String; double Double; @@ -545,37 +541,22 @@ typedef union YYSTYPE script_info * Sim_script; script_info_fifo * Sim_script_fifo; - -/* Line 387 of yacc.c */ -#line 551 "ntp_parser.c" -} YYSTYPE; +#line 545 "../../ntpd/ntp_parser.c" /* yacc.c:355 */ +}; # define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif + extern YYSTYPE yylval; -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ -#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */ +#endif /* !YY_YY__NTPD_NTP_PARSER_H_INCLUDED */ /* Copy the second part of user declarations. */ -/* Line 390 of yacc.c */ -#line 579 "ntp_parser.c" +#line 560 "../../ntpd/ntp_parser.c" /* yacc.c:358 */ #ifdef short # undef short @@ -589,11 +570,8 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; #else -typedef short int yytype_int8; +typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -613,8 +591,7 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -636,11 +613,30 @@ typedef short int yytype_int16; # endif #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif @@ -651,24 +647,25 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(N) (N) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif #if ! defined yyoverflow || YYERROR_VERBOSE @@ -687,8 +684,7 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS @@ -700,8 +696,8 @@ YYID (yyi) # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -717,7 +713,7 @@ YYID (yyi) # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -725,15 +721,13 @@ YYID (yyi) # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -743,7 +737,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -768,16 +762,16 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) #endif @@ -796,7 +790,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ - while (YYID (0)) + while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ @@ -812,17 +806,19 @@ union yyalloc #define YYNNTS 105 /* YYNRULES -- Number of rules. */ #define YYNRULES 313 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 419 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 448 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -873,127 +869,7 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 5, 9, 12, 15, 16, 18, 20, - 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 46, 48, 50, 52, 54, 56, 58, 61, 63, - 65, 67, 68, 71, 73, 75, 77, 79, 81, 83, - 85, 87, 89, 91, 93, 95, 98, 101, 103, 105, - 107, 109, 111, 113, 116, 118, 121, 123, 125, 127, - 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, - 160, 163, 164, 167, 170, 173, 175, 177, 179, 181, - 183, 186, 189, 191, 194, 197, 200, 202, 204, 206, - 208, 210, 212, 214, 216, 218, 220, 223, 226, 230, - 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, - 252, 255, 258, 261, 263, 265, 267, 269, 271, 273, - 275, 277, 279, 281, 283, 285, 287, 290, 293, 297, - 303, 307, 312, 317, 321, 322, 325, 327, 329, 331, - 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, - 353, 355, 358, 360, 363, 365, 367, 369, 372, 374, - 377, 379, 381, 383, 385, 387, 389, 391, 393, 397, - 400, 402, 405, 408, 411, 414, 417, 419, 421, 423, - 425, 427, 429, 432, 435, 437, 440, 442, 444, 446, - 449, 452, 455, 457, 459, 461, 463, 465, 467, 469, - 471, 473, 475, 477, 480, 483, 485, 488, 490, 492, - 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, - 515, 518, 521, 524, 528, 530, 533, 536, 539, 542, - 546, 549, 551, 553, 555, 557, 559, 561, 563, 565, - 567, 569, 571, 574, 575, 580, 582, 583, 584, 587, - 590, 593, 596, 598, 600, 604, 608, 610, 612, 614, - 616, 618, 620, 622, 624, 626, 629, 632, 634, 636, - 638, 640, 642, 644, 646, 648, 651, 653, 656, 658, - 660, 662, 668, 671, 673, 676, 678, 680, 682, 684, - 686, 688, 694, 696, 700, 703, 707, 709, 711, 714, - 716, 722, 727, 731, 734, 736, 743, 747, 750, 754, - 756, 758, 760, 762 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 200, 0, -1, 201, -1, 201, 202, 183, -1, 202, - 183, -1, 1, 183, -1, -1, 203, -1, 216, -1, - 218, -1, 219, -1, 228, -1, 236, -1, 223, -1, - 245, -1, 250, -1, 254, -1, 259, -1, 263, -1, - 290, -1, 204, 205, 208, -1, 146, -1, 131, -1, - 126, -1, 14, -1, 84, -1, 206, -1, 207, 158, - -1, 158, -1, 66, -1, 68, -1, -1, 208, 209, - -1, 210, -1, 212, -1, 214, -1, 211, -1, 9, - -1, 17, -1, 53, -1, 116, -1, 133, -1, 134, - -1, 169, -1, 180, -1, 213, 61, -1, 213, 173, - -1, 70, -1, 100, -1, 92, -1, 171, -1, 102, - -1, 176, -1, 215, 158, -1, 54, -1, 217, 205, - -1, 174, -1, 175, -1, 15, -1, 85, 287, -1, - 107, 287, -1, 93, 61, -1, 10, 61, -1, 22, - 61, -1, 23, 220, -1, 71, 158, -1, 72, 158, - -1, 140, 61, -1, 143, 61, -1, 170, 283, -1, - 122, 158, -1, -1, 220, 221, -1, 222, 158, -1, - 143, 61, -1, 51, -1, 54, -1, 136, -1, 137, - -1, 28, -1, 167, 224, -1, 224, 225, -1, 225, - -1, 226, 61, -1, 227, 289, -1, 21, 288, -1, - 19, -1, 48, -1, 123, -1, 124, -1, 101, -1, - 13, -1, 98, -1, 90, -1, 96, -1, 88, -1, - 150, 229, -1, 152, 158, -1, 41, 230, 231, -1, - 229, 230, -1, 230, -1, 20, -1, 24, -1, 82, - -1, 127, -1, 138, -1, 160, -1, 165, -1, 135, - -1, -1, 231, 232, -1, 40, 158, -1, 172, 235, - -1, 233, -1, 234, -1, 78, -1, 109, -1, 37, - -1, 29, -1, 112, -1, 129, -1, 26, -1, 178, - -1, 105, -1, 181, -1, 4, -1, 30, 239, -1, - 106, 242, -1, 142, 205, 237, -1, 142, 206, 86, - 206, 237, -1, 142, 27, 237, -1, 142, 66, 27, - 237, -1, 142, 68, 27, 237, -1, 142, 148, 237, - -1, -1, 237, 238, -1, 47, -1, 55, -1, 73, - -1, 74, -1, 77, -1, 83, -1, 110, -1, 111, - -1, 114, -1, 115, -1, 117, -1, 118, -1, 119, - -1, 121, -1, 176, -1, 239, 240, -1, 240, -1, - 241, 61, -1, 11, -1, 99, -1, 104, -1, 242, - 243, -1, 243, -1, 244, 61, -1, 56, -1, 57, - -1, 58, -1, 59, -1, 87, -1, 89, -1, 91, - -1, 97, -1, 50, 205, 246, -1, 246, 247, -1, - 247, -1, 248, 289, -1, 249, 288, -1, 157, 61, - -1, 3, 158, -1, 139, 158, -1, 162, -1, 163, - -1, 43, -1, 44, -1, 45, -1, 46, -1, 144, - 251, -1, 251, 252, -1, 252, -1, 253, 61, -1, - 95, -1, 149, -1, 42, -1, 37, 255, -1, 29, - 255, -1, 255, 256, -1, 256, -1, 257, -1, 258, - -1, 8, -1, 12, -1, 18, -1, 69, -1, 104, - -1, 120, -1, 103, -1, 151, -1, 166, 260, -1, - 260, 261, -1, 261, -1, 262, 289, -1, 6, -1, - 31, -1, 49, -1, 52, -1, 125, -1, 153, -1, - 154, -1, 155, -1, 156, -1, 161, -1, 275, -1, - 279, -1, 264, 289, -1, 265, 61, -1, 266, 158, - -1, 267, 158, -1, 60, 158, 202, -1, 38, -1, - 33, 268, -1, 80, 273, -1, 128, 286, -1, 147, - 269, -1, 168, 206, 271, -1, 171, 282, -1, 16, - -1, 113, -1, 161, -1, 35, -1, 76, -1, 54, - -1, 75, -1, 130, -1, 81, -1, 145, -1, 158, - -1, 158, 32, -1, -1, 158, 194, 158, 270, -1, - 27, -1, -1, -1, 271, 272, -1, 132, 61, -1, - 62, 206, -1, 273, 274, -1, 274, -1, 158, -1, - 276, 278, 277, -1, 276, 278, 158, -1, 62, -1, - 108, -1, 5, -1, 65, -1, 67, -1, 179, -1, - 79, -1, 55, -1, 34, -1, 141, 280, -1, 280, - 281, -1, 281, -1, 7, -1, 8, -1, 25, -1, - 64, -1, 94, -1, 159, -1, 164, -1, 282, 61, - -1, 61, -1, 283, 284, -1, 284, -1, 61, -1, - 285, -1, 195, 61, 36, 61, 196, -1, 286, 158, - -1, 158, -1, 287, 205, -1, 205, -1, 61, -1, - 169, -1, 39, -1, 61, -1, 32, -1, 291, 197, - 292, 295, 198, -1, 184, -1, 292, 293, 183, -1, - 293, 183, -1, 294, 194, 289, -1, 185, -1, 186, - -1, 295, 296, -1, 296, -1, 298, 197, 297, 299, - 198, -1, 187, 194, 289, 183, -1, 146, 194, 205, - -1, 299, 300, -1, 300, -1, 188, 194, 289, 197, - 301, 198, -1, 301, 302, 183, -1, 302, 183, -1, - 303, 194, 289, -1, 189, -1, 190, -1, 191, -1, - 192, -1, 193, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 366, 366, 370, 371, 372, 387, 388, 389, 390, @@ -1019,15 +895,15 @@ static const yytype_uint16 yyrline[] = 1073, 1077, 1078, 1086, 1091, 1096, 1104, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1127, 1128, 1129, 1136, 1143, 1150, 1166, 1185, 1187, 1189, 1191, 1193, 1195, - 1202, 1207, 1208, 1209, 1213, 1217, 1226, 1227, 1228, 1232, - 1233, 1237, 1244, 1254, 1263, 1268, 1270, 1275, 1276, 1284, - 1286, 1294, 1299, 1307, 1332, 1339, 1349, 1350, 1354, 1355, - 1356, 1357, 1361, 1362, 1363, 1367, 1372, 1377, 1385, 1386, - 1387, 1388, 1389, 1390, 1391, 1401, 1406, 1414, 1419, 1427, - 1429, 1433, 1438, 1443, 1451, 1456, 1464, 1473, 1474, 1478, - 1479, 1488, 1506, 1510, 1515, 1523, 1528, 1529, 1533, 1538, - 1546, 1551, 1556, 1561, 1566, 1574, 1579, 1584, 1592, 1597, - 1598, 1599, 1600, 1601 + 1202, 1207, 1208, 1209, 1213, 1217, 1226, 1227, 1231, 1232, + 1233, 1237, 1248, 1262, 1274, 1279, 1281, 1286, 1287, 1295, + 1297, 1305, 1310, 1318, 1343, 1350, 1360, 1361, 1365, 1366, + 1367, 1368, 1372, 1373, 1374, 1378, 1383, 1388, 1396, 1397, + 1398, 1399, 1400, 1401, 1402, 1412, 1417, 1425, 1430, 1438, + 1440, 1444, 1449, 1454, 1462, 1467, 1475, 1484, 1485, 1489, + 1490, 1499, 1517, 1521, 1526, 1534, 1539, 1540, 1544, 1549, + 1557, 1562, 1567, 1572, 1577, 1585, 1590, 1595, 1603, 1608, + 1609, 1610, 1611, 1612 }; #endif @@ -1105,13 +981,13 @@ static const char *const yytname[] = "sim_init_statement_list", "sim_init_statement", "sim_init_keyword", "sim_server_list", "sim_server", "sim_server_offset", "sim_server_name", "sim_act_list", "sim_act", "sim_act_stmt_list", "sim_act_stmt", - "sim_act_keyword", YY_NULL + "sim_act_keyword", YY_NULLPTR }; #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -1137,148 +1013,18 @@ static const yytype_uint16 yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint16 yyr1[] = -{ - 0, 199, 200, 201, 201, 201, 202, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - 203, 204, 204, 204, 204, 204, 205, 205, 206, 207, - 207, 208, 208, 209, 209, 209, 210, 211, 211, 211, - 211, 211, 211, 211, 211, 212, 212, 213, 213, 213, - 213, 213, 213, 214, 215, 216, 217, 217, 218, 218, - 218, 218, 219, 219, 219, 219, 219, 219, 219, 219, - 219, 220, 220, 221, 221, 222, 222, 222, 222, 222, - 223, 224, 224, 225, 225, 225, 226, 226, 226, 226, - 226, 226, 227, 227, 227, 227, 228, 228, 228, 229, - 229, 230, 230, 230, 230, 230, 230, 230, 230, 231, - 231, 232, 232, 232, 232, 233, 233, 234, 234, 235, - 235, 235, 235, 235, 235, 235, 236, 236, 236, 236, - 236, 236, 236, 236, 237, 237, 238, 238, 238, 238, - 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - 238, 239, 239, 240, 241, 241, 241, 242, 242, 243, - 244, 244, 244, 244, 244, 244, 244, 244, 245, 246, - 246, 247, 247, 247, 247, 247, 248, 248, 249, 249, - 249, 249, 250, 251, 251, 252, 253, 253, 253, 254, - 254, 255, 255, 256, 256, 257, 257, 257, 257, 257, - 257, 258, 258, 259, 260, 260, 261, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 263, 263, 263, - 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, - 263, 264, 264, 264, 265, 265, 266, 266, 266, 267, - 267, 268, 268, 268, 269, 270, 270, 271, 271, 272, - 272, 273, 273, 274, 275, 275, 276, 276, 277, 277, - 277, 277, 278, 278, 278, 279, 280, 280, 281, 281, - 281, 281, 281, 281, 281, 282, 282, 283, 283, 284, - 284, 285, 286, 286, 287, 287, 288, 288, 288, 289, - 289, 290, 291, 292, 292, 293, 294, 294, 295, 295, - 296, 297, 298, 299, 299, 300, 301, 301, 302, 303, - 303, 303, 303, 303 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 3, 2, 2, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 3, 1, 1, 1, 1, 1, 1, 2, 1, 1, - 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, - 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 0, 2, 2, 2, 1, 1, 1, 1, 1, - 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 3, 5, - 3, 4, 4, 3, 0, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, - 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, - 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, - 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 3, 1, 2, 2, 2, 2, 3, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 0, 4, 1, 0, 0, 2, 2, - 2, 2, 1, 1, 3, 3, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, - 1, 5, 2, 1, 2, 1, 1, 1, 1, 1, - 1, 5, 1, 3, 2, 3, 1, 1, 2, 1, - 5, 4, 3, 2, 1, 6, 3, 2, 3, 1, - 1, 1, 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint16 yydefact[] = -{ - 0, 0, 0, 24, 58, 231, 0, 71, 0, 0, - 243, 234, 0, 224, 0, 0, 236, 0, 256, 0, - 0, 237, 235, 0, 239, 25, 0, 0, 0, 0, - 257, 232, 0, 23, 0, 238, 22, 0, 0, 0, - 0, 0, 240, 21, 0, 0, 0, 233, 0, 0, - 0, 0, 0, 56, 57, 292, 0, 2, 0, 7, - 0, 8, 0, 9, 10, 13, 11, 12, 14, 15, - 16, 17, 18, 0, 0, 0, 0, 217, 0, 218, - 19, 0, 5, 62, 63, 64, 195, 196, 197, 198, - 201, 199, 200, 202, 190, 192, 193, 194, 154, 155, - 156, 126, 152, 0, 241, 225, 189, 101, 102, 103, - 104, 108, 105, 106, 107, 109, 29, 30, 28, 0, - 26, 0, 6, 65, 66, 253, 226, 252, 285, 59, - 61, 160, 161, 162, 163, 164, 165, 166, 167, 127, - 158, 0, 60, 70, 283, 227, 67, 268, 269, 270, - 271, 272, 273, 274, 265, 267, 134, 29, 30, 134, - 134, 26, 68, 188, 186, 187, 182, 184, 0, 0, - 228, 96, 100, 97, 207, 208, 209, 210, 211, 212, - 213, 214, 215, 216, 203, 205, 0, 91, 86, 0, - 87, 95, 93, 94, 92, 90, 88, 89, 80, 82, - 0, 0, 247, 279, 0, 69, 278, 280, 276, 230, - 1, 0, 4, 31, 55, 290, 289, 219, 220, 221, - 222, 264, 263, 262, 0, 0, 79, 75, 76, 77, - 78, 0, 72, 0, 191, 151, 153, 242, 98, 0, - 178, 179, 180, 181, 0, 0, 176, 177, 168, 170, - 0, 0, 27, 223, 251, 284, 157, 159, 282, 266, - 130, 134, 134, 133, 128, 0, 183, 185, 0, 99, - 204, 206, 288, 286, 287, 85, 81, 83, 84, 229, - 0, 277, 275, 3, 20, 258, 259, 260, 255, 261, - 254, 296, 297, 0, 0, 0, 74, 73, 118, 117, - 0, 115, 116, 0, 110, 113, 114, 174, 175, 173, - 169, 171, 172, 136, 137, 138, 139, 140, 141, 142, - 143, 144, 145, 146, 147, 148, 149, 150, 135, 131, - 132, 134, 246, 0, 0, 248, 0, 37, 38, 39, - 54, 47, 49, 48, 51, 40, 41, 42, 43, 50, - 52, 44, 32, 33, 36, 34, 0, 35, 0, 0, - 0, 0, 299, 0, 294, 0, 111, 125, 121, 123, - 119, 120, 122, 124, 112, 129, 245, 244, 250, 249, - 0, 45, 46, 53, 0, 293, 291, 298, 0, 295, - 281, 302, 0, 0, 0, 0, 0, 304, 0, 0, - 300, 303, 301, 0, 0, 309, 310, 311, 312, 313, - 0, 0, 0, 305, 0, 307, 0, 306, 308 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 56, 57, 58, 59, 60, 128, 120, 121, 284, - 352, 353, 354, 355, 356, 357, 358, 61, 62, 63, - 64, 85, 232, 233, 65, 198, 199, 200, 201, 66, - 171, 115, 238, 304, 305, 306, 374, 67, 260, 328, - 101, 102, 103, 139, 140, 141, 68, 248, 249, 250, - 251, 69, 166, 167, 168, 70, 94, 95, 96, 97, - 71, 184, 185, 186, 72, 73, 74, 75, 76, 105, - 170, 377, 279, 335, 126, 127, 77, 78, 290, 224, - 79, 154, 155, 209, 205, 206, 207, 145, 129, 275, - 217, 80, 81, 293, 294, 295, 361, 362, 393, 363, - 396, 397, 410, 411, 412 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ #define YYPACT_NINF -185 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-185))) + +#define YYTABLE_NINF -7 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int16 yypact[] = { 78, -169, -34, -185, -185, -185, -29, -185, 17, 43, @@ -1325,7 +1071,56 @@ static const yytype_int16 yypact[] = 98, 57, 47, -185, 60, -185, -12, -185, -185 }; -/* YYPGOTO[NTERM-NUM]. */ + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 0, 0, 0, 24, 58, 231, 0, 71, 0, 0, + 243, 234, 0, 224, 0, 0, 236, 0, 256, 0, + 0, 237, 235, 0, 238, 25, 0, 0, 0, 0, + 257, 232, 0, 23, 0, 239, 22, 0, 0, 0, + 0, 0, 240, 21, 0, 0, 0, 233, 0, 0, + 0, 0, 0, 56, 57, 292, 0, 2, 0, 7, + 0, 8, 0, 9, 10, 13, 11, 12, 14, 15, + 16, 17, 18, 0, 0, 0, 0, 217, 0, 218, + 19, 0, 5, 62, 63, 64, 195, 196, 197, 198, + 201, 199, 200, 202, 190, 192, 193, 194, 154, 155, + 156, 126, 152, 0, 241, 225, 189, 101, 102, 103, + 104, 108, 105, 106, 107, 109, 29, 30, 28, 0, + 26, 0, 6, 65, 66, 253, 226, 252, 285, 59, + 61, 160, 161, 162, 163, 164, 165, 166, 167, 127, + 158, 0, 60, 70, 283, 227, 67, 268, 269, 270, + 271, 272, 273, 274, 265, 267, 134, 29, 30, 134, + 134, 26, 68, 188, 186, 187, 182, 184, 0, 0, + 228, 96, 100, 97, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 203, 205, 0, 91, 86, 0, + 87, 95, 93, 94, 92, 90, 88, 89, 80, 82, + 0, 0, 247, 279, 0, 69, 278, 280, 276, 230, + 1, 0, 4, 31, 55, 290, 289, 219, 220, 221, + 222, 264, 263, 262, 0, 0, 79, 75, 76, 77, + 78, 0, 72, 0, 191, 151, 153, 242, 98, 0, + 178, 179, 180, 181, 0, 0, 176, 177, 168, 170, + 0, 0, 27, 223, 251, 284, 157, 159, 282, 266, + 130, 134, 134, 133, 128, 0, 183, 185, 0, 99, + 204, 206, 288, 286, 287, 85, 81, 83, 84, 229, + 0, 277, 275, 3, 20, 258, 259, 260, 255, 261, + 254, 296, 297, 0, 0, 0, 74, 73, 118, 117, + 0, 115, 116, 0, 110, 113, 114, 174, 175, 173, + 169, 171, 172, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 135, 131, + 132, 134, 246, 0, 0, 248, 0, 37, 38, 39, + 54, 47, 49, 48, 51, 40, 41, 42, 43, 50, + 52, 44, 32, 33, 36, 34, 0, 35, 0, 0, + 0, 0, 299, 0, 294, 0, 111, 125, 121, 123, + 119, 120, 122, 124, 112, 129, 245, 244, 250, 249, + 0, 45, 46, 53, 0, 293, 291, 298, 0, 295, + 281, 302, 0, 0, 0, 0, 0, 304, 0, 0, + 300, 303, 301, 0, 0, 309, 310, 311, 312, 313, + 0, 0, 0, 305, 0, 307, 0, 306, 308 +}; + + /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -185, -185, -185, -44, -185, -185, -15, -38, -185, -185, @@ -1341,10 +1136,25 @@ static const yytype_int16 yypgoto[] = -185, -113, -185, -126, -185 }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -7 + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 56, 57, 58, 59, 60, 128, 120, 121, 284, + 352, 353, 354, 355, 356, 357, 358, 61, 62, 63, + 64, 85, 232, 233, 65, 198, 199, 200, 201, 66, + 171, 115, 238, 304, 305, 306, 374, 67, 260, 328, + 101, 102, 103, 139, 140, 141, 68, 248, 249, 250, + 251, 69, 166, 167, 168, 70, 94, 95, 96, 97, + 71, 184, 185, 186, 72, 73, 74, 75, 76, 105, + 170, 377, 279, 335, 126, 127, 77, 78, 290, 224, + 79, 154, 155, 209, 205, 206, 207, 145, 129, 275, + 217, 80, 81, 293, 294, 295, 361, 362, 393, 363, + 396, 397, 410, 411, 412 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { 119, 161, 271, 285, 272, 203, 381, 263, 264, 172, @@ -1414,12 +1224,6 @@ static const yytype_int16 yytable[] = 350, 0, 0, 0, 351, 0, 196, 197 }; -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-185))) - -#define yytable_value_is_error(Yytable_value) \ - YYID (0) - static const yytype_int16 yycheck[] = { 15, 39, 186, 5, 39, 61, 61, 159, 160, 45, @@ -1489,8 +1293,8 @@ static const yytype_int16 yycheck[] = 176, -1, -1, -1, 180, -1, 123, 124 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { 0, 1, 10, 14, 15, 16, 22, 23, 29, 30, @@ -1537,30 +1341,90 @@ static const yytype_uint16 yystos[] = 301, 302, 303, 198, 302, 183, 194, 183, 289 }; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint16 yyr1[] = +{ + 0, 199, 200, 201, 201, 201, 202, 202, 202, 202, + 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, + 203, 204, 204, 204, 204, 204, 205, 205, 206, 207, + 207, 208, 208, 209, 209, 209, 210, 211, 211, 211, + 211, 211, 211, 211, 211, 212, 212, 213, 213, 213, + 213, 213, 213, 214, 215, 216, 217, 217, 218, 218, + 218, 218, 219, 219, 219, 219, 219, 219, 219, 219, + 219, 220, 220, 221, 221, 222, 222, 222, 222, 222, + 223, 224, 224, 225, 225, 225, 226, 226, 226, 226, + 226, 226, 227, 227, 227, 227, 228, 228, 228, 229, + 229, 230, 230, 230, 230, 230, 230, 230, 230, 231, + 231, 232, 232, 232, 232, 233, 233, 234, 234, 235, + 235, 235, 235, 235, 235, 235, 236, 236, 236, 236, + 236, 236, 236, 236, 237, 237, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, + 238, 239, 239, 240, 241, 241, 241, 242, 242, 243, + 244, 244, 244, 244, 244, 244, 244, 244, 245, 246, + 246, 247, 247, 247, 247, 247, 248, 248, 249, 249, + 249, 249, 250, 251, 251, 252, 253, 253, 253, 254, + 254, 255, 255, 256, 256, 257, 257, 257, 257, 257, + 257, 258, 258, 259, 260, 260, 261, 262, 262, 262, + 262, 262, 262, 262, 262, 262, 262, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 264, 264, 264, 265, 265, 266, 266, 267, 267, + 267, 268, 268, 268, 269, 270, 270, 271, 271, 272, + 272, 273, 273, 274, 275, 275, 276, 276, 277, 277, + 277, 277, 278, 278, 278, 279, 280, 280, 281, 281, + 281, 281, 281, 281, 281, 282, 282, 283, 283, 284, + 284, 285, 286, 286, 287, 287, 288, 288, 288, 289, + 289, 290, 291, 292, 292, 293, 294, 294, 295, 295, + 296, 297, 298, 299, 299, 300, 301, 301, 302, 303, + 303, 303, 303, 303 +}; -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 3, 2, 2, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 3, 1, 1, 1, 1, 1, 1, 2, 1, 1, + 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, + 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 0, 2, 2, 2, 1, 1, 1, 1, 1, + 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 3, 5, + 3, 4, 4, 3, 0, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, + 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, + 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 3, 1, 2, 2, 2, 2, 3, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 0, 4, 1, 0, 0, 2, 2, + 2, 2, 1, 1, 3, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, + 1, 5, 2, 1, 2, 1, 1, 1, 1, 1, + 1, 5, 1, 3, 2, 3, 1, 1, 2, 1, + 5, 4, 3, 2, 1, 6, 3, 2, 3, 1, + 1, 1, 1, 1 +}; -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1577,27 +1441,15 @@ do \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) + YYERROR; \ + } \ +while (0) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -1607,40 +1459,36 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif { FILE *yyo = yyoutput; YYUSE (yyo); @@ -1649,8 +1497,6 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); # endif YYUSE (yytype); } @@ -1660,22 +1506,11 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) | Print this symbol on YYOUTPUT. | `--------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif { - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); @@ -1686,16 +1521,8 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1706,49 +1533,42 @@ yy_stack_print (yybottom, yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1762,7 +1582,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1785,15 +1605,8 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -1809,16 +1622,8 @@ yystrlen (yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif { char *yyd = yydest; const char *yys = yysrc; @@ -1848,27 +1653,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1891,11 +1696,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1903,10 +1708,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, int yycount = 0; /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - - for details. YYERROR is fine as it does not invoke this - function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected @@ -1956,7 +1757,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -2023,26 +1824,17 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | Release the memory associated to this symbol. | `-----------------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif { YYUSE (yyvaluep); - if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -2051,18 +1843,8 @@ yydestruct (yymsg, yytype, yyvaluep) /* The lookahead symbol. */ int yychar; - -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - /* The semantic value of the lookahead symbol. */ -YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); - +YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; @@ -2071,35 +1853,16 @@ int yynerrs; | yyparse. | `----------*/ -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) int yyparse (void) -#else -int -yyparse () - -#endif -#endif { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. + 'yyss': related to states. + 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ @@ -2167,23 +1930,23 @@ yyparse () #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); - yyss = yyss1; - yyvs = yyvs1; + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -2191,22 +1954,22 @@ yyparse () # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -2215,10 +1978,10 @@ yyparse () yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -2247,7 +2010,7 @@ yyparse () if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; + yychar = yylex (); } if (yychar <= YYEOF) @@ -2312,7 +2075,7 @@ yyparse () yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -2326,8 +2089,7 @@ yyparse () switch (yyn) { case 5: -/* Line 1787 of yacc.c */ -#line 373 "../../ntpd/ntp_parser.y" +#line 373 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { /* I will need to incorporate much more fine grained * error messages. The following should suffice for @@ -2340,433 +2102,433 @@ yyparse () ip_ctx->errpos.nline, ip_ctx->errpos.ncol); } +#line 2106 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 20: -/* Line 1787 of yacc.c */ -#line 409 "../../ntpd/ntp_parser.y" +#line 409 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { peer_node *my_node; - my_node = create_peer_node((yyvsp[(1) - (3)].Integer), (yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Attr_val_fifo)); + my_node = create_peer_node((yyvsp[-2].Integer), (yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); APPEND_G_FIFO(cfgt.peers, my_node); } +#line 2117 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 27: -/* Line 1787 of yacc.c */ -#line 428 "../../ntpd/ntp_parser.y" - { (yyval.Address_node) = create_address_node((yyvsp[(2) - (2)].String), (yyvsp[(1) - (2)].Integer)); } +#line 428 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Address_node) = create_address_node((yyvsp[0].String), (yyvsp[-1].Integer)); } +#line 2123 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 28: -/* Line 1787 of yacc.c */ -#line 433 "../../ntpd/ntp_parser.y" - { (yyval.Address_node) = create_address_node((yyvsp[(1) - (1)].String), AF_UNSPEC); } +#line 433 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Address_node) = create_address_node((yyvsp[0].String), AF_UNSPEC); } +#line 2129 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 29: -/* Line 1787 of yacc.c */ -#line 438 "../../ntpd/ntp_parser.y" +#line 438 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = AF_INET; } +#line 2135 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 30: -/* Line 1787 of yacc.c */ -#line 440 "../../ntpd/ntp_parser.y" +#line 440 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = AF_INET6; } +#line 2141 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 31: -/* Line 1787 of yacc.c */ -#line 445 "../../ntpd/ntp_parser.y" +#line 445 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; } +#line 2147 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 32: -/* Line 1787 of yacc.c */ -#line 447 "../../ntpd/ntp_parser.y" +#line 447 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2156 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 36: -/* Line 1787 of yacc.c */ -#line 461 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } +#line 461 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } +#line 2162 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 45: -/* Line 1787 of yacc.c */ -#line 477 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 477 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2168 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 46: -/* Line 1787 of yacc.c */ -#line 479 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_uval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 479 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_uval((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2174 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 53: -/* Line 1787 of yacc.c */ -#line 493 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } +#line 493 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } +#line 2180 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 55: -/* Line 1787 of yacc.c */ -#line 507 "../../ntpd/ntp_parser.y" +#line 507 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { unpeer_node *my_node; - my_node = create_unpeer_node((yyvsp[(2) - (2)].Address_node)); + my_node = create_unpeer_node((yyvsp[0].Address_node)); if (my_node) APPEND_G_FIFO(cfgt.unpeers, my_node); } +#line 2192 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 58: -/* Line 1787 of yacc.c */ -#line 528 "../../ntpd/ntp_parser.y" +#line 528 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { cfgt.broadcastclient = 1; } +#line 2198 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 59: -/* Line 1787 of yacc.c */ -#line 530 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[(2) - (2)].Address_fifo)); } +#line 530 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[0].Address_fifo)); } +#line 2204 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 60: -/* Line 1787 of yacc.c */ -#line 532 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[(2) - (2)].Address_fifo)); } +#line 532 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[0].Address_fifo)); } +#line 2210 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 61: -/* Line 1787 of yacc.c */ -#line 534 "../../ntpd/ntp_parser.y" - { cfgt.mdnstries = (yyvsp[(2) - (2)].Integer); } +#line 534 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.mdnstries = (yyvsp[0].Integer); } +#line 2216 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 62: -/* Line 1787 of yacc.c */ -#line 545 "../../ntpd/ntp_parser.y" +#line 545 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *atrv; - atrv = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); + atrv = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); APPEND_G_FIFO(cfgt.vars, atrv); } +#line 2227 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 63: -/* Line 1787 of yacc.c */ -#line 552 "../../ntpd/ntp_parser.y" - { cfgt.auth.control_key = (yyvsp[(2) - (2)].Integer); } +#line 552 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.auth.control_key = (yyvsp[0].Integer); } +#line 2233 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 64: -/* Line 1787 of yacc.c */ -#line 554 "../../ntpd/ntp_parser.y" +#line 554 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { cfgt.auth.cryptosw++; - CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[(2) - (2)].Attr_val_fifo)); + CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[0].Attr_val_fifo)); } +#line 2242 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 65: -/* Line 1787 of yacc.c */ -#line 559 "../../ntpd/ntp_parser.y" - { cfgt.auth.keys = (yyvsp[(2) - (2)].String); } +#line 559 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.auth.keys = (yyvsp[0].String); } +#line 2248 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 66: -/* Line 1787 of yacc.c */ -#line 561 "../../ntpd/ntp_parser.y" - { cfgt.auth.keysdir = (yyvsp[(2) - (2)].String); } +#line 561 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.auth.keysdir = (yyvsp[0].String); } +#line 2254 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 67: -/* Line 1787 of yacc.c */ -#line 563 "../../ntpd/ntp_parser.y" - { cfgt.auth.request_key = (yyvsp[(2) - (2)].Integer); } +#line 563 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.auth.request_key = (yyvsp[0].Integer); } +#line 2260 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 68: -/* Line 1787 of yacc.c */ -#line 565 "../../ntpd/ntp_parser.y" - { cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); } +#line 565 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.auth.revoke = (yyvsp[0].Integer); } +#line 2266 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 69: -/* Line 1787 of yacc.c */ -#line 567 "../../ntpd/ntp_parser.y" +#line 567 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - cfgt.auth.trusted_key_list = (yyvsp[(2) - (2)].Attr_val_fifo); + cfgt.auth.trusted_key_list = (yyvsp[0].Attr_val_fifo); // if (!cfgt.auth.trusted_key_list) // cfgt.auth.trusted_key_list = $2; // else // LINK_SLIST(cfgt.auth.trusted_key_list, $2, link); } +#line 2279 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 70: -/* Line 1787 of yacc.c */ -#line 576 "../../ntpd/ntp_parser.y" - { cfgt.auth.ntp_signd_socket = (yyvsp[(2) - (2)].String); } +#line 576 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { cfgt.auth.ntp_signd_socket = (yyvsp[0].String); } +#line 2285 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 71: -/* Line 1787 of yacc.c */ -#line 581 "../../ntpd/ntp_parser.y" +#line 581 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; } +#line 2291 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 72: -/* Line 1787 of yacc.c */ -#line 583 "../../ntpd/ntp_parser.y" +#line 583 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2300 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 73: -/* Line 1787 of yacc.c */ -#line 591 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } +#line 591 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } +#line 2306 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 74: -/* Line 1787 of yacc.c */ -#line 593 "../../ntpd/ntp_parser.y" +#line 593 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val) = NULL; - cfgt.auth.revoke = (yyvsp[(2) - (2)].Integer); + cfgt.auth.revoke = (yyvsp[0].Integer); msyslog(LOG_WARNING, "'crypto revoke %d' is deprecated, " "please use 'revoke %d' instead.", cfgt.auth.revoke, cfgt.auth.revoke); } +#line 2319 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 80: -/* Line 1787 of yacc.c */ -#line 618 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 618 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[0].Attr_val_fifo)); } +#line 2325 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 81: -/* Line 1787 of yacc.c */ -#line 623 "../../ntpd/ntp_parser.y" +#line 623 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2334 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 82: -/* Line 1787 of yacc.c */ -#line 628 "../../ntpd/ntp_parser.y" +#line 628 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2343 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 83: -/* Line 1787 of yacc.c */ -#line 636 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } +#line 636 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); } +#line 2349 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 84: -/* Line 1787 of yacc.c */ -#line 638 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } +#line 638 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } +#line 2355 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 85: -/* Line 1787 of yacc.c */ -#line 640 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (double)(yyvsp[(2) - (2)].Integer)); } +#line 640 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); } +#line 2361 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 96: -/* Line 1787 of yacc.c */ -#line 666 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[(2) - (2)].Int_fifo)); } +#line 666 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[0].Int_fifo)); } +#line 2367 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 97: -/* Line 1787 of yacc.c */ -#line 668 "../../ntpd/ntp_parser.y" +#line 668 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { - cfgt.stats_dir = (yyvsp[(2) - (2)].String); + cfgt.stats_dir = (yyvsp[0].String); } else { - YYFREE((yyvsp[(2) - (2)].String)); + YYFREE((yyvsp[0].String)); yyerror("statsdir remote configuration ignored"); } } +#line 2380 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 98: -/* Line 1787 of yacc.c */ -#line 677 "../../ntpd/ntp_parser.y" +#line 677 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { filegen_node *fgn; - fgn = create_filegen_node((yyvsp[(2) - (3)].Integer), (yyvsp[(3) - (3)].Attr_val_fifo)); + fgn = create_filegen_node((yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo)); APPEND_G_FIFO(cfgt.filegen_opts, fgn); } +#line 2391 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 99: -/* Line 1787 of yacc.c */ -#line 687 "../../ntpd/ntp_parser.y" +#line 687 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo); - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); + (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } +#line 2400 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 100: -/* Line 1787 of yacc.c */ -#line 692 "../../ntpd/ntp_parser.y" +#line 692 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Int_fifo) = NULL; - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(1) - (1)].Integer))); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } +#line 2409 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 109: -/* Line 1787 of yacc.c */ -#line 711 "../../ntpd/ntp_parser.y" +#line 711 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; } +#line 2415 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 110: -/* Line 1787 of yacc.c */ -#line 713 "../../ntpd/ntp_parser.y" +#line 713 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2424 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 111: -/* Line 1787 of yacc.c */ -#line 721 "../../ntpd/ntp_parser.y" +#line 721 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { - (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); + (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } else { (yyval.Attr_val) = NULL; - YYFREE((yyvsp[(2) - (2)].String)); + YYFREE((yyvsp[0].String)); yyerror("filegen file remote config ignored"); } } +#line 2438 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 112: -/* Line 1787 of yacc.c */ -#line 731 "../../ntpd/ntp_parser.y" +#line 731 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { - (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); + (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } else { (yyval.Attr_val) = NULL; yyerror("filegen type remote config ignored"); } } +#line 2451 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 113: -/* Line 1787 of yacc.c */ -#line 740 "../../ntpd/ntp_parser.y" +#line 740 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { const char *err; if (lex_from_file()) { - (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); + (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } else { (yyval.Attr_val) = NULL; - if (T_Link == (yyvsp[(1) - (1)].Integer)) + if (T_Link == (yyvsp[0].Integer)) err = "filegen link remote config ignored"; else err = "filegen nolink remote config ignored"; yyerror(err); } } +#line 2470 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 114: -/* Line 1787 of yacc.c */ -#line 755 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } +#line 755 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } +#line 2476 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 126: -/* Line 1787 of yacc.c */ -#line 785 "../../ntpd/ntp_parser.y" +#line 785 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); + CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[0].Attr_val_fifo)); } +#line 2484 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 127: -/* Line 1787 of yacc.c */ -#line 789 "../../ntpd/ntp_parser.y" +#line 789 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); + CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[0].Attr_val_fifo)); } +#line 2492 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 128: -/* Line 1787 of yacc.c */ -#line 793 "../../ntpd/ntp_parser.y" +#line 793 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { restrict_node *rn; - rn = create_restrict_node((yyvsp[(2) - (3)].Address_node), NULL, (yyvsp[(3) - (3)].Int_fifo), + rn = create_restrict_node((yyvsp[-1].Address_node), NULL, (yyvsp[0].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } +#line 2504 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 129: -/* Line 1787 of yacc.c */ -#line 801 "../../ntpd/ntp_parser.y" +#line 801 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { restrict_node *rn; - rn = create_restrict_node((yyvsp[(2) - (5)].Address_node), (yyvsp[(4) - (5)].Address_node), (yyvsp[(5) - (5)].Int_fifo), + rn = create_restrict_node((yyvsp[-3].Address_node), (yyvsp[-1].Address_node), (yyvsp[0].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } +#line 2516 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 130: -/* Line 1787 of yacc.c */ -#line 809 "../../ntpd/ntp_parser.y" +#line 809 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { restrict_node *rn; - rn = create_restrict_node(NULL, NULL, (yyvsp[(3) - (3)].Int_fifo), + rn = create_restrict_node(NULL, NULL, (yyvsp[0].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } +#line 2528 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 131: -/* Line 1787 of yacc.c */ -#line 817 "../../ntpd/ntp_parser.y" +#line 817 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { restrict_node *rn; @@ -2777,15 +2539,15 @@ yyparse () create_address_node( estrdup("0.0.0.0"), AF_INET), - (yyvsp[(4) - (4)].Int_fifo), + (yyvsp[0].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } +#line 2547 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 132: -/* Line 1787 of yacc.c */ -#line 832 "../../ntpd/ntp_parser.y" +#line 832 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { restrict_node *rn; @@ -2796,320 +2558,320 @@ yyparse () create_address_node( estrdup("::"), AF_INET6), - (yyvsp[(4) - (4)].Int_fifo), + (yyvsp[0].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } +#line 2566 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 133: -/* Line 1787 of yacc.c */ -#line 847 "../../ntpd/ntp_parser.y" +#line 847 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { restrict_node * rn; - APPEND_G_FIFO((yyvsp[(3) - (3)].Int_fifo), create_int_node((yyvsp[(2) - (3)].Integer))); + APPEND_G_FIFO((yyvsp[0].Int_fifo), create_int_node((yyvsp[-1].Integer))); rn = create_restrict_node( - NULL, NULL, (yyvsp[(3) - (3)].Int_fifo), lex_current()->curpos.nline); + NULL, NULL, (yyvsp[0].Int_fifo), lex_current()->curpos.nline); APPEND_G_FIFO(cfgt.restrict_opts, rn); } +#line 2579 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 134: -/* Line 1787 of yacc.c */ -#line 859 "../../ntpd/ntp_parser.y" +#line 859 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Int_fifo) = NULL; } +#line 2585 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 135: -/* Line 1787 of yacc.c */ -#line 861 "../../ntpd/ntp_parser.y" +#line 861 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo); - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); + (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } +#line 2594 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 151: -/* Line 1787 of yacc.c */ -#line 887 "../../ntpd/ntp_parser.y" +#line 887 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2603 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 152: -/* Line 1787 of yacc.c */ -#line 892 "../../ntpd/ntp_parser.y" +#line 892 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2612 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 153: -/* Line 1787 of yacc.c */ -#line 900 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 900 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2618 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 157: -/* Line 1787 of yacc.c */ -#line 911 "../../ntpd/ntp_parser.y" +#line 911 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2627 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 158: -/* Line 1787 of yacc.c */ -#line 916 "../../ntpd/ntp_parser.y" +#line 916 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2636 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 159: -/* Line 1787 of yacc.c */ -#line 924 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 924 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2642 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 168: -/* Line 1787 of yacc.c */ -#line 944 "../../ntpd/ntp_parser.y" +#line 944 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { addr_opts_node *aon; - aon = create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Attr_val_fifo)); + aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); APPEND_G_FIFO(cfgt.fudge, aon); } +#line 2653 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 169: -/* Line 1787 of yacc.c */ -#line 954 "../../ntpd/ntp_parser.y" +#line 954 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2662 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 170: -/* Line 1787 of yacc.c */ -#line 959 "../../ntpd/ntp_parser.y" +#line 959 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2671 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 171: -/* Line 1787 of yacc.c */ -#line 967 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } +#line 967 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } +#line 2677 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 172: -/* Line 1787 of yacc.c */ -#line 969 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 969 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2683 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 173: -/* Line 1787 of yacc.c */ -#line 971 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 971 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2689 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 174: -/* Line 1787 of yacc.c */ -#line 973 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } +#line 973 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } +#line 2695 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 175: -/* Line 1787 of yacc.c */ -#line 975 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); } +#line 975 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); } +#line 2701 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 182: -/* Line 1787 of yacc.c */ -#line 996 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 996 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[0].Attr_val_fifo)); } +#line 2707 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 183: -/* Line 1787 of yacc.c */ -#line 1001 "../../ntpd/ntp_parser.y" +#line 1001 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2716 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 184: -/* Line 1787 of yacc.c */ -#line 1006 "../../ntpd/ntp_parser.y" +#line 1006 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2725 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 185: -/* Line 1787 of yacc.c */ -#line 1014 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 1014 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 2731 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 189: -/* Line 1787 of yacc.c */ -#line 1030 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 1030 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[0].Attr_val_fifo)); } +#line 2737 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 190: -/* Line 1787 of yacc.c */ -#line 1032 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 1032 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[0].Attr_val_fifo)); } +#line 2743 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 191: -/* Line 1787 of yacc.c */ -#line 1037 "../../ntpd/ntp_parser.y" +#line 1037 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2752 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 192: -/* Line 1787 of yacc.c */ -#line 1042 "../../ntpd/ntp_parser.y" +#line 1042 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2761 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 193: -/* Line 1787 of yacc.c */ -#line 1050 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); } +#line 1050 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } +#line 2767 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 194: -/* Line 1787 of yacc.c */ -#line 1052 "../../ntpd/ntp_parser.y" +#line 1052 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (lex_from_file()) { - (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[(1) - (1)].Integer)); + (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); } else { char err_str[128]; (yyval.Attr_val) = NULL; snprintf(err_str, sizeof(err_str), "enable/disable %s remote configuration ignored", - keyword((yyvsp[(1) - (1)].Integer))); + keyword((yyvsp[0].Integer))); yyerror(err_str); } } +#line 2785 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 203: -/* Line 1787 of yacc.c */ -#line 1087 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 1087 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[0].Attr_val_fifo)); } +#line 2791 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 204: -/* Line 1787 of yacc.c */ -#line 1092 "../../ntpd/ntp_parser.y" +#line 1092 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2800 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 205: -/* Line 1787 of yacc.c */ -#line 1097 "../../ntpd/ntp_parser.y" +#line 1097 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 2809 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 206: -/* Line 1787 of yacc.c */ -#line 1105 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); } +#line 1105 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); } +#line 2815 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 219: -/* Line 1787 of yacc.c */ -#line 1130 "../../ntpd/ntp_parser.y" +#line 1130 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *av; - av = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); + av = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); APPEND_G_FIFO(cfgt.vars, av); } +#line 2826 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 220: -/* Line 1787 of yacc.c */ -#line 1137 "../../ntpd/ntp_parser.y" +#line 1137 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *av; - av = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); + av = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); APPEND_G_FIFO(cfgt.vars, av); } +#line 2837 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 221: -/* Line 1787 of yacc.c */ -#line 1144 "../../ntpd/ntp_parser.y" +#line 1144 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { attr_val *av; - av = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); + av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); APPEND_G_FIFO(cfgt.vars, av); } +#line 2848 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 222: -/* Line 1787 of yacc.c */ -#line 1151 "../../ntpd/ntp_parser.y" +#line 1151 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { char error_text[64]; attr_val *av; if (lex_from_file()) { - av = create_attr_sval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].String)); + av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); APPEND_G_FIFO(cfgt.vars, av); } else { - YYFREE((yyvsp[(2) - (2)].String)); + YYFREE((yyvsp[0].String)); snprintf(error_text, sizeof(error_text), "%s remote config ignored", - keyword((yyvsp[(1) - (2)].Integer))); + keyword((yyvsp[-1].Integer))); yyerror(error_text); } } +#line 2868 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 223: -/* Line 1787 of yacc.c */ -#line 1167 "../../ntpd/ntp_parser.y" +#line 1167 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { if (!lex_from_file()) { - YYFREE((yyvsp[(2) - (3)].String)); /* avoid leak */ + YYFREE((yyvsp[-1].String)); /* avoid leak */ yyerror("remote includefile ignored"); break; } @@ -3117,486 +2879,497 @@ yyparse () fprintf(stderr, "getconfig: Maximum include file level exceeded.\n"); msyslog(LOG_ERR, "getconfig: Maximum include file level exceeded."); } else { - const char * path = FindConfig((yyvsp[(2) - (3)].String)); /* might return $2! */ + const char * path = FindConfig((yyvsp[-1].String)); /* might return $2! */ if (!lex_push_file(path, "r")) { fprintf(stderr, "getconfig: Couldn't open <%s>\n", path); msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", path); } } - YYFREE((yyvsp[(2) - (3)].String)); /* avoid leak */ + YYFREE((yyvsp[-1].String)); /* avoid leak */ } +#line 2891 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 224: -/* Line 1787 of yacc.c */ -#line 1186 "../../ntpd/ntp_parser.y" +#line 1186 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { lex_flush_stack(); } +#line 2897 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 225: -/* Line 1787 of yacc.c */ -#line 1188 "../../ntpd/ntp_parser.y" +#line 1188 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { /* see drift_parm below for actions */ } +#line 2903 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 226: -/* Line 1787 of yacc.c */ -#line 1190 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 1190 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[0].Attr_val_fifo)); } +#line 2909 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 227: -/* Line 1787 of yacc.c */ -#line 1192 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[(2) - (2)].String_fifo)); } +#line 1192 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[0].String_fifo)); } +#line 2915 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 228: -/* Line 1787 of yacc.c */ -#line 1194 "../../ntpd/ntp_parser.y" - { APPEND_G_FIFO(cfgt.setvar, (yyvsp[(2) - (2)].Set_var)); } +#line 1194 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { APPEND_G_FIFO(cfgt.setvar, (yyvsp[0].Set_var)); } +#line 2921 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 229: -/* Line 1787 of yacc.c */ -#line 1196 "../../ntpd/ntp_parser.y" +#line 1196 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { addr_opts_node *aon; - aon = create_addr_opts_node((yyvsp[(2) - (3)].Address_node), (yyvsp[(3) - (3)].Attr_val_fifo)); + aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo)); APPEND_G_FIFO(cfgt.trap, aon); } +#line 2932 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 230: -/* Line 1787 of yacc.c */ -#line 1203 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[(2) - (2)].Attr_val_fifo)); } +#line 1203 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[0].Attr_val_fifo)); } +#line 2938 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 235: -/* Line 1787 of yacc.c */ -#line 1218 "../../ntpd/ntp_parser.y" +#line 1218 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { #ifndef LEAP_SMEAR yyerror("Built without LEAP_SMEAR support."); #endif } +#line 2948 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 241: -/* Line 1787 of yacc.c */ -#line 1238 "../../ntpd/ntp_parser.y" +#line 1238 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - attr_val *av; - - av = create_attr_sval(T_Driftfile, (yyvsp[(1) - (1)].String)); - APPEND_G_FIFO(cfgt.vars, av); + if (lex_from_file()) { + attr_val *av; + av = create_attr_sval(T_Driftfile, (yyvsp[0].String)); + APPEND_G_FIFO(cfgt.vars, av); + } else { + YYFREE((yyvsp[0].String)); + yyerror("driftfile remote configuration ignored"); + } } +#line 2963 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 242: -/* Line 1787 of yacc.c */ -#line 1245 "../../ntpd/ntp_parser.y" +#line 1249 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - attr_val *av; - - av = create_attr_sval(T_Driftfile, (yyvsp[(1) - (2)].String)); - APPEND_G_FIFO(cfgt.vars, av); - av = create_attr_dval(T_WanderThreshold, (yyvsp[(2) - (2)].Double)); - APPEND_G_FIFO(cfgt.vars, av); + if (lex_from_file()) { + attr_val *av; + av = create_attr_sval(T_Driftfile, (yyvsp[-1].String)); + APPEND_G_FIFO(cfgt.vars, av); + av = create_attr_dval(T_WanderThreshold, (yyvsp[0].Double)); + APPEND_G_FIFO(cfgt.vars, av); + } else { + YYFREE((yyvsp[-1].String)); + yyerror("driftfile remote configuration ignored"); + } } +#line 2980 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 243: -/* Line 1787 of yacc.c */ -#line 1254 "../../ntpd/ntp_parser.y" +#line 1262 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - attr_val *av; - - av = create_attr_sval(T_Driftfile, ""); - APPEND_G_FIFO(cfgt.vars, av); + if (lex_from_file()) { + attr_val *av; + av = create_attr_sval(T_Driftfile, estrdup("")); + APPEND_G_FIFO(cfgt.vars, av); + } else { + yyerror("driftfile remote configuration ignored"); + } } +#line 2994 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 244: -/* Line 1787 of yacc.c */ -#line 1264 "../../ntpd/ntp_parser.y" - { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (4)].String), (yyvsp[(3) - (4)].String), (yyvsp[(4) - (4)].Integer)); } +#line 1275 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Set_var) = create_setvar_node((yyvsp[-3].String), (yyvsp[-1].String), (yyvsp[0].Integer)); } +#line 3000 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 246: -/* Line 1787 of yacc.c */ -#line 1270 "../../ntpd/ntp_parser.y" +#line 1281 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = 0; } +#line 3006 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 247: -/* Line 1787 of yacc.c */ -#line 1275 "../../ntpd/ntp_parser.y" +#line 1286 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; } +#line 3012 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 248: -/* Line 1787 of yacc.c */ -#line 1277 "../../ntpd/ntp_parser.y" +#line 1288 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 3021 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 249: -/* Line 1787 of yacc.c */ -#line 1285 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); } +#line 1296 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); } +#line 3027 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 250: -/* Line 1787 of yacc.c */ -#line 1287 "../../ntpd/ntp_parser.y" +#line 1298 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), estrdup((yyvsp[(2) - (2)].Address_node)->address)); - destroy_address_node((yyvsp[(2) - (2)].Address_node)); + (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), estrdup((yyvsp[0].Address_node)->address)); + destroy_address_node((yyvsp[0].Address_node)); } +#line 3036 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 251: -/* Line 1787 of yacc.c */ -#line 1295 "../../ntpd/ntp_parser.y" +#line 1306 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 3045 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 252: -/* Line 1787 of yacc.c */ -#line 1300 "../../ntpd/ntp_parser.y" +#line 1311 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 3054 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 253: -/* Line 1787 of yacc.c */ -#line 1308 "../../ntpd/ntp_parser.y" +#line 1319 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { char prefix; char * type; - switch ((yyvsp[(1) - (1)].String)[0]) { + switch ((yyvsp[0].String)[0]) { case '+': case '-': case '=': - prefix = (yyvsp[(1) - (1)].String)[0]; - type = (yyvsp[(1) - (1)].String) + 1; + prefix = (yyvsp[0].String)[0]; + type = (yyvsp[0].String) + 1; break; default: prefix = '='; - type = (yyvsp[(1) - (1)].String); + type = (yyvsp[0].String); } (yyval.Attr_val) = create_attr_sval(prefix, estrdup(type)); - YYFREE((yyvsp[(1) - (1)].String)); + YYFREE((yyvsp[0].String)); } +#line 3080 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 254: -/* Line 1787 of yacc.c */ -#line 1333 "../../ntpd/ntp_parser.y" +#line 1344 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { nic_rule_node *nrn; - nrn = create_nic_rule_node((yyvsp[(3) - (3)].Integer), NULL, (yyvsp[(2) - (3)].Integer)); + nrn = create_nic_rule_node((yyvsp[0].Integer), NULL, (yyvsp[-1].Integer)); APPEND_G_FIFO(cfgt.nic_rules, nrn); } +#line 3091 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 255: -/* Line 1787 of yacc.c */ -#line 1340 "../../ntpd/ntp_parser.y" +#line 1351 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { nic_rule_node *nrn; - nrn = create_nic_rule_node(0, (yyvsp[(3) - (3)].String), (yyvsp[(2) - (3)].Integer)); + nrn = create_nic_rule_node(0, (yyvsp[0].String), (yyvsp[-1].Integer)); APPEND_G_FIFO(cfgt.nic_rules, nrn); } +#line 3102 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 265: -/* Line 1787 of yacc.c */ -#line 1368 "../../ntpd/ntp_parser.y" - { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[(2) - (2)].Int_fifo)); } +#line 1379 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[0].Int_fifo)); } +#line 3108 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 266: -/* Line 1787 of yacc.c */ -#line 1373 "../../ntpd/ntp_parser.y" +#line 1384 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo); - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); + (yyval.Int_fifo) = (yyvsp[-1].Int_fifo); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } +#line 3117 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 267: -/* Line 1787 of yacc.c */ -#line 1378 "../../ntpd/ntp_parser.y" +#line 1389 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Int_fifo) = NULL; - APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(1) - (1)].Integer))); + APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer))); } +#line 3126 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 275: -/* Line 1787 of yacc.c */ -#line 1402 "../../ntpd/ntp_parser.y" +#line 1413 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[(2) - (2)].Integer))); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer))); } +#line 3135 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 276: -/* Line 1787 of yacc.c */ -#line 1407 "../../ntpd/ntp_parser.y" +#line 1418 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[(1) - (1)].Integer))); + APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer))); } +#line 3144 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 277: -/* Line 1787 of yacc.c */ -#line 1415 "../../ntpd/ntp_parser.y" +#line 1426 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 3153 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 278: -/* Line 1787 of yacc.c */ -#line 1420 "../../ntpd/ntp_parser.y" +#line 1431 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val)); } +#line 3162 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 279: -/* Line 1787 of yacc.c */ -#line 1428 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[(1) - (1)].Integer)); } +#line 1439 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[0].Integer)); } +#line 3168 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 281: -/* Line 1787 of yacc.c */ -#line 1434 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[(2) - (5)].Integer), (yyvsp[(4) - (5)].Integer)); } +#line 1445 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[-3].Integer), (yyvsp[-1].Integer)); } +#line 3174 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 282: -/* Line 1787 of yacc.c */ -#line 1439 "../../ntpd/ntp_parser.y" +#line 1450 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.String_fifo) = (yyvsp[(1) - (2)].String_fifo); - APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[(2) - (2)].String))); + (yyval.String_fifo) = (yyvsp[-1].String_fifo); + APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String))); } +#line 3183 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 283: -/* Line 1787 of yacc.c */ -#line 1444 "../../ntpd/ntp_parser.y" +#line 1455 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.String_fifo) = NULL; - APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[(1) - (1)].String))); + APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String))); } +#line 3192 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 284: -/* Line 1787 of yacc.c */ -#line 1452 "../../ntpd/ntp_parser.y" +#line 1463 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Address_fifo) = (yyvsp[(1) - (2)].Address_fifo); - APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[(2) - (2)].Address_node)); + (yyval.Address_fifo) = (yyvsp[-1].Address_fifo); + APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node)); } +#line 3201 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 285: -/* Line 1787 of yacc.c */ -#line 1457 "../../ntpd/ntp_parser.y" +#line 1468 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Address_fifo) = NULL; - APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[(1) - (1)].Address_node)); + APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node)); } +#line 3210 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 286: -/* Line 1787 of yacc.c */ -#line 1465 "../../ntpd/ntp_parser.y" +#line 1476 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].Integer) != 0 && (yyvsp[(1) - (1)].Integer) != 1) { + if ((yyvsp[0].Integer) != 0 && (yyvsp[0].Integer) != 1) { yyerror("Integer value is not boolean (0 or 1). Assuming 1"); (yyval.Integer) = 1; } else { - (yyval.Integer) = (yyvsp[(1) - (1)].Integer); + (yyval.Integer) = (yyvsp[0].Integer); } } +#line 3223 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 287: -/* Line 1787 of yacc.c */ -#line 1473 "../../ntpd/ntp_parser.y" +#line 1484 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = 1; } +#line 3229 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 288: -/* Line 1787 of yacc.c */ -#line 1474 "../../ntpd/ntp_parser.y" +#line 1485 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Integer) = 0; } +#line 3235 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 289: -/* Line 1787 of yacc.c */ -#line 1478 "../../ntpd/ntp_parser.y" - { (yyval.Double) = (double)(yyvsp[(1) - (1)].Integer); } +#line 1489 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Double) = (double)(yyvsp[0].Integer); } +#line 3241 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 291: -/* Line 1787 of yacc.c */ -#line 1489 "../../ntpd/ntp_parser.y" +#line 1500 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { sim_node *sn; - sn = create_sim_node((yyvsp[(3) - (5)].Attr_val_fifo), (yyvsp[(4) - (5)].Sim_server_fifo)); + sn = create_sim_node((yyvsp[-2].Attr_val_fifo), (yyvsp[-1].Sim_server_fifo)); APPEND_G_FIFO(cfgt.sim_details, sn); /* Revert from ; to \n for end-of-command */ old_config_style = 1; } +#line 3255 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 292: -/* Line 1787 of yacc.c */ -#line 1506 "../../ntpd/ntp_parser.y" +#line 1517 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { old_config_style = 0; } +#line 3261 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 293: -/* Line 1787 of yacc.c */ -#line 1511 "../../ntpd/ntp_parser.y" +#line 1522 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (3)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (3)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } +#line 3270 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 294: -/* Line 1787 of yacc.c */ -#line 1516 "../../ntpd/ntp_parser.y" +#line 1527 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (2)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } +#line 3279 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 295: -/* Line 1787 of yacc.c */ -#line 1524 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } +#line 1535 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); } +#line 3285 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 298: -/* Line 1787 of yacc.c */ -#line 1534 "../../ntpd/ntp_parser.y" +#line 1545 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Sim_server_fifo) = (yyvsp[(1) - (2)].Sim_server_fifo); - APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[(2) - (2)].Sim_server)); + (yyval.Sim_server_fifo) = (yyvsp[-1].Sim_server_fifo); + APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server)); } +#line 3294 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 299: -/* Line 1787 of yacc.c */ -#line 1539 "../../ntpd/ntp_parser.y" +#line 1550 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_server_fifo) = NULL; - APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[(1) - (1)].Sim_server)); + APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server)); } +#line 3303 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 300: -/* Line 1787 of yacc.c */ -#line 1547 "../../ntpd/ntp_parser.y" - { (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[(1) - (5)].Address_node), (yyvsp[(3) - (5)].Double), (yyvsp[(4) - (5)].Sim_script_fifo))); } +#line 1558 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[-4].Address_node), (yyvsp[-2].Double), (yyvsp[-1].Sim_script_fifo))); } +#line 3309 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 301: -/* Line 1787 of yacc.c */ -#line 1552 "../../ntpd/ntp_parser.y" - { (yyval.Double) = (yyvsp[(3) - (4)].Double); } +#line 1563 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Double) = (yyvsp[-1].Double); } +#line 3315 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 302: -/* Line 1787 of yacc.c */ -#line 1557 "../../ntpd/ntp_parser.y" - { (yyval.Address_node) = (yyvsp[(3) - (3)].Address_node); } +#line 1568 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Address_node) = (yyvsp[0].Address_node); } +#line 3321 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 303: -/* Line 1787 of yacc.c */ -#line 1562 "../../ntpd/ntp_parser.y" +#line 1573 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Sim_script_fifo) = (yyvsp[(1) - (2)].Sim_script_fifo); - APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[(2) - (2)].Sim_script)); + (yyval.Sim_script_fifo) = (yyvsp[-1].Sim_script_fifo); + APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script)); } +#line 3330 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 304: -/* Line 1787 of yacc.c */ -#line 1567 "../../ntpd/ntp_parser.y" +#line 1578 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Sim_script_fifo) = NULL; - APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[(1) - (1)].Sim_script)); + APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script)); } +#line 3339 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 305: -/* Line 1787 of yacc.c */ -#line 1575 "../../ntpd/ntp_parser.y" - { (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[(3) - (6)].Double), (yyvsp[(5) - (6)].Attr_val_fifo))); } +#line 1586 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[-3].Double), (yyvsp[-1].Attr_val_fifo))); } +#line 3345 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 306: -/* Line 1787 of yacc.c */ -#line 1580 "../../ntpd/ntp_parser.y" +#line 1591 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { - (yyval.Attr_val_fifo) = (yyvsp[(1) - (3)].Attr_val_fifo); - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (3)].Attr_val)); + (yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } +#line 3354 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 307: -/* Line 1787 of yacc.c */ -#line 1585 "../../ntpd/ntp_parser.y" +#line 1596 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ { (yyval.Attr_val_fifo) = NULL; - APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (2)].Attr_val)); + APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val)); } +#line 3363 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; case 308: -/* Line 1787 of yacc.c */ -#line 1593 "../../ntpd/ntp_parser.y" - { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); } +#line 1604 "../../ntpd/ntp_parser.y" /* yacc.c:1646 */ + { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); } +#line 3369 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ break; -/* Line 1787 of yacc.c */ -#line 3600 "ntp_parser.c" +#line 3373 "../../ntpd/ntp_parser.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3618,7 +3391,7 @@ yyparse () *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state + /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -3633,9 +3406,9 @@ yyparse () goto yynewstate; -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -3686,20 +3459,20 @@ yyparse () if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -3718,7 +3491,7 @@ yyparse () if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -3731,29 +3504,29 @@ yyparse () | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -3804,14 +3577,14 @@ yyparse () yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -3822,13 +3595,9 @@ yyparse () if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - - -/* Line 2050 of yacc.c */ -#line 1604 "../../ntpd/ntp_parser.y" +#line 1615 "../../ntpd/ntp_parser.y" /* yacc.c:1906 */ void diff --git a/contrib/ntp/ntpd/ntp_parser.h b/contrib/ntp/ntpd/ntp_parser.h index b474fc24113c..1ec7f8cc69af 100644 --- a/contrib/ntp/ntpd/ntp_parser.h +++ b/contrib/ntp/ntpd/ntp_parser.h @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 3.0.2. */ /* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -26,13 +26,13 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef YY_YY_NTP_PARSER_H_INCLUDED -# define YY_YY_NTP_PARSER_H_INCLUDED -/* Enabling traces. */ +#ifndef YY_YY__NTPD_NTP_PARSER_H_INCLUDED +# define YY_YY__NTPD_NTP_PARSER_H_INCLUDED +/* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif @@ -40,204 +40,203 @@ extern int yydebug; #endif -/* Tokens. */ +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_Abbrev = 258, - T_Age = 259, - T_All = 260, - T_Allan = 261, - T_Allpeers = 262, - T_Auth = 263, - T_Autokey = 264, - T_Automax = 265, - T_Average = 266, - T_Bclient = 267, - T_Beacon = 268, - T_Broadcast = 269, - T_Broadcastclient = 270, - T_Broadcastdelay = 271, - T_Burst = 272, - T_Calibrate = 273, - T_Ceiling = 274, - T_Clockstats = 275, - T_Cohort = 276, - T_ControlKey = 277, - T_Crypto = 278, - T_Cryptostats = 279, - T_Ctl = 280, - T_Day = 281, - T_Default = 282, - T_Digest = 283, - T_Disable = 284, - T_Discard = 285, - T_Dispersion = 286, - T_Double = 287, - T_Driftfile = 288, - T_Drop = 289, - T_Dscp = 290, - T_Ellipsis = 291, - T_Enable = 292, - T_End = 293, - T_False = 294, - T_File = 295, - T_Filegen = 296, - T_Filenum = 297, - T_Flag1 = 298, - T_Flag2 = 299, - T_Flag3 = 300, - T_Flag4 = 301, - T_Flake = 302, - T_Floor = 303, - T_Freq = 304, - T_Fudge = 305, - T_Host = 306, - T_Huffpuff = 307, - T_Iburst = 308, - T_Ident = 309, - T_Ignore = 310, - T_Incalloc = 311, - T_Incmem = 312, - T_Initalloc = 313, - T_Initmem = 314, - T_Includefile = 315, - T_Integer = 316, - T_Interface = 317, - T_Intrange = 318, - T_Io = 319, - T_Ipv4 = 320, - T_Ipv4_flag = 321, - T_Ipv6 = 322, - T_Ipv6_flag = 323, - T_Kernel = 324, - T_Key = 325, - T_Keys = 326, - T_Keysdir = 327, - T_Kod = 328, - T_Mssntp = 329, - T_Leapfile = 330, - T_Leapsmearinterval = 331, - T_Limited = 332, - T_Link = 333, - T_Listen = 334, - T_Logconfig = 335, - T_Logfile = 336, - T_Loopstats = 337, - T_Lowpriotrap = 338, - T_Manycastclient = 339, - T_Manycastserver = 340, - T_Mask = 341, - T_Maxage = 342, - T_Maxclock = 343, - T_Maxdepth = 344, - T_Maxdist = 345, - T_Maxmem = 346, - T_Maxpoll = 347, - T_Mdnstries = 348, - T_Mem = 349, - T_Memlock = 350, - T_Minclock = 351, - T_Mindepth = 352, - T_Mindist = 353, - T_Minimum = 354, - T_Minpoll = 355, - T_Minsane = 356, - T_Mode = 357, - T_Mode7 = 358, - T_Monitor = 359, - T_Month = 360, - T_Mru = 361, - T_Multicastclient = 362, - T_Nic = 363, - T_Nolink = 364, - T_Nomodify = 365, - T_Nomrulist = 366, - T_None = 367, - T_Nonvolatile = 368, - T_Nopeer = 369, - T_Noquery = 370, - T_Noselect = 371, - T_Noserve = 372, - T_Notrap = 373, - T_Notrust = 374, - T_Ntp = 375, - T_Ntpport = 376, - T_NtpSignDsocket = 377, - T_Orphan = 378, - T_Orphanwait = 379, - T_Panic = 380, - T_Peer = 381, - T_Peerstats = 382, - T_Phone = 383, - T_Pid = 384, - T_Pidfile = 385, - T_Pool = 386, - T_Port = 387, - T_Preempt = 388, - T_Prefer = 389, - T_Protostats = 390, - T_Pw = 391, - T_Randfile = 392, - T_Rawstats = 393, - T_Refid = 394, - T_Requestkey = 395, - T_Reset = 396, - T_Restrict = 397, - T_Revoke = 398, - T_Rlimit = 399, - T_Saveconfigdir = 400, - T_Server = 401, - T_Setvar = 402, - T_Source = 403, - T_Stacksize = 404, - T_Statistics = 405, - T_Stats = 406, - T_Statsdir = 407, - T_Step = 408, - T_Stepback = 409, - T_Stepfwd = 410, - T_Stepout = 411, - T_Stratum = 412, - T_String = 413, - T_Sys = 414, - T_Sysstats = 415, - T_Tick = 416, - T_Time1 = 417, - T_Time2 = 418, - T_Timer = 419, - T_Timingstats = 420, - T_Tinker = 421, - T_Tos = 422, - T_Trap = 423, - T_True = 424, - T_Trustedkey = 425, - T_Ttl = 426, - T_Type = 427, - T_U_int = 428, - T_Unconfig = 429, - T_Unpeer = 430, - T_Version = 431, - T_WanderThreshold = 432, - T_Week = 433, - T_Wildcard = 434, - T_Xleave = 435, - T_Year = 436, - T_Flag = 437, - T_EOC = 438, - T_Simulate = 439, - T_Beep_Delay = 440, - T_Sim_Duration = 441, - T_Server_Offset = 442, - T_Duration = 443, - T_Freq_Offset = 444, - T_Wander = 445, - T_Jitter = 446, - T_Prop_Delay = 447, - T_Proc_Delay = 448 - }; + enum yytokentype + { + T_Abbrev = 258, + T_Age = 259, + T_All = 260, + T_Allan = 261, + T_Allpeers = 262, + T_Auth = 263, + T_Autokey = 264, + T_Automax = 265, + T_Average = 266, + T_Bclient = 267, + T_Beacon = 268, + T_Broadcast = 269, + T_Broadcastclient = 270, + T_Broadcastdelay = 271, + T_Burst = 272, + T_Calibrate = 273, + T_Ceiling = 274, + T_Clockstats = 275, + T_Cohort = 276, + T_ControlKey = 277, + T_Crypto = 278, + T_Cryptostats = 279, + T_Ctl = 280, + T_Day = 281, + T_Default = 282, + T_Digest = 283, + T_Disable = 284, + T_Discard = 285, + T_Dispersion = 286, + T_Double = 287, + T_Driftfile = 288, + T_Drop = 289, + T_Dscp = 290, + T_Ellipsis = 291, + T_Enable = 292, + T_End = 293, + T_False = 294, + T_File = 295, + T_Filegen = 296, + T_Filenum = 297, + T_Flag1 = 298, + T_Flag2 = 299, + T_Flag3 = 300, + T_Flag4 = 301, + T_Flake = 302, + T_Floor = 303, + T_Freq = 304, + T_Fudge = 305, + T_Host = 306, + T_Huffpuff = 307, + T_Iburst = 308, + T_Ident = 309, + T_Ignore = 310, + T_Incalloc = 311, + T_Incmem = 312, + T_Initalloc = 313, + T_Initmem = 314, + T_Includefile = 315, + T_Integer = 316, + T_Interface = 317, + T_Intrange = 318, + T_Io = 319, + T_Ipv4 = 320, + T_Ipv4_flag = 321, + T_Ipv6 = 322, + T_Ipv6_flag = 323, + T_Kernel = 324, + T_Key = 325, + T_Keys = 326, + T_Keysdir = 327, + T_Kod = 328, + T_Mssntp = 329, + T_Leapfile = 330, + T_Leapsmearinterval = 331, + T_Limited = 332, + T_Link = 333, + T_Listen = 334, + T_Logconfig = 335, + T_Logfile = 336, + T_Loopstats = 337, + T_Lowpriotrap = 338, + T_Manycastclient = 339, + T_Manycastserver = 340, + T_Mask = 341, + T_Maxage = 342, + T_Maxclock = 343, + T_Maxdepth = 344, + T_Maxdist = 345, + T_Maxmem = 346, + T_Maxpoll = 347, + T_Mdnstries = 348, + T_Mem = 349, + T_Memlock = 350, + T_Minclock = 351, + T_Mindepth = 352, + T_Mindist = 353, + T_Minimum = 354, + T_Minpoll = 355, + T_Minsane = 356, + T_Mode = 357, + T_Mode7 = 358, + T_Monitor = 359, + T_Month = 360, + T_Mru = 361, + T_Multicastclient = 362, + T_Nic = 363, + T_Nolink = 364, + T_Nomodify = 365, + T_Nomrulist = 366, + T_None = 367, + T_Nonvolatile = 368, + T_Nopeer = 369, + T_Noquery = 370, + T_Noselect = 371, + T_Noserve = 372, + T_Notrap = 373, + T_Notrust = 374, + T_Ntp = 375, + T_Ntpport = 376, + T_NtpSignDsocket = 377, + T_Orphan = 378, + T_Orphanwait = 379, + T_Panic = 380, + T_Peer = 381, + T_Peerstats = 382, + T_Phone = 383, + T_Pid = 384, + T_Pidfile = 385, + T_Pool = 386, + T_Port = 387, + T_Preempt = 388, + T_Prefer = 389, + T_Protostats = 390, + T_Pw = 391, + T_Randfile = 392, + T_Rawstats = 393, + T_Refid = 394, + T_Requestkey = 395, + T_Reset = 396, + T_Restrict = 397, + T_Revoke = 398, + T_Rlimit = 399, + T_Saveconfigdir = 400, + T_Server = 401, + T_Setvar = 402, + T_Source = 403, + T_Stacksize = 404, + T_Statistics = 405, + T_Stats = 406, + T_Statsdir = 407, + T_Step = 408, + T_Stepback = 409, + T_Stepfwd = 410, + T_Stepout = 411, + T_Stratum = 412, + T_String = 413, + T_Sys = 414, + T_Sysstats = 415, + T_Tick = 416, + T_Time1 = 417, + T_Time2 = 418, + T_Timer = 419, + T_Timingstats = 420, + T_Tinker = 421, + T_Tos = 422, + T_Trap = 423, + T_True = 424, + T_Trustedkey = 425, + T_Ttl = 426, + T_Type = 427, + T_U_int = 428, + T_Unconfig = 429, + T_Unpeer = 430, + T_Version = 431, + T_WanderThreshold = 432, + T_Week = 433, + T_Wildcard = 434, + T_Xleave = 435, + T_Year = 436, + T_Flag = 437, + T_EOC = 438, + T_Simulate = 439, + T_Beep_Delay = 440, + T_Sim_Duration = 441, + T_Server_Offset = 442, + T_Duration = 443, + T_Freq_Offset = 444, + T_Wander = 445, + T_Jitter = 446, + T_Prop_Delay = 447, + T_Proc_Delay = 448 + }; #endif /* Tokens. */ #define T_Abbrev 258 @@ -432,13 +431,12 @@ extern int yydebug; #define T_Prop_Delay 447 #define T_Proc_Delay 448 - - +/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE +typedef union YYSTYPE YYSTYPE; +union YYSTYPE { -/* Line 2053 of yacc.c */ -#line 51 "../../ntpd/ntp_parser.y" +#line 51 "../../ntpd/ntp_parser.y" /* yacc.c:1909 */ char * String; double Double; @@ -457,29 +455,15 @@ typedef union YYSTYPE script_info * Sim_script; script_info_fifo * Sim_script_fifo; - -/* Line 2053 of yacc.c */ -#line 463 "ntp_parser.h" -} YYSTYPE; +#line 459 "../../ntpd/ntp_parser.h" /* yacc.c:1909 */ +}; # define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif + extern YYSTYPE yylval; -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ -#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */ +#endif /* !YY_YY__NTPD_NTP_PARSER_H_INCLUDED */ diff --git a/contrib/ntp/ntpd/ntp_peer.c b/contrib/ntp/ntpd/ntp_peer.c index d42d804d444d..cc23a382309c 100644 --- a/contrib/ntp/ntpd/ntp_peer.c +++ b/contrib/ntp/ntpd/ntp_peer.c @@ -718,9 +718,13 @@ refresh_all_peerinterfaces(void) /* * this is called when the interface list has changed * give all peers a chance to find a better interface + * but only if either they don't have an address already + * or if the one they have hasn't worked for a while. */ - for (p = peer_list; p != NULL; p = p->p_link) - peer_refresh_interface(p); + for (p = peer_list; p != NULL; p = p->p_link) { + if (!(p->dstadr && (p->reach & 0x3))) // Bug 2849 XOR 2043 + peer_refresh_interface(p); + } } @@ -746,6 +750,8 @@ newpeer( struct peer * peer; u_int hash; + DEBUG_REQUIRE(srcadr); + #ifdef AUTOKEY /* * If Autokey is requested but not configured, complain loudly. @@ -764,7 +770,7 @@ newpeer( /* * For now only pool associations have a hostname. */ - NTP_INSIST(NULL == hostname || (MDF_POOL & cast_flags)); + INSIST(NULL == hostname || (MDF_POOL & cast_flags)); /* * First search from the beginning for an association with given @@ -817,6 +823,7 @@ newpeer( if (peer_free_count == 0) getmorepeermem(); UNLINK_HEAD_SLIST(peer, peer_free, p_link); + INSIST(peer != NULL); peer_free_count--; peer_associations++; if (FLAG_PREEMPT & flags) diff --git a/contrib/ntp/ntpd/ntp_proto.c b/contrib/ntp/ntpd/ntp_proto.c index 40624066746f..2a15d7242647 100644 --- a/contrib/ntp/ntpd/ntp_proto.c +++ b/contrib/ntp/ntpd/ntp_proto.c @@ -28,14 +28,27 @@ * This macro defines the authentication state. If x is 1 authentication * is required; othewise it is optional. */ -#define AUTH(x, y) ((x) ? (y) == AUTH_OK : (y) == AUTH_OK || \ - (y) == AUTH_NONE) +#define AUTH(x, y) ((x) ? (y) == AUTH_OK \ + : (y) == AUTH_OK || (y) == AUTH_NONE) #define AUTH_NONE 0 /* authentication not required */ #define AUTH_OK 1 /* authentication OK */ #define AUTH_ERROR 2 /* authentication error */ #define AUTH_CRYPTO 3 /* crypto_NAK */ +/* + * Set up Kiss Code values + */ + +enum kiss_codes { + NOKISS, /* No Kiss Code */ + RATEKISS, /* Rate limit Kiss Code */ + DENYKISS, /* Deny Kiss */ + RSTRKISS, /* Restricted Kiss */ + XKISS, /* Experimental Kiss */ + UNKNOWNKISS /* Unknown Kiss Code */ +}; + /* * traffic shaping parameters */ @@ -139,6 +152,7 @@ u_long sys_declined; /* declined */ u_long sys_limitrejected; /* rate exceeded */ u_long sys_kodsent; /* KoD sent */ +static int kiss_code_check(u_char hisleap, u_char hisstratum, u_char hismode, u_int32 refid); static double root_distance (struct peer *); static void clock_combine (peer_select *, int, int); static void peer_xmit (struct peer *); @@ -185,7 +199,34 @@ set_sys_leap(u_char new_sys_leap) { } } +/* + * Kiss Code check + */ +int kiss_code_check(u_char hisleap, u_char hisstratum, u_char hismode, u_int32 refid) { + if ( hismode == MODE_SERVER + && hisleap == LEAP_NOTINSYNC + && hisstratum == STRATUM_UNSPEC) { + if(memcmp(&refid,"RATE", 4) == 0) { + return (RATEKISS); + } + else if(memcmp(&refid,"DENY", 4) == 0) { + return (DENYKISS); + } + else if(memcmp(&refid,"RSTR", 4) == 0) { + return (RSTRKISS); + } + else if(memcmp(&refid,"X", 1) == 0) { + return (XKISS); + } + else { + return (UNKNOWNKISS); + } + } + else { + return (NOKISS); + } +} /* * transmit - transmit procedure called by poll timeout */ @@ -235,8 +276,8 @@ transmit( peer->unreach = 0; peer->ttl = 0; peer_xmit(peer); - } else if (sys_survivors < sys_minclock || - peer_associations < sys_maxclock) { + } else if ( sys_survivors < sys_minclock + || peer_associations < sys_maxclock) { if (peer->ttl < (u_int32)sys_ttlmax) peer->ttl++; peer_xmit(peer); @@ -260,9 +301,9 @@ transmit( */ if (peer->cast_flags & MDF_POOL) { peer->outdate = current_time; - if ((peer_associations <= 2 * sys_maxclock) && - (peer_associations < sys_maxclock || - sys_survivors < sys_minclock)) + if ( (peer_associations <= 2 * sys_maxclock) + && ( peer_associations < sys_maxclock + || sys_survivors < sys_minclock)) pool_xmit(peer); poll_update(peer, hpoll); return; @@ -297,8 +338,8 @@ transmit( peer_unfit(peer); report_event(PEVNT_UNREACH, peer, NULL); } - if ((peer->flags & FLAG_IBURST) && - peer->retry == 0) + if ( (peer->flags & FLAG_IBURST) + && peer->retry == 0) peer->retry = NTP_RETRY; } else { @@ -312,8 +353,9 @@ transmit( hpoll = sys_poll; if (!(peer->flags & FLAG_PREEMPT)) peer->unreach = 0; - if ((peer->flags & FLAG_BURST) && peer->retry == - 0 && !peer_unfit(peer)) + if ( (peer->flags & FLAG_BURST) + && peer->retry == 0 + && !peer_unfit(peer)) peer->retry = NTP_RETRY; } @@ -334,9 +376,9 @@ transmit( unpeer(peer); return; } - if ((peer->flags & FLAG_PREEMPT) && - (peer_associations > sys_maxclock) && - score_all(peer)) { + if ( (peer->flags & FLAG_PREEMPT) + && (peer_associations > sys_maxclock) + && score_all(peer)) { report_event(PEVNT_RESTART, peer, "timeout"); peer_clear(peer, "TIME"); unpeer(peer); @@ -392,6 +434,7 @@ receive( u_char hismode; /* packet mode */ u_char hisstratum; /* packet stratum */ u_short restrict_mask; /* restrict bits */ + int kissCode = NOKISS; /* Kiss Code */ int has_mac; /* length of MAC field */ int authlen; /* offset of MAC field */ int is_authentic = 0; /* cryptosum ok */ @@ -483,8 +526,8 @@ receive( */ if (hisversion == NTP_VERSION) { sys_newversion++; /* new version */ - } else if (!(restrict_mask & RES_VERSION) && hisversion >= - NTP_OLDVERSION) { + } else if ( !(restrict_mask & RES_VERSION) + && hisversion >= NTP_OLDVERSION) { sys_oldversion++; /* previous version */ } else { sys_badlength++; @@ -538,8 +581,9 @@ receive( } else { opcode = ntohl(((u_int32 *)pkt)[authlen / 4]); len = opcode & 0xffff; - if (len % 4 != 0 || len < 4 || (int)len + - authlen > rbufp->recv_length) { + if ( len % 4 != 0 + || len < 4 + || (int)len + authlen > rbufp->recv_length) { sys_badlength++; return; /* bad length */ } @@ -549,13 +593,13 @@ receive( * sys_groupname is non-NULL, there must be * a group name provided to elicit a response. */ - if ((opcode & 0x3fff0000) == CRYPTO_ASSOC && - sys_groupname != NULL) { + if ( (opcode & 0x3fff0000) == CRYPTO_ASSOC + && sys_groupname != NULL) { ep = (struct exten *)&((u_int32 *)pkt)[authlen / 4]; hostlen = ntohl(ep->vallen); - if (hostlen >= sizeof(hostname) || - hostlen > len - - offsetof(struct exten, pkt)) { + if ( hostlen >= sizeof(hostname) + || hostlen > len - + offsetof(struct exten, pkt)) { sys_badlength++; return; /* bad length */ } @@ -599,8 +643,9 @@ receive( restrict_mask = ntp_monitor(rbufp, restrict_mask); if (restrict_mask & RES_LIMITED) { sys_limitrejected++; - if (!(restrict_mask & RES_KOD) || MODE_BROADCAST == - hismode || MODE_SERVER == hismode) { + if ( !(restrict_mask & RES_KOD) + || MODE_BROADCAST == hismode + || MODE_SERVER == hismode) { if (MODE_SERVER == hismode) DPRINTF(1, ("Possibly self-induced rate limiting of MODE_SERVER from %s\n", stoa(&rbufp->recv_srcadr))); @@ -698,10 +743,11 @@ receive( * This is described in Microsoft's WSPP docs, in MS-SNTP: * http://msdn.microsoft.com/en-us/library/cc212930.aspx */ - } else if (has_mac == MAX_MD5_LEN && (restrict_mask & RES_MSSNTP) && - (retcode == AM_FXMIT || retcode == AM_NEWPASS) && - (memcmp(zero_key, (char *)pkt + authlen + 4, MAX_MD5_LEN - 4) == - 0)) { + } else if ( has_mac == MAX_MD5_LEN + && (restrict_mask & RES_MSSNTP) + && (retcode == AM_FXMIT || retcode == AM_NEWPASS) + && (memcmp(zero_key, (char *)pkt + authlen + 4, + MAX_MD5_LEN - 4) == 0)) { is_authentic = AUTH_NONE; #endif /* HAVE_NTP_SIGND */ @@ -754,8 +800,9 @@ receive( * mobilized. However, if this is from * the wildcard interface, game over. */ - if (crypto_flags && rbufp->dstadr == - ANY_INTERFACE_CHOOSE(&rbufp->recv_srcadr)) { + if ( crypto_flags + && rbufp->dstadr == + ANY_INTERFACE_CHOOSE(&rbufp->recv_srcadr)) { sys_restricted++; return; /* no wildcard */ } @@ -882,10 +929,10 @@ receive( * stratum is greater than the manycaster or the * manycaster has already synchronized to us. */ - if (sys_leap == LEAP_NOTINSYNC || sys_stratum >= - hisstratum || (!sys_cohort && sys_stratum == - hisstratum + 1) || rbufp->dstadr->addr_refid == - pkt->refid) { + if ( sys_leap == LEAP_NOTINSYNC + || sys_stratum >= hisstratum + || (!sys_cohort && sys_stratum == hisstratum + 1) + || rbufp->dstadr->addr_refid == pkt->refid) { sys_declined++; return; /* no help */ } @@ -933,9 +980,10 @@ receive( sys_restricted++; return; /* not enabled */ } - if (!AUTH((!(peer2->cast_flags & MDF_POOL) && - sys_authenticate) | (restrict_mask & (RES_NOPEER | - RES_DONTTRUST)), is_authentic)) { + if (!AUTH( (!(peer2->cast_flags & MDF_POOL) + && sys_authenticate) + || (restrict_mask & (RES_NOPEER | + RES_DONTTRUST)), is_authentic)) { sys_restricted++; return; /* access denied */ } @@ -944,8 +992,9 @@ receive( * Do not respond if unsynchronized or stratum is below * the floor or at or above the ceiling. */ - if (hisleap == LEAP_NOTINSYNC || hisstratum < - sys_floor || hisstratum >= sys_ceiling) { + if ( hisleap == LEAP_NOTINSYNC + || hisstratum < sys_floor + || hisstratum >= sys_ceiling) { sys_declined++; return; /* no help */ } @@ -1007,8 +1056,9 @@ receive( * Do not respond if unsynchronized or stratum is below * the floor or at or above the ceiling. */ - if (hisleap == LEAP_NOTINSYNC || hisstratum < - sys_floor || hisstratum >= sys_ceiling) { + if ( hisleap == LEAP_NOTINSYNC + || hisstratum < sys_floor + || hisstratum >= sys_ceiling) { sys_declined++; return; /* no help */ } @@ -1018,8 +1068,8 @@ receive( * Do not respond if Autokey and the opcode is not a * CRYPTO_ASSOC response with association ID. */ - if (crypto_flags && skeyid > NTP_MAXKEY && (opcode & - 0xffff0000) != (CRYPTO_ASSOC | CRYPTO_RESP)) { + if ( crypto_flags && skeyid > NTP_MAXKEY + && (opcode & 0xffff0000) != (CRYPTO_ASSOC | CRYPTO_RESP)) { sys_declined++; return; /* protocol error */ } @@ -1133,6 +1183,24 @@ receive( sys_restricted++; return; } + /* [Bug 2941] + * If we got here, the packet isn't part of an + * existing association, it isn't correctly + * authenticated, and it didn't meet either of + * the previous two special cases so we should + * just drop it on the floor. For example, + * crypto-NAKs (is_authentic == AUTH_CRYPTO) + * will make it this far. This is just + * debug-printed and not logged to avoid log + * flooding. + */ + DPRINTF(1, ("receive: at %ld refusing to mobilize passive association" + " with unknown peer %s mode %d keyid %08x len %d auth %d\n", + current_time, stoa(&rbufp->recv_srcadr), + hismode, skeyid, (authlen + has_mac), + is_authentic)); + sys_declined++; + return; } /* @@ -1145,8 +1213,8 @@ receive( * we will spin an ephemeral association in response to * MODE_ACTIVE KoDs, which will time out eventually. */ - if (hisleap != LEAP_NOTINSYNC && (hisstratum < - sys_floor || hisstratum >= sys_ceiling)) { + if ( hisleap != LEAP_NOTINSYNC + && (hisstratum < sys_floor || hisstratum >= sys_ceiling)) { sys_declined++; return; /* no help */ } @@ -1205,9 +1273,9 @@ receive( * have a public key ID; if not, the packet must have a * symmetric key ID. */ - if (is_authentic != AUTH_CRYPTO && (((peer->flags & - FLAG_SKEY) && skeyid <= NTP_MAXKEY) || (!(peer->flags & - FLAG_SKEY) && skeyid > NTP_MAXKEY))) { + if ( is_authentic != AUTH_CRYPTO + && ( ((peer->flags & FLAG_SKEY) && skeyid <= NTP_MAXKEY) + || (!(peer->flags & FLAG_SKEY) && skeyid > NTP_MAXKEY))) { sys_badauth++; return; } @@ -1256,16 +1324,23 @@ receive( * Check for bogus packet in basic mode. If found, switch to * interleaved mode and resynchronize, but only after confirming * the packet is not bogus in symmetric interleaved mode. + * + * This could also mean somebody is forging packets claiming to + * be from us, attempting to cause our server to KoD us. */ } else if (peer->flip == 0) { if (!L_ISEQU(&p_org, &peer->aorg)) { peer->bogusorg++; peer->flash |= TEST2; /* bogus */ - if (!L_ISZERO(&peer->dst) && L_ISEQU(&p_org, - &peer->dst)) { + msyslog(LOG_INFO, + "receive: Unexpected origin timestamp from %s", + ntoa(&peer->srcadr)); + if ( !L_ISZERO(&peer->dst) + && L_ISEQU(&p_org, &peer->dst)) { peer->flip = 1; report_event(PEVNT_XLEAVE, peer, NULL); } + return; /* Bogus packet, we are done */ } else { L_CLR(&peer->aorg); } @@ -1282,11 +1357,12 @@ receive( * can happen if a packet is lost, duplicated or crossed. If * found, flip and resynchronize. */ - } else if (!L_ISZERO(&peer->dst) && !L_ISEQU(&p_org, - &peer->dst)) { + } else if ( !L_ISZERO(&peer->dst) + && !L_ISEQU(&p_org, &peer->dst)) { peer->bogusorg++; peer->flags |= FLAG_XBOGUS; peer->flash |= TEST2; /* bogus */ + return; /* Bogus packet, we are done */ } /* @@ -1321,8 +1397,8 @@ receive( report_event(PEVNT_AUTH, peer, "digest"); peer->flash |= TEST5; /* bad auth */ peer->badauth++; - if (has_mac && - (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)) + if ( has_mac + && (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)) fast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask); if (peer->flags & FLAG_PREEMPT) { unpeer(peer); @@ -1351,11 +1427,22 @@ receive( * this maximum and advance the headway to give the sender some * headroom. Very intricate. */ + + /* + * Check for any kiss codes. Note this is only used when a server + * responds to a packet request + */ + + kissCode = kiss_code_check(hisleap, hisstratum, hismode, pkt->refid); + + /* + * Check to see if this is a RATE Kiss Code + * Currently this kiss code will accept whatever poll + * rate that the server sends + */ peer->ppoll = max(peer->minpoll, pkt->ppoll); - if (hismode == MODE_SERVER && hisleap == LEAP_NOTINSYNC && - hisstratum == STRATUM_UNSPEC && memcmp(&pkt->refid, - "RATE", 4) == 0) { - peer->selbroken++; + if (kissCode == RATEKISS) { + peer->selbroken++; /* Increment the KoD count */ report_event(PEVNT_RATE, peer, NULL); if (pkt->ppoll > peer->minpoll) peer->minpoll = peer->ppoll; @@ -1364,6 +1451,11 @@ receive( poll_update(peer, pkt->ppoll); return; /* kiss-o'-death */ } + if (kissCode != NOKISS) { + peer->selbroken++; /* Increment the KoD count */ + return; /* Drop any other kiss code packets */ + } + /* * That was hard and I am sweaty, but the packet is squeaky @@ -1455,8 +1547,8 @@ receive( int i; for (i = 0; ; i++) { - if (tkeyid == peer->pkeyid || - tkeyid == ap->key) { + if ( tkeyid == peer->pkeyid + || tkeyid == ap->key) { peer->flash &= ~TEST8; peer->pkeyid = skeyid; ap->seq -= i; @@ -1589,8 +1681,8 @@ process_packet( * Verify the server is synchronized; that is, the leap bits, * stratum and root distance are valid. */ - if (pleap == LEAP_NOTINSYNC || /* test 6 */ - pstratum < sys_floor || pstratum >= sys_ceiling) + if ( pleap == LEAP_NOTINSYNC /* test 6 */ + || pstratum < sys_floor || pstratum >= sys_ceiling) peer->flash |= TEST6; /* bad synch or strat */ if (p_del / 2 + p_disp >= MAXDISPERSE) /* test 7 */ peer->flash |= TEST7; /* bad header */ @@ -1823,8 +1915,9 @@ process_packet( * client mode when the client is fit and the autokey dance is * complete. */ - if ((FLAG_BC_VOL & peer->flags) && MODE_CLIENT == peer->hmode && - !(TEST11 & peer_unfit(peer))) { /* distance exceeded */ + if ( (FLAG_BC_VOL & peer->flags) + && MODE_CLIENT == peer->hmode + && !(TEST11 & peer_unfit(peer))) { /* distance exceeded */ #ifdef AUTOKEY if (peer->flags & FLAG_SKEY) { if (!(~peer->crypto & CRYPTO_FLAG_ALL)) @@ -1865,8 +1958,8 @@ clock_update( sys_poll = peer->maxpoll; poll_update(peer, sys_poll); sys_stratum = min(peer->stratum + 1, STRATUM_UNSPEC); - if (peer->stratum == STRATUM_REFCLOCK || - peer->stratum == STRATUM_UNSPEC) + if ( peer->stratum == STRATUM_REFCLOCK + || peer->stratum == STRATUM_UNSPEC) sys_refid = peer->refid; else sys_refid = addr2refid(&peer->srcadr); @@ -1992,12 +2085,12 @@ clock_update( * once is mostly harmless.) */ if (leapsec == LSPROX_NOWARN) { - if (leap_vote_ins > leap_vote_del + if ( leap_vote_ins > leap_vote_del && leap_vote_ins > sys_survivors / 2) { get_systime(&now); leapsec_add_dyn(TRUE, now.l_ui, NULL); } - if (leap_vote_del > leap_vote_ins + if ( leap_vote_del > leap_vote_ins && leap_vote_del > sys_survivors / 2) { get_systime(&now); leapsec_add_dyn(FALSE, now.l_ui, NULL); @@ -2320,8 +2413,8 @@ clock_filter( m = 0; for (i = 0; i < NTP_SHIFT; i++) { peer->filter_order[i] = (u_char) ord[i]; - if (dst[i] >= MAXDISPERSE || (m >= 2 && dst[i] >= - sys_maxdist)) + if ( dst[i] >= MAXDISPERSE + || (m >= 2 && dst[i] >= sys_maxdist)) continue; m++; } @@ -2367,10 +2460,11 @@ clock_filter( * than twice the host poll interval, consider the new sample * a popcorn spike and ignore it. */ - if (peer->disp < sys_maxdist && peer->filter_disp[k] < - sys_maxdist && etemp > CLOCK_SGATE * peer->jitter && - peer->filter_epoch[k] - peer->epoch < 2. * - ULOGTOD(peer->hpoll)) { + if ( peer->disp < sys_maxdist + && peer->filter_disp[k] < sys_maxdist + && etemp > CLOCK_SGATE * peer->jitter + && peer->filter_epoch[k] - peer->epoch + < 2. * ULOGTOD(peer->hpoll)) { snprintf(tbuf, sizeof(tbuf), "%.6f s", etemp); report_event(PEVNT_POPCORN, peer, tbuf); return; @@ -2547,14 +2641,14 @@ clock_select(void) if (!(peer->flags & FLAG_PREFER)) { switch (peer->refclktype) { case REFCLK_LOCALCLOCK: - if (current_time > orphwait && - typelocal == NULL) + if ( current_time > orphwait + && typelocal == NULL) typelocal = peer; continue; case REFCLK_ACTS: - if (current_time > orphwait && - typeacts == NULL) + if ( current_time > orphwait + && typeacts == NULL) typeacts = peer; continue; } @@ -2684,8 +2778,10 @@ clock_select(void) peer = peers[i].peer; h = peers[i].synch; - if ((high <= low || peer->offset + h < low || - peer->offset - h > high) && !(peer->flags & FLAG_TRUE)) + if (( high <= low + || peer->offset + h < low + || peer->offset - h > high + ) && !(peer->flags & FLAG_TRUE)) continue; #ifdef REFCLOCK @@ -2742,7 +2838,7 @@ clock_select(void) } /* - * Now, vote outlyers off the island by select jitter weighted + * Now, vote outliers off the island by select jitter weighted * by root distance. Continue voting as long as there are more * than sys_minclock survivors and the select jitter of the peer * with the worst metric is greater than the minimum peer @@ -2772,8 +2868,9 @@ clock_select(void) } } g = max(g, LOGTOD(sys_precision)); - if (nlist <= max(1, sys_minclock) || g <= d || - ((FLAG_TRUE | FLAG_PREFER) & peers[k].peer->flags)) + if ( nlist <= max(1, sys_minclock) + || g <= d + || ((FLAG_TRUE | FLAG_PREFER) & peers[k].peer->flags)) break; DPRINTF(3, ("select: drop %s seljit %.6f jit %.6f\n", @@ -2898,10 +2995,12 @@ clock_select(void) * if there is a prefer peer or there are no survivors and none * are required. */ - if (typepps != NULL && fabs(sys_offset) < 0.4 && - (typepps->refclktype != REFCLK_ATOM_PPS || - (typepps->refclktype == REFCLK_ATOM_PPS && (sys_prefer != - NULL || (typesystem == NULL && sys_minsane == 0))))) { + if ( typepps != NULL + && fabs(sys_offset) < 0.4 + && ( typepps->refclktype != REFCLK_ATOM_PPS + || ( typepps->refclktype == REFCLK_ATOM_PPS + && ( sys_prefer != NULL + || (typesystem == NULL && sys_minsane == 0))))) { typesystem = typepps; sys_clockhop = 0; typesystem->new_status = CTL_PST_SEL_PPS; @@ -3240,16 +3339,16 @@ peer_xmit( * autokey sequence, the autokey exchange is * used to retrieve the autokey values. */ - else if (sys_leap != LEAP_NOTINSYNC && - peer->leap != LEAP_NOTINSYNC && - !(peer->crypto & CRYPTO_FLAG_COOK)) + else if ( sys_leap != LEAP_NOTINSYNC + && peer->leap != LEAP_NOTINSYNC + && !(peer->crypto & CRYPTO_FLAG_COOK)) exten = crypto_args(peer, CRYPTO_COOK, peer->associd, NULL); else if (!(peer->crypto & CRYPTO_FLAG_AUTO)) exten = crypto_args(peer, CRYPTO_AUTO, peer->associd, NULL); - else if (peer->flags & FLAG_ASSOC && - peer->crypto & CRYPTO_FLAG_SIGN) + else if ( peer->flags & FLAG_ASSOC + && peer->crypto & CRYPTO_FLAG_SIGN) exten = crypto_args(peer, CRYPTO_AUTO | CRYPTO_RESP, peer->assoc, NULL); @@ -3693,7 +3792,7 @@ pool_xmit( pool->hostname)); else msyslog(LOG_ERR, - "unable to start pool DNS %s %m", + "unable to start pool DNS %s: %m", pool->hostname); return; } @@ -3883,8 +3982,9 @@ peer_unfit( * synchronized, (2) the server stratum is below the floor or * greater than or equal to the ceiling. */ - if (peer->leap == LEAP_NOTINSYNC || peer->stratum < sys_floor || - peer->stratum >= sys_ceiling) + if ( peer->leap == LEAP_NOTINSYNC + || peer->stratum < sys_floor + || peer->stratum >= sys_ceiling) rval |= TEST10; /* bad synch or stratum */ /* @@ -3892,8 +3992,9 @@ peer_unfit( * distance is greater than or equal to the distance threshold * plus the increment due to one host poll interval. */ - if (!(peer->flags & FLAG_REFCLOCK) && root_distance(peer) >= - sys_maxdist + clock_phi * ULOGTOD(peer->hpoll)) + if ( !(peer->flags & FLAG_REFCLOCK) + && root_distance(peer) >= sys_maxdist + + clock_phi * ULOGTOD(peer->hpoll)) rval |= TEST11; /* distance exceeded */ /* diff --git a/contrib/ntp/ntpd/ntp_refclock.c b/contrib/ntp/ntpd/ntp_refclock.c index f0e9b9ec307d..1f16ca797106 100644 --- a/contrib/ntp/ntpd/ntp_refclock.c +++ b/contrib/ntp/ntpd/ntp_refclock.c @@ -1049,7 +1049,7 @@ refclock_control( if (NULL == peer) return; - NTP_INSIST(peer->procptr != NULL); + INSIST(peer->procptr != NULL); pp = peer->procptr; /* diff --git a/contrib/ntp/ntpd/ntp_request.c b/contrib/ntp/ntpd/ntp_request.c index 8ffebad32882..6073f99c456d 100644 --- a/contrib/ntp/ntpd/ntp_request.c +++ b/contrib/ntp/ntpd/ntp_request.c @@ -1757,10 +1757,12 @@ do_restrict( } /* - * Looks okay, try it out + * Looks okay, try it out. Needs to reload data pointer and + * item counter. (Talos-CAN-0052) */ ZERO_SOCK(&matchaddr); ZERO_SOCK(&matchmask); + items = INFO_NITEMS(inpkt->err_nitems); datap = inpkt->u.data; while (items-- > 0) { @@ -1917,9 +1919,11 @@ reset_peer( } /* - * Now do it in earnest. + * Now do it in earnest. Needs to reload data pointer and item + * counter. (Talos-CAN-0052) */ - + + items = INFO_NITEMS(inpkt->err_nitems); datap = inpkt->u.data; while (items-- > 0) { ZERO(cp); diff --git a/contrib/ntp/ntpd/ntp_restrict.c b/contrib/ntp/ntpd/ntp_restrict.c index 9948d54d9e90..82bbaef25741 100644 --- a/contrib/ntp/ntpd/ntp_restrict.c +++ b/contrib/ntp/ntpd/ntp_restrict.c @@ -173,7 +173,7 @@ alloc_res4(void) LINK_SLIST(resfree4, res, link); res = (void *)((char *)res - cb); } - NTP_INSIST(rl == res); + INSIST(rl == res); /* allocate the first */ return res; } @@ -199,7 +199,7 @@ alloc_res6(void) LINK_SLIST(resfree6, res, link); res = (void *)((char *)res - cb); } - NTP_INSIST(rl == res); + INSIST(rl == res); /* allocate the first */ return res; } @@ -223,7 +223,7 @@ free_res( else plisthead = &restrictlist4; UNLINK_SLIST(unlinked, *plisthead, res, link, restrict_u); - NTP_INSIST(unlinked == res); + INSIST(unlinked == res); if (v6) { zero_mem(res, V6_SIZEOF_RESTRICT_U); @@ -291,7 +291,7 @@ match_restrict6_addr( for (res = restrictlist6; res != NULL; res = next) { next = res->link; - NTP_INSIST(next != res); + INSIST(next != res); if (res->expire && res->expire <= current_time) free_res(res, v6); @@ -435,6 +435,9 @@ restrictions( match = match_restrict4_addr(SRCADR(srcadr), SRCPORT(srcadr)); + + INSIST(match != NULL); + match->count++; /* * res_not_found counts only use of the final default @@ -461,6 +464,7 @@ restrictions( return (int)RES_IGNORE; match = match_restrict6_addr(pin6, SRCPORT(srcadr)); + INSIST(match != NULL); match->count++; if (&restrict_def6 == match) res_not_found++; @@ -494,8 +498,8 @@ hack_restrict( op, stoa(resaddr), stoa(resmask), mflags, flags)); if (NULL == resaddr) { - NTP_REQUIRE(NULL == resmask); - NTP_REQUIRE(RESTRICT_FLAGS == op); + REQUIRE(NULL == resmask); + REQUIRE(RESTRICT_FLAGS == op); restrict_source_flags = flags; restrict_source_mflags = mflags; restrict_source_enabled = 1; @@ -503,9 +507,13 @@ hack_restrict( } ZERO(match); + +#if 0 /* silence VC9 potentially uninit warnings */ + // HMS: let's use a compiler-specific "enable" for this. res = NULL; v6 = 0; +#endif if (IS_IPV4(resaddr)) { v6 = 0; @@ -528,7 +536,7 @@ hack_restrict( &match.u.v6.mask); } else /* not IPv4 nor IPv6 */ - NTP_REQUIRE(0); + REQUIRE(0); match.flags = flags; match.mflags = mflags; @@ -600,7 +608,7 @@ hack_restrict( break; default: /* unknown op */ - NTP_INSIST(0); + INSIST(0); break; } @@ -626,7 +634,7 @@ restrict_source( IS_MCAST(addr) || ISREFCLOCKADR(addr)) return; - NTP_REQUIRE(AF_INET == AF(addr) || AF_INET6 == AF(addr)); + REQUIRE(AF_INET == AF(addr) || AF_INET6 == AF(addr)); SET_HOSTMASK(&onesmask, AF(addr)); if (farewell) { @@ -647,10 +655,12 @@ restrict_source( */ if (IS_IPV4(addr)) { res = match_restrict4_addr(SRCADR(addr), SRCPORT(addr)); + INSIST(res != NULL); found_specific = (SRCADR(&onesmask) == res->u.v4.mask); } else { res = match_restrict6_addr(&SOCK_ADDR6(addr), SRCPORT(addr)); + INSIST(res != NULL); found_specific = ADDR6_EQ(&res->u.v6.mask, &SOCK_ADDR6(&onesmask)); } diff --git a/contrib/ntp/ntpd/ntp_timer.c b/contrib/ntp/ntpd/ntp_timer.c index 5cbb892e3ddd..828aa8c273bf 100644 --- a/contrib/ntp/ntpd/ntp_timer.c +++ b/contrib/ntp/ntpd/ntp_timer.c @@ -56,6 +56,12 @@ static void check_leapsec(u_int32, const time_t*, int/*BOOL*/); */ volatile int interface_interval; /* init_io() sets def. 300s */ +/* + * Initializing flag. All async routines watch this and only do their + * thing when it is clear. + */ +int initializing; + /* * Alarm flag. The mainline code imports this. */ diff --git a/contrib/ntp/ntpd/ntpd-opts.c b/contrib/ntp/ntpd/ntpd-opts.c index 2d547a18de79..1bbecfa0460d 100644 --- a/contrib/ntp/ntpd/ntpd-opts.c +++ b/contrib/ntp/ntpd/ntpd-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpd-opts.c) * - * It has been AutoGen-ed June 29, 2015 at 04:28:19 PM by AutoGen 5.18.5 + * It has been AutoGen-ed October 21, 2015 at 12:36:00 PM by AutoGen 5.18.5 * From the definitions ntpd-opts.def * and the template file options * @@ -75,7 +75,7 @@ extern FILE * option_usage_fp; * static const strings for ntpd options */ static char const ntpd_opt_strs[3129] = -/* 0 */ "ntpd 4.2.8p3\n" +/* 0 */ "ntpd 4.2.8p4\n" "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the NTP License, copies of which\n" @@ -205,12 +205,12 @@ static char const ntpd_opt_strs[3129] = /* 2900 */ "output version information and exit\0" /* 2936 */ "version\0" /* 2944 */ "NTPD\0" -/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p3\n" +/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p4\n" "Usage: %s [ - [] | --[{=| }] ]... \\\n" "\t\t[ ... ]\n\0" /* 3080 */ "http://bugs.ntp.org, bugs@ntp.org\0" /* 3114 */ "\n\0" -/* 3116 */ "ntpd 4.2.8p3"; +/* 3116 */ "ntpd 4.2.8p4"; /** * ipv4 option description with @@ -1529,7 +1529,7 @@ static void bogus_function(void) { translate option names. */ /* referenced via ntpdOptions.pzCopyright */ - puts(_("ntpd 4.2.8p3\n\ + puts(_("ntpd 4.2.8p4\n\ Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\ This is free software. It is licensed for use, modification and\n\ redistribution under the terms of the NTP License, copies of which\n\ @@ -1670,7 +1670,7 @@ implied warranty.\n")); puts(_("output version information and exit")); /* referenced via ntpdOptions.pzUsageTitle */ - puts(_("ntpd - NTP daemon program - Ver. 4.2.8p3\n\ + puts(_("ntpd - NTP daemon program - Ver. 4.2.8p4\n\ Usage: %s [ - [] | --[{=| }] ]... \\\n\ \t\t[ ... ]\n")); @@ -1678,7 +1678,7 @@ Usage: %s [ - [] | --[{=| }] ]... \\\n\ puts(_("\n")); /* referenced via ntpdOptions.pzFullVersion */ - puts(_("ntpd 4.2.8p3")); + puts(_("ntpd 4.2.8p4")); /* referenced via ntpdOptions.pzFullUsage */ puts(_("<<>>")); diff --git a/contrib/ntp/ntpd/ntpd-opts.def b/contrib/ntp/ntpd/ntpd-opts.def index dee484dbe1b4..00d35115dc43 100644 --- a/contrib/ntp/ntpd/ntpd-opts.def +++ b/contrib/ntp/ntpd/ntpd-opts.def @@ -236,6 +236,8 @@ when you have permission to do so from the owner of the target host. Finally, in the past many startup scripts would run .Xr ntpdate 1ntpdatemdoc +or +.Xr sntp 1sntpmdoc to get the system clock close to correct before starting .Xr ntpd 1ntpdmdoc , but this was never more than a mediocre hack and is no longer needed. @@ -245,7 +247,9 @@ and you still need to set the system time before starting .Nm , please open a bug report and document what is going on, and then look at using -.Xr sntp 1sntpmdoc . +.Xr sntp 1sntpmdoc +if you really need to set the clock before starting +.Nm . .Pp There is a way to start .Xr ntpd 1ntpdmdoc diff --git a/contrib/ntp/ntpd/ntpd-opts.h b/contrib/ntp/ntpd/ntpd-opts.h index 21142d8c4de2..d87c2216dcb5 100644 --- a/contrib/ntp/ntpd/ntpd-opts.h +++ b/contrib/ntp/ntpd/ntpd-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpd-opts.h) * - * It has been AutoGen-ed June 29, 2015 at 04:28:18 PM by AutoGen 5.18.5 + * It has been AutoGen-ed October 21, 2015 at 12:35:59 PM by AutoGen 5.18.5 * From the definitions ntpd-opts.def * and the template file options * @@ -106,9 +106,9 @@ typedef enum { /** count of all options for ntpd */ #define OPTION_CT 38 /** ntpd version */ -#define NTPD_VERSION "4.2.8p3" +#define NTPD_VERSION "4.2.8p4" /** Full ntpd version text */ -#define NTPD_FULL_VERSION "ntpd 4.2.8p3" +#define NTPD_FULL_VERSION "ntpd 4.2.8p4" /** * Interface defines for all options. Replace "n" with the UPPER_CASED diff --git a/contrib/ntp/ntpd/ntpd.1ntpdman b/contrib/ntp/ntpd/ntpd.1ntpdman index c231b7fd8486..187a79a79a08 100644 --- a/contrib/ntp/ntpd/ntpd.1ntpdman +++ b/contrib/ntp/ntpd/ntpd.1ntpdman @@ -10,11 +10,11 @@ .ds B-Font B .ds I-Font I .ds R-Font R -.TH ntpd 1ntpdman "29 Jun 2015" "4.2.8p3" "User Commands" +.TH ntpd 1ntpdman "21 Oct 2015" "4.2.8p4" "User Commands" .\" -.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-LZaapD/ag-XZa4nD) +.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dUaOfK/ag-qUaGeK) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:24 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:11 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agman-cmd.tpl .SH NAME @@ -602,6 +602,8 @@ when you have permission to do so from the owner of the target host. Finally, in the past many startup scripts would run \fCntpdate\f[]\fR(1ntpdatemdoc)\f[] +or +\fCsntp\f[]\fR(1sntpmdoc)\f[] to get the system clock close to correct before starting \fCntpd\f[]\fR(1ntpdmdoc)\f[], but this was never more than a mediocre hack and is no longer needed. @@ -611,7 +613,9 @@ and you still need to set the system time before starting \f\*[B-Font]ntpd\fP, please open a bug report and document what is going on, and then look at using -\fCsntp\f[]\fR(1sntpmdoc)\f[]. +\fCsntp\f[]\fR(1sntpmdoc)\f[] +if you really need to set the clock before starting +\f\*[B-Font]ntpd\fP. .sp \n(Ppu .ne 2 diff --git a/contrib/ntp/ntpd/ntpd.1ntpdmdoc b/contrib/ntp/ntpd/ntpd.1ntpdmdoc index 08d7655dff1f..139de527781e 100644 --- a/contrib/ntp/ntpd/ntpd.1ntpdmdoc +++ b/contrib/ntp/ntpd/ntpd.1ntpdmdoc @@ -1,9 +1,9 @@ -.Dd June 29 2015 +.Dd October 21 2015 .Dt NTPD 1ntpdmdoc User Commands .Os .\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc) .\" -.\" It has been AutoGen-ed June 29, 2015 at 04:30:41 PM by AutoGen 5.18.5 +.\" It has been AutoGen-ed October 21, 2015 at 12:38:30 PM by AutoGen 5.18.5 .\" From the definitions ntpd-opts.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -532,6 +532,8 @@ when you have permission to do so from the owner of the target host. Finally, in the past many startup scripts would run .Xr ntpdate 1ntpdatemdoc +or +.Xr sntp 1sntpmdoc to get the system clock close to correct before starting .Xr ntpd 1ntpdmdoc , but this was never more than a mediocre hack and is no longer needed. @@ -541,7 +543,9 @@ and you still need to set the system time before starting .Nm , please open a bug report and document what is going on, and then look at using -.Xr sntp 1sntpmdoc . +.Xr sntp 1sntpmdoc +if you really need to set the clock before starting +.Nm . .Pp There is a way to start .Xr ntpd 1ntpdmdoc diff --git a/contrib/ntp/ntpd/ntpd.c b/contrib/ntp/ntpd/ntpd.c index 529e6ce1b0cc..a517391ba522 100644 --- a/contrib/ntp/ntpd/ntpd.c +++ b/contrib/ntp/ntpd/ntpd.c @@ -27,6 +27,14 @@ #include "ntp_libopts.h" #include "ntpd-opts.h" +/* there's a short treatise below what the thread stuff is for */ +#if defined(HAVE_PTHREADS) && HAVE_PTHREADS && !defined(NO_THREADS) +# ifdef HAVE_PTHREAD_H +# include +# endif +# define NEED_PTHREAD_WARMUP +#endif + #ifdef HAVE_UNISTD_H # include #endif @@ -179,12 +187,6 @@ struct passwd *pw; int waitsync_fd_to_close = -1; /* -w/--wait-sync */ #endif -/* - * Initializing flag. All async routines watch this and only do their - * thing when it is clear. - */ -int initializing; - /* * Version declaration */ @@ -238,6 +240,68 @@ static void library_unexpected_error(const char *, int, #endif /* !SIM */ +/* Bug2332 unearthed a problem in the interaction of reduced user + * privileges, the limits on memory usage and some versions of the + * pthread library on Linux systems. The 'pthread_cancel()' function and + * likely some others need to track the stack of the thread involved, + * and uses a function that comes from GCC (--> libgcc_s.so) to do + * this. Unfortunately the developers of glibc decided to load the + * library on demand, which speeds up program start but can cause + * trouble here: Due to all the things NTPD does to limit its resource + * usage, this deferred load of libgcc_s does not always work once the + * restrictions are in effect. + * + * One way out of this was attempting a forced link against libgcc_s + * when possible because it makes the library available immediately + * without deferred load. (The symbol resolution would still be dynamic + * and on demand, but the code would already be in the process image.) + * + * This is a tricky thing to do, since it's not necessary everywhere, + * not possible everywhere, has shown to break the build of other + * programs in the NTP suite and is now generally frowned upon. + * + * So we take a different approach here: We creat a worker thread that does + * actually nothing except waiting for cancellation and cancel it. If + * this is done before all the limitations are put in place, the + * machinery is pre-heated and all the runtime stuff should be in place + * and useable when needed. + * + * This uses only the standard pthread API and should work with all + * implementations of pthreads. It is not necessary everywhere, but it's + * cheap enough to go on nearly unnoticed. + */ +#ifdef NEED_PTHREAD_WARMUP + +/* simple thread function: sleep until cancelled, just to exercise + * thread cancellation. + */ +static void* +my_pthread_warmup_worker( + void *thread_args) +{ + (void)thread_args; + for (;;) + sleep(10); + return NULL; +} + +/* pre-heat threading: create a thread and cancel it, just to exercise + * thread cancellation. + */ +static void +my_pthread_warmup(void) +{ + pthread_t thread; + int rc; + rc = pthread_create( + &thread, NULL, my_pthread_warmup_worker, NULL); + if (0 == rc) { + pthread_cancel(thread); + pthread_join(thread, NULL); + } +} + +#endif /*defined(NEED_PTHREAD_WARMUP)*/ void @@ -451,6 +515,10 @@ ntpdmain( int zero; # endif +# ifdef NEED_PTHREAD_WARMUP + my_pthread_warmup(); +# endif + # ifdef HAVE_UMASK uv = umask(0); if (uv) @@ -791,13 +859,16 @@ ntpdmain( */ getconfig(argc, argv); - if (do_memlock) { + if (-1 == cur_memlock) { # if defined(HAVE_MLOCKALL) /* * lock the process into memory */ - if (!HAVE_OPT(SAVECONFIGQUIT) && - 0 != mlockall(MCL_CURRENT|MCL_FUTURE)) + if ( !HAVE_OPT(SAVECONFIGQUIT) +# ifdef RLIMIT_MEMLOCK + && -1 != DFLT_RLIMIT_MEMLOCK +# endif + && 0 != mlockall(MCL_CURRENT|MCL_FUTURE)) msyslog(LOG_ERR, "mlockall(): %m"); # else /* !HAVE_MLOCKALL follows */ # ifdef HAVE_PLOCK @@ -937,10 +1008,17 @@ ntpdmain( msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group); exit (-1); } - if (group) - setgroups(1, &sw_gid); - else - initgroups(pw->pw_name, pw->pw_gid); + if (group) { + if (0 != setgroups(1, &sw_gid)) { + msyslog(LOG_ERR, "setgroups(1, %d) failed: %m", sw_gid); + exit (-1); + } + } + else if (pw) + if (0 != initgroups(pw->pw_name, pw->pw_gid)) { + msyslog(LOG_ERR, "initgroups(<%s>, %d) filed: %m", pw->pw_name, pw->pw_gid); + exit (-1); + } if (user && setuid(sw_uid)) { msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user); exit (-1); diff --git a/contrib/ntp/ntpd/ntpd.html b/contrib/ntp/ntpd/ntpd.html index 7af6d9859f95..8d6f9d6ad507 100644 --- a/contrib/ntp/ntpd/ntpd.html +++ b/contrib/ntp/ntpd/ntpd.html @@ -39,7 +39,7 @@ The program can operate in any of several modes, including client/server, symmetric and broadcast modes, and with both symmetric-key and public-key cryptography. -

This document applies to version 4.2.8p3 of ntpd. +

This document applies to version 4.2.8p4 of ntpd.