Skip to content

Commit

Permalink
base: don't use static array indices for buffer argument of _nl_inet_…
Browse files Browse the repository at this point in the history
…ntop()

Seems the static array indices can confuse coverity. I think coverity is wrong
here, regardless, change it.

  libnl-3.8.0/include/base/nl-base-utils.h:683: overrun-buffer-arg: Overrunning buffer pointed to by "buf" of 16 bytes by passing it to a function which accesses it at byte offset 45 using argument "(addr_family == 2) ? 16 : 46" (which evaluates to 46).
  #  681|   	 * and a suitably large buffer, it cannot. Assert for that. */
  #  682|
  #  683|-> 	r = (char *)inet_ntop(addr_family, addr, buf,
  #  684|   			      (addr_family == AF_INET) ? INET_ADDRSTRLEN :
  #  685|   							 INET6_ADDRSTRLEN);
  • Loading branch information
thom311 committed Dec 1, 2023
1 parent 444e2c0 commit 65ab16f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions include/base/nl-base-utils.h
Expand Up @@ -680,8 +680,7 @@ typedef union {
struct in6_addr a6;
} _NLIPAddr;

static inline char *_nl_inet_ntop(int addr_family, const void *addr,
char buf[static INET_ADDRSTRLEN])
static inline char *_nl_inet_ntop(int addr_family, const void *addr, char *buf)
{
char *r;

Expand Down

0 comments on commit 65ab16f

Please sign in to comment.