VirtualBox

Ignore:
Timestamp:
May 1, 2015 1:45:30 AM (10 years ago)
Author:
vboxsync
Message:

VBoxServiceControlSession.cpp: Added another todo about incorrect RTStrPrintf return value checks as well as one about more doing things simpler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r55577 r55578  
    17711771
    17721772/**
    1773  * Creates a guest session. This will spawn a new VBoxService.exe instance under
    1774  * behalf of the given user which then will act as a session host. On successful
    1775  * open, the session will be added to the given session thread list.
     1773 * Creates a guest session.
     1774 *
     1775 * This will spawn a new VBoxService.exe instance under behalf of the given user
     1776 * which then will act as a session host. On successful open, the session will
     1777 * be added to the given session thread list.
    17761778 *
    17771779 * @return  IPRT status code.
     
    18601862        if (pszExeName)
    18611863        {
     1864/** @todo r=bird: A while back we had this variant in the guest props code:
     1865 *  @code
     1866 *      int rc = RTStrPrintf(....);
     1867 *      if (RT_SUCCESS(rc))
     1868 *  @endcode
     1869 *
     1870 *  Here we've got a new variant:
     1871 *  @code
     1872 *      if (!RTStrPrintf(szBuf, sizeof(szBuf),...))
     1873 *         return VERR_BUFFER_OVERFLOW;
     1874 *  @endcode
     1875 *  ... which is just as pointless.
     1876 *
     1877 *  According to the doxygen docs in iprt/string.h, RTStrPrintf returns "The
     1878 *  length of the returned string (in pszBuffer) excluding the terminator".
     1879 *
     1880 *  Which admittedly makes it a real bitch to check for buffer overflows, but is
     1881 *  a great help preventing memory corruption by careless use of the returned
     1882 *  value if it was outside the buffer range (negative error codes or required
     1883 *  buffer size).  We should probably add a new string formatter which API which
     1884 *  returns VERR_BUFFER_OVERFLOW on overflow and optionally a required buffer
     1885 *  size that you can use here...
     1886 *
     1887 *  However in most cases you don't need to because you make things way to
     1888 *  complicated (see the log file name mangling for instance).
     1889 *
     1890 *  Here, you just need to format two or three (#ifdef DEBUG) 32-bit numbers
     1891 *  which are no brainers, while the szUser can be used as is.  The trick is to
     1892 *  pass the and option and the option value separately.
     1893 */
    18621894            char szParmUserName[GUESTPROCESS_MAX_USER_LEN + 32];
    18631895            if (!fAnonymous)
     
    19822014                    && g_Session.uFlags & VBOXSERVICECTRLSESSION_FLAG_DUMPSTDOUT)
    19832015                {
     2016/** @todo r=bird: This amazing code can be replaced by
     2017 *  @code
     2018 *    papszArgs[iOptIdx++] = "--dump-stdout";
     2019 *  @endcode
     2020 *  which doesn't even need braces.
     2021 */
    19842022                    if (!RTStrPrintf(szParmDumpStdOut, sizeof(szParmDumpStdOut), "--dump-stdout"))
    19852023                        rc = VERR_BUFFER_OVERFLOW;
Note: See TracChangeset for help on using the changeset viewer.

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