[tor-bugs] #13019 [Tor Browser]: New locale fingerprinting capabilities in FF31ESR

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Oct 30 20:16:27 UTC 2014


#13019: New locale fingerprinting capabilities in FF31ESR
-------------------------+-------------------------------------------------
     Reporter:           |      Owner:  tbb-team
  mikeperry              |     Status:  reopened
         Type:  defect   |  Milestone:
     Priority:  major    |    Version:
    Component:  Tor      |   Keywords:  ff31-esr, tbb-fingerprinting,
  Browser                |  MikePerry201409R, TorBrowserTeam201410,
   Resolution:           |  tbb-4.5-alpha
Actual Points:           |  Parent ID:
       Points:           |
-------------------------+-------------------------------------------------

Comment (by arthuredelstein):

 Replying to [comment:14 gk]:
 > Replying to [comment:12 mikeperry]:
 > > It looks like there's a new memory leak in that patch. You were
 strdupping an already strdupped pointer from JS_GetDefaultLocale().
 > >
 > > I fixed this in a fixup commit.
 >
 > This seems to break the build:

 I looked at it again, and I think the original patch is correct.
 JS_GetDefaultLocale is a minimal wrapper for
 JSRuntime::getDefaultLocale(), which returns a pointer to an internal
 JSRuntime member (char* JSRuntime::defaultLocale). The JS_strdup that
 allocates defaultLocale is matched internally in the JSRuntime class by a
 js_free in JSRuntime::resetDefaultLocale():
 {{{
 void
 JSRuntime::resetDefaultLocale()
 {
     js_free(defaultLocale);
     defaultLocale = nullptr;
 }

 const char *
 JSRuntime::getDefaultLocale()
 {
     if (defaultLocale)
         return defaultLocale;

     char *locale, *lang, *p;
 #ifdef HAVE_SETLOCALE
     locale = setlocale(LC_ALL, nullptr);
 #else
     locale = getenv("LANG");
 #endif
     // convert to a well-formed BCP 47 language tag
     if (!locale || !strcmp(locale, "C"))
         locale = const_cast<char*>("und");
     lang = JS_strdup(this, locale);
     if (!lang)
         return nullptr;
     if ((p = strchr(lang, '.')))
         *p = '\0';
     while ((p = strchr(lang, '_')))
         *p = '-';

     defaultLocale = lang;
     return defaultLocale;
 }
 }}}

 So we need an extra strdup to get an independent copy into
 nsXPComInit.cpp:static char* sJSLocale;

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/13019#comment:15>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list