Commit a6b5e0bd authored by btolsch's avatar btolsch Committed by Commit Bot

Check interface name before calling CoreWLAN

This change attempts to address some Mac CWInterface crashes.  Although
CWInterface's interfaceWithName was deprecated in 10.10, these crashes
don't appear to be a result of that (especially since there is one other
use of the API in Chromium that isn't experiencing any crashes).  This
change adds a check on the interface name before calling
interfaceWithName to ensure it is only called on Wifi interfaces.

Bug: 827944
Change-Id: I2775bc7c3b26a015c1893b3ba56a13f66f3d5ead
Reviewed-on: https://chromium-review.googlesource.com/1016068Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Commit-Queue: Brandon Tolsch <btolsch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551737}
parent 5eb18d91
......@@ -5,20 +5,17 @@
#include "chrome/browser/media/router/discovery/discovery_network_list_wifi.h"
#include <CoreWLAN/CoreWLAN.h>
#include <string.h>
#include <string>
#include <utility>
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
namespace media_router {
namespace {
bool MaybeGetWifiSSID(const std::string& if_name, std::string* ssid_out) {
DCHECK(ssid_out);
NSString* ns_ifname = base::SysUTF8ToNSString(if_name.data());
bool GetWifiSSID(NSString* ns_ifname, std::string* ssid_out) {
CWInterface* interface = [CWInterface interfaceWithName:ns_ifname];
if (interface == nil) {
return false;
......@@ -31,4 +28,17 @@ bool MaybeGetWifiSSID(const std::string& if_name, std::string* ssid_out) {
return true;
}
} // namespace
bool MaybeGetWifiSSID(const std::string& if_name, std::string* ssid_out) {
DCHECK(ssid_out);
NSString* ns_ifname = base::SysUTF8ToNSString(if_name.data());
NSSet* all_ifnames = [CWInterface interfaceNames];
for (NSString* ifname in all_ifnames)
if ([ifname isEqualToString:ns_ifname])
return GetWifiSSID(ns_ifname, ssid_out);
return false;
}
} // namespace media_router
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment