projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ovs-ofctl: Fix write before beginning of string in "add-flow".
[openvswitch]
/
utilities
/
ovs-ofctl.c
diff --git
a/utilities/ovs-ofctl.c
b/utilities/ovs-ofctl.c
index 69f8adfd93721401a969261489df165d94782d76..204e9582f22975dd5877eced8a78f9b3b432c9fa 100644
(file)
--- a/
utilities/ovs-ofctl.c
+++ b/
utilities/ovs-ofctl.c
@@
-405,6
+405,20
@@
str_to_u32(const char *str)
return value;
}
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])
{
static void
str_to_mac(const char *str, uint8_t mac[6])
{
@@
-627,6
+641,12
@@
str_to_action(char *str, struct ofpbuf *b)
struct ofp_action_nw_tos *nt;
nt = put_action(b, sizeof *nt, OFPAT_SET_NW_TOS);
nt->nw_tos = str_to_u32(arg);
struct ofp_action_nw_tos *nt;
nt = put_action(b, sizeof *nt, OFPAT_SET_NW_TOS);
nt->nw_tos = str_to_u32(arg);
+ } else if (!strcasecmp(act, "resubmit")) {
+ struct nx_action_resubmit *nar;
+ nar = put_action(b, sizeof *nar, OFPAT_VENDOR);
+ nar->vendor = htonl(NX_VENDOR_ID);
+ nar->subtype = htons(NXAST_RESUBMIT);
+ nar->in_port = htons(str_to_u32(arg));
} else if (!strcasecmp(act, "output")) {
put_output_action(b, str_to_u32(arg));
} else if (!strcasecmp(act, "drop")) {
} else if (!strcasecmp(act, "output")) {
put_output_action(b, str_to_u32(arg));
} else if (!strcasecmp(act, "drop")) {
@@
-643,7
+663,7
@@
str_to_action(char *str, struct ofpbuf *b)
/* Unless a numeric argument is specified, we send the whole
* packet to the controller. */
/* Unless a numeric argument is specified, we send the whole
* packet to the controller. */
- if (arg && (strspn(a
ct, "0123456789") == strlen(act
))) {
+ if (arg && (strspn(a
rg, "0123456789") == strlen(arg
))) {
oao->max_len = htons(str_to_u32(arg));
} else {
oao->max_len = htons(UINT16_MAX);
oao->max_len = htons(str_to_u32(arg));
} else {
oao->max_len = htons(UINT16_MAX);
@@
-760,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");
}
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");
}
if (!act_str) {
ovs_fatal(0, "must specify an action");
}
@@
-804,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")) {
} 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")) {
} else if (parse_field(name, &f)) {
void *data = (char *) match + f->offset;
if (!strcmp(value, "*") || !strcmp(value, "ANY")) {