Re: [PATCH bpf-next 2/3] bpftool: match programs by name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 13 Dec 2019 13:40:38 +0100, Paul Chaignon wrote:
> > > @@ -176,7 +177,20 @@ prog_parse_fds(int *argc, char ***argv, int *fds)
> > >  		}
> > >  		NEXT_ARGP();
> > >  
> > > -		return prog_fd_by_tag(tag, fds);
> > > +		return prog_fd_by_nametag(tag, fds, true);
> > > +	} else if (is_prefix(**argv, "name")) {
> > > +		char *name;
> > > +
> > > +		NEXT_ARGP();
> > > +
> > > +		name = **argv;
> > > +		if (strlen(name) > BPF_OBJ_NAME_LEN - 1) {  
> > 
> > Is this needed? strncmp will simply never match, is it preferred to
> > hard error?  
> 
> I tried to follow the fail-early pattern of lookups by tag above.  

Right although tag does a scanf and if we didn't scan all letters 
we'd use uninit memory.

> I do like that there's a different error message for a longer than
> expected name.  Since libbpf silently truncates names, typing a
> longer name is not uncommon.

Ugh, I didn't realize libbpf truncates names. Okay, let's keep the
error for now so we can switch to truncation if users complain.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux