Merge pull request #12860 from aabadie/pr/tools/ethos_fix_warning
tools/ethos: fix compilation warning in strncpy
This commit is contained in:
commit
61353e04eb
10
dist/tools/ethos/ethos.c
vendored
10
dist/tools/ethos/ethos.c
vendored
@ -156,7 +156,7 @@ typedef struct {
|
||||
**************************************************************************/
|
||||
int tun_alloc(char *dev, int flags) {
|
||||
|
||||
struct ifreq ifr;
|
||||
struct ifreq ifr = { 0 };
|
||||
int fd, err;
|
||||
|
||||
if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
|
||||
@ -164,12 +164,10 @@ int tun_alloc(char *dev, int flags) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
|
||||
ifr.ifr_flags = flags;
|
||||
|
||||
if (*dev) {
|
||||
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
||||
strncpy(ifr.ifr_name, dev, IFNAMSIZ - 1);
|
||||
}
|
||||
|
||||
if( (err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0 ) {
|
||||
@ -515,8 +513,8 @@ int main(int argc, char *argv[])
|
||||
serial_option = argv[3];
|
||||
}
|
||||
|
||||
char ifname[IFNAMSIZ];
|
||||
strncpy(ifname, argv[1], IFNAMSIZ);
|
||||
char ifname[IFNAMSIZ] = { 0 };
|
||||
strncpy(ifname, argv[1], IFNAMSIZ - 1);
|
||||
int tap_fd = tun_alloc(ifname, IFF_TAP | IFF_NO_PI);
|
||||
|
||||
if (tap_fd < 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user