[ovs-dev] [PATCH] ofp-parse: Fix parsing of register values 2**31 and greater.
Ben Pfaff
blp at nicira.com
Fri Aug 12 15:05:12 PDT 2011
Thanks, I pushed this to master.
On Fri, Aug 12, 2011 at 03:02:46PM -0700, Ethan Jackson wrote:
> That fixes it, thanks.
>
> Ethan
>
> On Fri, Aug 12, 2011 at 15:00, Ben Pfaff <blp at nicira.com> wrote:
> > Reported-by: Ethan Jackson <ethan at nicira.com>
> > ---
> > Ethan, does this fix the problem that you reported?
> >
> > diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
> > index e6a6af1..5c7feb2 100644
> > --- a/lib/ofp-parse.c
> > +++ b/lib/ofp-parse.c
> > @@ -812,14 +812,20 @@ parse_field_value(struct cls_rule *rule, enum field_index index,
> > ?static void
> > ?parse_reg_value(struct cls_rule *rule, int reg_idx, const char *value)
> > ?{
> > - ? ?uint32_t reg_value, reg_mask;
> > + ? ?/* This uses an oversized destination field (64 bits when 32 bits would do)
> > + ? ? * because some sscanf() implementations truncate the range of %i
> > + ? ? * directives, so that e.g. "%"SCNi16 interprets input of "0xfedc" as a
> > + ? ? * value of 0x7fff. ?The other alternatives are to allow only a single
> > + ? ? * radix (e.g. decimal or hexadecimal) or to write more sophisticated
> > + ? ? * parsers. */
> > + ? ?unsigned long long int reg_value, reg_mask;
> >
> > ? ? if (!strcmp(value, "ANY") || !strcmp(value, "*")) {
> > ? ? ? ? cls_rule_set_reg_masked(rule, reg_idx, 0, 0);
> > - ? ?} else if (sscanf(value, "%"SCNi32"/%"SCNi32,
> > + ? ?} else if (sscanf(value, "%lli/%lli",
> > ? ? ? ? ? ? ? ? ? ? ? ®_value, ®_mask) == 2) {
> > ? ? ? ? cls_rule_set_reg_masked(rule, reg_idx, reg_value, reg_mask);
> > - ? ?} else if (sscanf(value, "%"SCNi32, ®_value)) {
> > + ? ?} else if (sscanf(value, "%lli", ®_value)) {
> > ? ? ? ? cls_rule_set_reg(rule, reg_idx, reg_value);
> > ? ? } else {
> > ? ? ? ? ovs_fatal(0, "register fields must take the form <value> "
> > --
> > 1.7.2.5
> >
> >
More information about the dev
mailing list