diff options
author | Dedy Lansky <dlansky@codeaurora.org> | 2015-09-21 10:52:32 +0300 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:05 -0600 |
commit | a9ba677f4fe48fbb3c6787129b75a3191decddcb (patch) | |
tree | 13ca4c535d7dab742e9fada35dc713fc70dbbdac /luni | |
parent | b670c900b31d85720ce8d82c4d01003ec09784f6 (diff) | |
download | libcore-a9ba677f4fe48fbb3c6787129b75a3191decddcb.zip libcore-a9ba677f4fe48fbb3c6787129b75a3191decddcb.tar.gz libcore-a9ba677f4fe48fbb3c6787129b75a3191decddcb.tar.bz2 |
fix getNetworkInterfacesList with unexpected files in /sys/class/net
getNetworkInterfacesList works by iterating over all files in
/sys/class/net. It expects that each file is actually a directory
containing an "ifindex" file.
It is possible that /sys/class/net contains files that doesn't adhere to
above expectation in which case getNetworkInterfacesList returned with
exception.
This commit fixes this by ignoring files that do not adhere to above
expectation.
Change-Id: Ic39a0a9d311fc3269a5d1a8a5e6cbadc3f5a2105
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/net/NetworkInterface.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/luni/src/main/java/java/net/NetworkInterface.java b/luni/src/main/java/java/net/NetworkInterface.java index 852c09b..0f8e37a 100644 --- a/luni/src/main/java/java/net/NetworkInterface.java +++ b/luni/src/main/java/java/net/NetworkInterface.java @@ -118,7 +118,12 @@ public final class NetworkInterface extends Object { */ private static NetworkInterface getByNameInternal(String interfaceName, String[] ifInet6Lines) throws SocketException { - int interfaceIndex = readIntFile("/sys/class/net/" + interfaceName + "/ifindex"); + int interfaceIndex; + try { + interfaceIndex = readIntFile("/sys/class/net/" + interfaceName + "/ifindex"); + } catch (SocketException e) { + return null; + } List<InetAddress> addresses = new ArrayList<InetAddress>(); List<InterfaceAddress> interfaceAddresses = new ArrayList<InterfaceAddress>(); |