]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ntpdc.h:
authorFrank Kardel <kardel@ntp.org>
Fri, 26 May 2006 17:08:21 +0000 (17:08 +0000)
committerFrank Kardel <kardel@ntp.org>
Fri, 26 May 2006 17:08:21 +0000 (17:08 +0000)
  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

ntpdc/ntpdc.c
ntpdc/ntpdc.h

index 0609cd31bd52842fe8a2b49dc190442facc91ff3..c5fa87e413fd70d0f50b33bd7f2f4a3d05a3dc02 100644 (file)
@@ -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)) {
index 7fc6994748b295028bab255fc46bbafbbe17dc90..785c31242d74a50852ad0fcd36433c59b6dc2948 100644 (file)
 #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;