VirtualBox

Ignore:
Timestamp:
Jul 12, 2020 1:32:28 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139251
Message:

Main/PerformanceDarwin.cpp: Signed/unsigned conversion issues w/ overflow aspects (>=4TiB). RTPROCESS vs pid_t. bugref:9790

File:
1 edited

Legend:

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

    r82968 r85274  
    122122    {
    123123        *total = totalRAM;
    124         *available = cb / 1024;
     124        cb /= 1024;
     125        *available = cb < ~(ULONG)0 ? (ULONG)cb : ~(ULONG)0;
    125126        *used = *total - *available;
    126127    }
     
    131132{
    132133    Log7(("getProcessInfo() getting info for %d", process));
    133     int nb = proc_pidinfo(process, PROC_PIDTASKINFO, 0, tinfo, sizeof(*tinfo));
    134     if (nb <= 0)
     134    int cbRet = proc_pidinfo((pid_t)process, PROC_PIDTASKINFO, 0, tinfo, sizeof(*tinfo));
     135    if (cbRet <= 0)
    135136    {
    136         int rc = errno;
    137         Log(("proc_pidinfo() -> %s", strerror(rc)));
    138         return RTErrConvertFromDarwin(rc);
     137        int iErrNo = errno;
     138        Log(("proc_pidinfo() -> %s", strerror(iErrNo)));
     139        return RTErrConvertFromDarwin(iErrNo);
    139140    }
    140     else if ((unsigned int)nb < sizeof(*tinfo))
     141    if ((unsigned int)cbRet < sizeof(*tinfo))
    141142    {
    142         Log(("proc_pidinfo() -> too few bytes %d", nb));
     143        Log(("proc_pidinfo() -> too few bytes %d", cbRet));
    143144        return VERR_INTERNAL_ERROR;
    144145    }
     
    171172    if (RT_SUCCESS(rc))
    172173    {
    173         *used = tinfo.pti_resident_size / 1024;
     174        uint64_t cKbResident = tinfo.pti_resident_size / 1024;
     175        *used = cKbResident < ~(ULONG)0 ? (ULONG)cKbResident : ~(ULONG)0;
    174176    }
    175177    return rc;
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