Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 17 Aug 2020 00:12:30 -0400
From: Waldek Kozaczuk <jwkozaczuk@...il.com>
To: musl@...ts.openwall.com
Subject: Both network/if_nametoindex.c and network/if_indextoname.c should use
 strlcpy instead of strncpy

Hi,

As I have been working on upgrading OSv (
https://github.com/cloudius-systems/osv) to latest version of musl, I have
noticed that both network/if_nametoindex.c and network/if_indextoname.c use
strncpy() to copy interface name to/from buffer. In both cases per
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html and
https://linux.die.net/man/3/if_indextoname, it seems that  ifname should be
big enough to hold IF_NAMESIZE bytes which SHOULD include null terminating
one. If that is the case both functions should use strlcpy instead of
strncpy.

Am I wrong?

My regards,
Waldemar Kozaczuk

PS. Trying to compile if_nameindex() yields warning:

  CC musl/src/network/if_nameindex.c
include/api/net/if.h: In function ‘if_nametoindex’:
musl/src/network/if_nametoindex.c:14:2: error: ‘strncpy’ specified bound 16
equals destination size [-Werror=stringop-truncation]
   14 |  strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.