Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
e99955de
Commit
e99955de
authored
Jun 28, 2010
by
Mike Hibler
Browse files
Bug fix: interface name may not be null-terminated, don't assume it.
Take proper code from the current ifconfig. Thanks Guilherme!
parent
ef7567a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
tmcd/findif.c
View file @
e99955de
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2001-200
6
University of Utah and the Flux Group.
* Copyright (c) 2001-20
1
0 University of Utah and the Flux Group.
* All rights reserved.
*
* BSD code derived from:
...
...
@@ -133,7 +133,8 @@ find_iface(char *macaddr)
struct
if_msghdr
*
ifm
;
struct
ifa_msghdr
*
ifam
;
struct
sockaddr_dl
*
sdl
;
char
*
buf
,
*
lim
,
*
next
,
*
cp
,
*
name
;
char
*
buf
,
*
lim
,
*
next
,
*
cp
;
char
name
[
IFNAMSIZ
];
size_t
needed
;
int
n
,
addrs
,
mib
[
6
];
...
...
@@ -181,7 +182,11 @@ find_iface(char *macaddr)
cp
=
(
char
*
)
LLADDR
(
sdl
);
if
((
n
=
sdl
->
sdl_alen
)
<=
0
||
sdl
->
sdl_type
!=
IFT_ETHER
)
continue
;
name
=
sdl
->
sdl_data
;
memcpy
(
name
,
sdl
->
sdl_data
,
sizeof
(
name
)
<
sdl
->
sdl_nlen
?
sizeof
(
name
)
-
1
:
sdl
->
sdl_nlen
);
name
[
sizeof
(
name
)
<
sdl
->
sdl_nlen
?
sizeof
(
name
)
-
1
:
sdl
->
sdl_nlen
]
=
'\0'
;
if
(
addrtype
==
ADDR_MAC
)
{
char
enet
[
BUFSIZ
],
*
bp
=
enet
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment