Re: [libnftnl PATCH v3] utils: Add helpers for interface name wildcards

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

 



On Wed, Jul 16, 2025 at 03:06:19PM +0200, Florian Westphal wrote:
> Phil Sutter <phil@xxxxxx> wrote:
> > +void nftnl_attr_put_ifname(struct nlmsghdr *nlh, int attr, const char *ifname)
> > +{
> > +	int len = strlen(ifname) + 1;
> 
> Nit: size_t len.
> 
> > +const char *nftnl_attr_get_ifname(struct nlattr *attr)
> > +{
> > +	size_t slen = mnl_attr_get_payload_len(attr);
> > +	const char *dev = mnl_attr_get_str(attr);
> > +	static char buf[IFNAMSIZ];
> 
> I missed this on my last review, sorry:

My fault, I should have at least added a hint about the missing
thread-safety.

> Please pass "char buf[IFNAMESIZ]" as argument.
> 
> Returning pointer to a static buffer breaks thread safety
> of libnftables.
> 
> Alternatively you could always return a malloc'd buffer
> and force caller to free it.  Up to you.

I'll go with the latter option since all callers pass the return value
directly to strdup() anyway.

Thanks, Phil




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux