VirtualBox

Changeset 107892 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Jan 22, 2025 1:10:18 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167109
Message:

Runtime/r3/win/process-win.cpp: Fixed warnings found by Parfait (unused assignment + unused function). Removes rtProcWinParseAccountInfo() + rtProcWinFreeAccountInfo(), as unused. jiraref:VBP-1424

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r106061 r107892  
    696696            RTMemTmpFree(pwszProcName);
    697697        }
    698         else
    699             rc = VERR_NO_TMP_MEMORY;
    700698    }
    701699    RTMemTmpFree(paPids);
     
    14641462    else
    14651463        AssertFailed();
    1466 }
    1467 
    1468 
    1469 /**
    1470  * Extracts the user name + domain from a given UPN (User Principal Name, "[email protected]") or
    1471  * Down-Level Logon Name format ("example.com\\joedoe") string.
    1472  *
    1473  * @return  IPRT status code.
    1474  * @param   pwszString      Pointer to string to extract the account info from.
    1475  * @param   pAccountInfo    Where to store the parsed account info.
    1476  *                          Must be free'd with rtProcWinFreeAccountInfo().
    1477  */
    1478 static int rtProcWinParseAccountInfo(PRTUTF16 pwszString, PRTPROCWINACCOUNTINFO pAccountInfo)
    1479 {
    1480     AssertPtrReturn(pwszString,   VERR_INVALID_POINTER);
    1481     AssertPtrReturn(pAccountInfo, VERR_INVALID_POINTER);
    1482 
    1483     /*
    1484      * Note: UPN handling is defined in RFC 822. We only implement very rudimentary parsing for the user
    1485      *       name and domain fields though.
    1486      */
    1487     char *pszString;
    1488     int rc = RTUtf16ToUtf8(pwszString, &pszString);
    1489     if (RT_SUCCESS(rc))
    1490     {
    1491         do
    1492         {
    1493             /* UPN or FQDN handling needed? */
    1494             /** @todo Add more validation here as needed. Regular expressions would be nice. */
    1495             char *pszDelim = strchr(pszString, '@');
    1496             if (pszDelim) /* UPN name? */
    1497             {
    1498                 rc = RTStrToUtf16Ex(pszString, pszDelim - pszString, &pAccountInfo->pwszUserName, 0, NULL);
    1499                 if (RT_FAILURE(rc))
    1500                     break;
    1501 
    1502                 rc = RTStrToUtf16Ex(pszDelim + 1, RTSTR_MAX, &pAccountInfo->pwszDomain, 0, NULL);
    1503                 if (RT_FAILURE(rc))
    1504                     break;
    1505             }
    1506             else if (pszDelim = strchr(pszString, '\\')) /* FQDN name? */
    1507             {
    1508                 rc = RTStrToUtf16Ex(pszString, pszDelim - pszString, &pAccountInfo->pwszDomain, 0, NULL);
    1509                 if (RT_FAILURE(rc))
    1510                     break;
    1511 
    1512                 rc = RTStrToUtf16Ex(pszDelim + 1, RTSTR_MAX, &pAccountInfo->pwszUserName, 0, NULL);
    1513                 if (RT_FAILURE(rc))
    1514                     break;
    1515             }
    1516             else
    1517                 rc = VERR_NOT_SUPPORTED;
    1518 
    1519         } while (0);
    1520 
    1521         RTStrFree(pszString);
    1522     }
    1523 
    1524 #ifdef DEBUG
    1525     LogRelFunc(("Name  : %ls\n", pAccountInfo->pwszUserName));
    1526     LogRelFunc(("Domain: %ls\n", pAccountInfo->pwszDomain));
    1527 #endif
    1528 
    1529     if (RT_FAILURE(rc))
    1530         LogRelFunc(("Parsing \"%ls\" failed with rc=%Rrc\n", pwszString, rc));
    1531     return rc;
    1532 }
    1533 
    1534 
    1535 static void rtProcWinFreeAccountInfo(PRTPROCWINACCOUNTINFO pAccountInfo)
    1536 {
    1537     if (!pAccountInfo)
    1538         return;
    1539 
    1540     if (pAccountInfo->pwszUserName)
    1541     {
    1542         RTUtf16Free(pAccountInfo->pwszUserName);
    1543         pAccountInfo->pwszUserName = NULL;
    1544     }
    1545 
    1546     if (pAccountInfo->pwszDomain)
    1547     {
    1548         RTUtf16Free(pAccountInfo->pwszDomain);
    1549         pAccountInfo->pwszDomain = NULL;
    1550     }
    15511464}
    15521465
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