X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fovs-ofctl.c;h=204e9582f22975dd5877eced8a78f9b3b432c9fa;hb=80bc2072c0f8b105142f7f30f202809127af87a5;hp=0c977c790b77b48f23a1124a80ac06a68ffb4cf0;hpb=3a2fe1f354988b92aa8b4fa8a7c3bac04f8693ab;p=openvswitch diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 0c977c79..204e9582 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -405,6 +405,20 @@ str_to_u32(const char *str) return value; } +static uint64_t +str_to_u64(const char *str) +{ + char *tail; + uint64_t value; + + errno = 0; + value = strtoull(str, &tail, 0); + if (errno == EINVAL || errno == ERANGE || *tail) { + ovs_fatal(0, "invalid numeric format %s", str); + } + return value; +} + static void str_to_mac(const char *str, uint8_t mac[6]) { @@ -766,9 +780,9 @@ str_to_flow(char *string, struct ofp_match *match, struct ofpbuf *actions, if (!act_str) { ovs_fatal(0, "must specify an action"); } - *(act_str-1) = '\0'; + *act_str = '\0'; - act_str = strchr(act_str, '='); + act_str = strchr(act_str + 1, '='); if (!act_str) { ovs_fatal(0, "must specify an action"); } @@ -810,7 +824,7 @@ str_to_flow(char *string, struct ofp_match *match, struct ofpbuf *actions, } else if (hard_timeout && !strcmp(name, "hard_timeout")) { *hard_timeout = atoi(value); } else if (cookie && !strcmp(name, "cookie")) { - *cookie = atoi(value); + *cookie = str_to_u64(value); } else if (parse_field(name, &f)) { void *data = (char *) match + f->offset; if (!strcmp(value, "*") || !strcmp(value, "ANY")) {