diff options
author | roberto <roberto@FreeBSD.org> | 2013-12-04 21:33:17 +0000 |
---|---|---|
committer | roberto <roberto@FreeBSD.org> | 2013-12-04 21:33:17 +0000 |
commit | d54cfbdce4a9878ef65216dea36b62cf6646b84b (patch) | |
tree | a618007bb41d13153794a598e3d904ace2976324 /libntp/ntp_libopts.c | |
parent | fd23eea016bd30c806a3ee90eb6f397470c2fa46 (diff) | |
download | FreeBSD-src-d54cfbdce4a9878ef65216dea36b62cf6646b84b.zip FreeBSD-src-d54cfbdce4a9878ef65216dea36b62cf6646b84b.tar.gz |
Virgin import of ntpd 4.2.6p5.
When the series of commits is complete, things like
https://cert.litnet.lt/en/docs/ntp-distributed-reflection-dos-attacks
should be fixed.
PR: bin/148836 (except that we import a newer version)
Asked by: Too many
MFC after: 2 weeks
Diffstat (limited to 'libntp/ntp_libopts.c')
-rw-r--r-- | libntp/ntp_libopts.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libntp/ntp_libopts.c b/libntp/ntp_libopts.c new file mode 100644 index 0000000..f155970 --- /dev/null +++ b/libntp/ntp_libopts.c @@ -0,0 +1,54 @@ +/* + * ntp_libopts.c + * + * Common code interfacing with Autogen's libopts command-line option + * processing. + */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <stddef.h> +#include "ntp_libopts.h" +#include "ntp_stdlib.h" + +extern const char *Version; /* version.c for each program */ + + +/* + * ntpOptionProcess() is a clone of libopts' optionProcess which + * overrides the --version output, appending detail from version.c + * which was not available at Autogen time. + */ +int +ntpOptionProcess( + tOptions * pOpts, + int argc, + char ** argv + ) +{ + char * pchOpts; + char ** ppzFullVersion; + char * pzNewFV; + char * pzAutogenFV; + size_t octets; + int rc; + + pchOpts = (void *)pOpts; + ppzFullVersion = (char **)(pchOpts + offsetof(tOptions, + pzFullVersion)); + pzAutogenFV = *ppzFullVersion; + octets = strlen(pzAutogenFV) + + 1 + /* '\n' */ + strlen(Version) + + 1; /* '\0' */ + pzNewFV = emalloc(octets); + snprintf(pzNewFV, octets, "%s\n%s", pzAutogenFV, Version); + *ppzFullVersion = pzNewFV; + rc = optionProcess(pOpts, argc, argv); + *ppzFullVersion = pzAutogenFV; + free(pzNewFV); + + return rc; +} |