Messages in this thread | | | From | Florent Revest <> | Date | Tue, 6 Apr 2021 17:38:31 +0200 | Subject | Re: [PATCH bpf-next v2 2/6] bpf: Add a ARG_PTR_TO_CONST_STR argument type |
| |
On Fri, Mar 26, 2021 at 11:23 PM Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote: > On Tue, Mar 23, 2021 at 7:23 PM Florent Revest <revest@chromium.org> wrote: > > + > > + map_off = reg->off + reg->var_off.value; > > + err = map->ops->map_direct_value_addr(map, &map_addr, map_off); > > + if (err) > > + return err; > > + > > + str_ptr = (char *)(long)(map_addr); > > + if (!strnchr(str_ptr + map_off, > > + map->value_size - reg->off - map_off, 0)) > > you are double subtracting reg->off here. isn't map->value_size - > map_off what you want?
Good catch!
> > + verbose(env, "string is not zero-terminated\n"); > > I'd prefer `return -EINVAL;`, but at least set err, otherwise what's the point?
Ah yeah, absolutely.
| |