From 13b290e700929fa5bee18ce68fa1ac50c2506a0a Mon Sep 17 00:00:00 2001 From: "thomasvl@chromium.org" Date: Wed, 7 Apr 2010 19:56:11 +0000 Subject: [Mac] This probably won't fix the bug complete, but just put in some checks to make sure the process name is only getting set in ways we expect. BUG=40583 TEST=none Review URL: http://codereview.chromium.org/1628007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43867 0039d316-1c4b-4281-b951-d872f2087c98 --- base/mac_util.mm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'base') diff --git a/base/mac_util.mm b/base/mac_util.mm index 5735aa3..91ad48c 100644 --- a/base/mac_util.mm +++ b/base/mac_util.mm @@ -388,6 +388,16 @@ CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, } void SetProcessName(CFStringRef process_name) { + if (!process_name || CFStringGetLength(process_name) == 0) { + NOTREACHED() << "SetProcessName given bad name."; + return; + } + + if (![NSThread isMainThread]) { + NOTREACHED() << "Should only set process name from main thread."; + return; + } + // Warning: here be dragons! This is SPI reverse-engineered from WebKit's // plugin host, and could break at any time (although realistically it's only // likely to break in a new major release). @@ -449,9 +459,12 @@ void SetProcessName(CFStringRef process_name) { PrivateLSASN asn = ls_get_current_application_asn_func(); // Constant used by WebKit; what exactly it means is unknown. const int magic_session_constant = -2; - ls_set_application_information_item_func(magic_session_constant, asn, - ls_display_name_key, process_name, - NULL /* optional out param */); + OSErr err = + ls_set_application_information_item_func(magic_session_constant, asn, + ls_display_name_key, + process_name, + NULL /* optional out param */); + LOG_IF(ERROR, err) << "Call to set process name failed, err " << err; } } // namespace mac_util -- cgit v1.1