From: Harlan Stenn Date: Wed, 25 Apr 2007 06:45:35 +0000 (-0400) Subject: [Bug 542] Tolerate missing directory separator at EO statsdir X-Git-Tag: NTP_4_2_5P27~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e305ecd597d440c6d3d016f5f638cf53ec1a152a;p=thirdparty%2Fntp.git [Bug 542] Tolerate missing directory separator at EO statsdir bk: 462ef90fdrX7qiGSNTj98JUJ97pQkA --- diff --git a/ChangeLog b/ChangeLog index 1b9fe7ded..f1cc13669 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 542] Tolerate missing directory separator at EO statsdir. * [Bug 812] ntpd should drop supplementary groups. * [Bug 815] Fix warning compiling 4.2.5p22 under Windows with VC6. * [Bug 740] Fix kernel/daemon startup drift anomaly. diff --git a/Makefile.am b/Makefile.am index 37513c3d9..68c9fbac3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,7 @@ EXTRA_DIST = \ conf \ html \ libisc \ + m4 \ ports \ \ bincheck.mf \ diff --git a/configure.ac b/configure.ac index cd62ce368..ea742cfae 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,7 @@ case "$host" in esac AMU_OS_CFLAGS +NTP_DIR_SEP # NTP has (so far) been relying on leading-edge autogen. # Therefore, by default: diff --git a/m4/ntp_dir_sep.m4 b/m4/ntp_dir_sep.m4 new file mode 100644 index 000000000..6c0d50bf1 --- /dev/null +++ b/m4/ntp_dir_sep.m4 @@ -0,0 +1,18 @@ +dnl ###################################################################### +dnl What directory path separator do we use? +AC_DEFUN([NTP_DIR_SEP], [ +AC_CACHE_CHECK([for directory path separator], ac_cv_dir_sep, +[ + case "$ac_cv_dir_sep" in + '') + case "$target_os" in + *djgpp | *mingw32* | *emx*) ac_cv_dir_sep='"\\"' ;; + *) ac_cv_dir_sep='"/"' ;; + esac + ;; + esac +]) +AC_DEFINE_UNQUOTED(DIR_SEP,$ac_cv_dir_sep,dnl + [Directory separator, usually / or \\])dnl +]) +dnl ====================================================================== diff --git a/ntpd/ntp_util.c b/ntpd/ntp_util.c index 91ff8a64f..1934a5c6b 100644 --- a/ntpd/ntp_util.c +++ b/ntpd/ntp_util.c @@ -358,15 +358,34 @@ stats_config( break; case STATS_STATSDIR: + /* HMS: the following test is insufficient: + * - value may be missing the DIR_SEP + * - we still need the filename after it + */ if (strlen(value) >= sizeof(statsdir)) { msyslog(LOG_ERR, "value for statsdir too long (>%d, sigh)", (int)sizeof(statsdir)-1); } else { l_fp now; + int add_dir_sep; + int value_l = strlen(value); + + /* We do not want a DIR_SEP if we have no prefix */ + if (value_l == 0) + add_dir_sep = 0; + else + add_dir_sep = strcmp(DIR_SEP, + value + value_l - strlen(DIR_SEP)); + + if (add_dir_sep) + snprintf(statsdir, sizeof(statsdir), + "%s%s", value, DIR_SEP); + else + snprintf(statsdir, sizeof(statsdir), + "%s", value); get_systime(&now); - strcpy(statsdir,value); if(peerstats.prefix == &statsdir[0] && peerstats.fp != NULL) { fclose(peerstats.fp); diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h index 6bab3598b..0bf51161c 100644 --- a/ports/winnt/include/config.h +++ b/ports/winnt/include/config.h @@ -57,7 +57,7 @@ typedef unsigned int uintptr_t; /* * The type of the socklen_t defined for getnameinfo() and getaddrinfo() - * is int for VS compilers on Windows but the type is already declared + * is int for VS compilers on Windows but the type is already declared */ #define GETSOCKNAME_SOCKLEN_TYPE socklen_t /* @@ -89,7 +89,7 @@ typedef unsigned int uintptr_t; /* Prevent inclusion of winsock.h in windows.h */ #ifndef _WINSOCKAPI_ -#define _WINSOCKAPI_ +#define _WINSOCKAPI_ #endif #ifndef __RPCASYNC_H__ @@ -108,9 +108,9 @@ typedef unsigned int uintptr_t; #endif #define OPEN_BCAST_SOCKET 1 /* for ntp_io.c */ -#define TYPEOF_IP_MULTICAST_LOOP BOOL +#define TYPEOF_IP_MULTICAST_LOOP BOOL #define SETSOCKOPT_ARG_CAST (const char *) -#define HAVE_RANDOM +#define HAVE_RANDOM #define MAXHOSTNAMELEN 64 #define AUTOKEY @@ -180,7 +180,7 @@ int NT_set_process_priority(void); /* Define this function */ # define REFCLOCK /* from ntpd.mak */ # define CLOCK_LOCAL /* from ntpd.mak */ -//# define CLOCK_PARSE +//# define CLOCK_PARSE /* # define CLOCK_ATOM */ /* # define CLOCK_SHM */ /* from ntpd.mak */ # define CLOCK_HOPF_SERIAL /* device 38, hopf DCF77/GPS serial line receiver */ @@ -196,7 +196,7 @@ int NT_set_process_priority(void); /* Define this function */ # define NTP_POSIX_SOURCE # define SYSLOG_FILE /* from libntp.mak */ -# define SYSV_TIMEOFDAY /* for ntp_unixtime.h */ +# define SYSV_TIMEOFDAY /* for ntp_unixtime.h */ # define SIZEOF_SIGNED_CHAR 1 # define SIZEOF_INT 4 /* for ntp_types.h */ @@ -228,7 +228,10 @@ int NT_set_process_priority(void); /* Define this function */ # define NEED_S_CHAR_TYPEDEF -# define USE_PROTOTYPES /* for ntp_types.h */ +# define USE_PROTOTYPES /* for ntp_types.h */ + +/* Directory separator, usually / or \ */ +#define DIR_SEP "\\" #define ULONG_CONST(a) a ## UL