VirtualBox

Changeset 25558 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Dec 22, 2009 12:45:27 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56235
Message:

FreeBSD/iprt,suplib: Review and cleanup of r56138. Hope it compiles...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r25472 r25558  
    141141#endif
    142142
     143
    143144/*******************************************************************************
    144145*   Internal Functions                                                         *
     
    324325# ifdef RT_OS_LINUX
    325326    int cchLink = readlink("/proc/self/exe", &g_szSupLibHardenedExePath[0], sizeof(g_szSupLibHardenedExePath) - 1);
     327
    326328# elif defined(RT_OS_SOLARIS)
    327329    char szFileBuf[PATH_MAX + 1];
    328330    sprintf(szFileBuf, "/proc/%ld/path/a.out", (long)getpid());
    329331    int cchLink = readlink(szFileBuf, &g_szSupLibHardenedExePath[0], sizeof(g_szSupLibHardenedExePath) - 1);
    330 # else /* RT_OS_FREEBSD: */
     332
     333# else /* RT_OS_FREEBSD */
    331334    int aiName[4];
    332     size_t cbPath;
    333 
    334335    aiName[0] = CTL_KERN;
    335336    aiName[1] = KERN_PROC;
     
    337338    aiName[3] = getpid();
    338339
    339     cbPath = sizeof(g_szSupLibHardenedExePath) - 1;
    340     if(sysctl(aiName, RT_ELEMENTS(aiName), g_szSupLibHardenedExePath, &cbPath, NULL, 0) < 0)
    341        supR3HardenedFatal("supR3HardenedExecDir: sysctl failed\n");
    342 
    343     int cchLink = strlen(g_szSupLibHardenedExePath);
     340    size_t cbPath = sizeof(g_szSupLibHardenedExePath);
     341    if (sysctl(aiName, RT_ELEMENTS(aiName), g_szSupLibHardenedExePath, &cbPath, NULL, 0) < 0)
     342        supR3HardenedFatal("supR3HardenedExecDir: sysctl failed\n");
     343    g_szSupLibHardenedExePath[sizeof(g_szSupLibHardenedExePath) - 1] = '\0';
     344    int cchLink = strlen(g_szSupLibHardenedExePath); /* paranoid? can't we use cbPath? */
     345
    344346# endif
    345347    if (cchLink < 0 || cchLink == sizeof(g_szSupLibHardenedExePath) - 1)
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