VirtualBox

Changeset 85271 in vbox for trunk


Ignore:
Timestamp:
Jul 12, 2020 12:36:21 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139248
Message:

Main/HostDnsServiceDarwin.cpp,++: Wrong index types (must use CFIndex). Left a number of TODOs behind. bugref:9790

Location:
trunk/src/VBox/Main/src-server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostDnsService.cpp

    r83794 r85271  
    6969}
    7070
    71 inline static void detachVectorOfString(const std::vector<std::string>& v,
    72                                         std::vector<com::Utf8Str> &aArray)
     71DECLINLINE(void) detachVectorOfString(const std::vector<std::string>& v, std::vector<com::Utf8Str> &aArray)
    7372{
    7473    aArray.resize(v.size());
    7574    size_t i = 0;
    7675    for (std::vector<std::string>::const_iterator it = v.begin(); it != v.end(); ++it, ++i)
    77         aArray[i] = Utf8Str(it->c_str());
     76        aArray[i] = Utf8Str(it->c_str()); /** @todo r=bird: *it isn't necessarily UTF-8 clean!!
     77                                           * On darwin we do silly shit like using CFStringGetSystemEncoding()
     78                                           * that may be UTF-8 but doesn't need to be.
     79                                           *
     80                                           * Why on earth are we using std::string here anyway?
     81                                           */
    7882}
    7983
  • trunk/src/VBox/Main/src-server/HostDnsService.h

    r84425 r85271  
    3838class HostDnsInformation
    3939{
    40   public:
     40public:
    4141    static const uint32_t IGNORE_SERVER_ORDER = RT_BIT_32(0);
    4242    static const uint32_t IGNORE_SUFFIXES     = RT_BIT_32(1);
    4343
    44   public:
     44public:
     45    /** @todo r=bird: Why on earth are we using std::string and not Utf8Str?   */
    4546    std::vector<std::string> servers;
    4647    std::string domain;
  • trunk/src/VBox/Main/src-server/darwin/HostDnsServiceDarwin.cpp

    r83794 r85271  
    140140    }
    141141
    142     if(SCDynamicStoreSetNotificationKeys(m->m_store, watchingArrayRef, NULL))
     142    if (SCDynamicStoreSetNotificationKeys(m->m_store, watchingArrayRef, NULL))
    143143        CFRunLoopAddSource(CFRunLoopGetCurrent(), m->m_DnsWatcher, kCFRunLoopCommonModes);
    144144
     
    149149    /* Trigger initial update. */
    150150    int rc = updateInfo();
    151     AssertRC(rc); /* Not fatal in release builds. */
     151    AssertRC(rc); /* Not fatal in release builds. */  /** @todo r=bird: The function always returns VINF_SUCCESS. */
    152152
    153153    while (!ASMAtomicReadBool(&m->m_fStop))
     
    189189
    190190    HostDnsInformation info;
    191     CFStringRef domainNameRef = (CFStringRef)CFDictionaryGetValue(
    192        static_cast<CFDictionaryRef>(propertyRef), CFSTR("DomainName"));
    193 
     191    CFStringRef domainNameRef = (CFStringRef)CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyRef), CFSTR("DomainName"));
    194192    if (domainNameRef)
    195193    {
     
    199197    }
    200198
    201     int i, arrayCount;
    202 
    203     CFArrayRef serverArrayRef = (CFArrayRef)CFDictionaryGetValue(
    204        static_cast<CFDictionaryRef>(propertyRef), CFSTR("ServerAddresses"));
     199    CFArrayRef serverArrayRef = (CFArrayRef)CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyRef),
     200                                                                 CFSTR("ServerAddresses"));
    205201    if (serverArrayRef)
    206202    {
    207         arrayCount = CFArrayGetCount(serverArrayRef);
    208         for (i = 0; i < arrayCount; ++i)
     203        CFIndex const cItems = CFArrayGetCount(serverArrayRef);
     204        for (CFIndex i = 0; i < cItems; ++i)
    209205        {
    210206            CFStringRef serverAddressRef = (CFStringRef)CFArrayGetValueAtIndex(serverArrayRef, i);
     
    212208                continue;
    213209
     210            /** @todo r=bird: This code is messed up as CFStringGetCStringPtr is documented
     211             *  to return NULL even if the string is valid.   Furthermore, we must have
     212             *  UTF-8 - some joker might decide latin-1 is better here for all we know
     213             *  and we'll end up with evil invalid UTF-8 sequences. */
    214214            const char *pszServerAddress = CFStringGetCStringPtr(serverAddressRef, CFStringGetSystemEncoding());
    215215            if (!pszServerAddress)
    216216                continue;
    217217
     218            /** @todo r=bird: Why on earth are we using std::string and not Utf8Str?   */
    218219            info.servers.push_back(std::string(pszServerAddress));
    219220        }
    220221    }
    221222
    222     CFArrayRef searchArrayRef = (CFArrayRef)CFDictionaryGetValue(
    223        static_cast<CFDictionaryRef>(propertyRef), CFSTR("SearchDomains"));
    224 
     223    CFArrayRef searchArrayRef = (CFArrayRef)CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyRef),
     224                                                                 CFSTR("SearchDomains"));
    225225    if (searchArrayRef)
    226226    {
    227         arrayCount = CFArrayGetCount(searchArrayRef);
    228 
    229         for (i = 0; i < arrayCount; ++i)
     227        CFIndex const cItems = CFArrayGetCount(searchArrayRef);
     228        for (CFIndex i = 0; i < cItems; ++i)
    230229        {
    231230            CFStringRef searchStringRef = (CFStringRef)CFArrayGetValueAtIndex(searchArrayRef, i);
     
    233232                continue;
    234233
     234            /** @todo r=bird: This code is messed up as CFStringGetCStringPtr is documented
     235             *  to return NULL even if the string is valid.   Furthermore, we must have
     236             *  UTF-8 - some joker might decide latin-1 is better here for all we know
     237             *  and we'll end up with evil invalid UTF-8 sequences. */
    235238            const char *pszSearchString = CFStringGetCStringPtr(searchStringRef, CFStringGetSystemEncoding());
    236239            if (!pszSearchString)
    237240                continue;
    238241
     242            /** @todo r=bird: Why on earth are we using std::string and not Utf8Str?   */
    239243            info.searchList.push_back(std::string(pszSearchString));
    240244        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette