From: Frank Kardel Date: Fri, 26 May 2006 17:08:21 +0000 (+0000) Subject: ntpdc.h: X-Git-Tag: NTP_4_2_1P257_RC~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98d807ab4c5caba8512b766819a33614b6f054dd;p=thirdparty%2Fntp.git ntpdc.h: bug 621 change arg_v to struct, add type field ntpdc.c: bug 621 change arg_v to struct, add type field, initialize string member always as the 'new' parsing code seems to make that previously unfounded assumption. bk: 44773605KIztqkLIXbxAz0CJdHjnBQ --- diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c index 0609cd31b..c5fa87e41 100644 --- a/ntpdc/ntpdc.c +++ b/ntpdc/ntpdc.c @@ -1324,6 +1324,9 @@ findcmd( /* * getarg - interpret an argument token * + * string is always set. + * type is set to the decoded type. + * * return: 0 - failure * 1 - success * -1 - skip to next token @@ -1339,9 +1342,13 @@ getarg( char *cp, *np; static const char *digits = "0123456789"; - switch (code & ~OPT) { + memset(argp, 0, sizeof(*argp)); + + argp->string = str; + argp->type = code & ~OPT; + + switch (argp->type) { case NTP_STR: - argp->string = str; break; case NTP_ADD: if (!strcmp("-6", str)) { diff --git a/ntpdc/ntpdc.h b/ntpdc/ntpdc.h index 7fc699474..785c31242 100644 --- a/ntpdc/ntpdc.h +++ b/ntpdc/ntpdc.h @@ -26,9 +26,11 @@ #define IP_VERSION 0x5 /* IP version */ /* - * Arguments are returned in a union + * Arguments are returned in a struct - no + * union space saving is attempted. */ -typedef union { +typedef struct { + u_char type; char *string; long ival; u_long uval;