VirtualBox

Changeset 78048 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Apr 9, 2019 1:21:09 AM (6 years ago)
Author:
vboxsync
Message:

IPRT: Working on new RTPathAbsEx implementation, temporarily called RTPathAbsExEx. This should fix most of the bugs in the current RTPathAbs/Ex code and do away with the fixed path buffer limitations. Also introduces a RTPATH_BIG_MAX, given that RTPATH_MAX is just a reasonable and not absolute MAX value. The new one is more or less absolute and must never be used for stack buffers. bugref:9172

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r77983 r78048  
    15971597# define RTPathAbsDup                                   RT_MANGLER(RTPathAbsDup)
    15981598# define RTPathAbsEx                                    RT_MANGLER(RTPathAbsEx)
     1599# define RTPathAbsExEx                                  RT_MANGLER(RTPathAbsExEx)
    15991600# define RTPathAbsExDup                                 RT_MANGLER(RTPathAbsExDup)
    16001601# define RTPathAppDocs                                  RT_MANGLER(RTPathAppDocs)
  • trunk/include/iprt/path.h

    r76589 r78048  
    5050 */
    5151#if !defined(IPRT_INCLUDED_param_h) || defined(DOXYGEN_RUNNING)
    52 # define RTPATH_MAX         (4096 + 4)    /* (PATH_MAX + 1) on linux w/ some alignment */
     52# define RTPATH_MAX                 (4096 + 4)    /* (PATH_MAX + 1) on linux w/ some alignment */
    5353#endif
     54
     55/**
     56 * The absolute max host path length we are willing to support.
     57 * @note Not really suitable for stack buffers.
     58 */
     59#define RTPATH_BIG_MAX              (_64K)
    5460
    5561/** @def RTPATH_TAG
     
    6167 */
    6268#ifndef RTPATH_TAG
    63 # define RTPATH_TAG     (__FILE__)
     69# define RTPATH_TAG                 (__FILE__)
    6470#endif
    6571
     
    305311 * @param   pszPath         The path to resolve.
    306312 * @param   pszAbsPath      Where to store the absolute path.
    307  * @param   cchAbsPath      Size of the buffer.
     313 * @param   cbAbsPath       Size of the buffer.
    308314 *
    309315 * @note    Current implementation is buggy and will remove trailing slashes
    310316 *          that would normally specify a directory.  Don't depend on this.
    311317 */
    312 RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cchAbsPath);
     318RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cbAbsPath);
    313319
    314320/**
     
    335341 * @param   pszPath         The path to resolve.
    336342 * @param   pszAbsPath      Where to store the absolute path.
    337  * @param   cchAbsPath      Size of the buffer.
     343 * @param   cbAbsPath       Size of the buffer.
    338344 *
    339345 * @note    Current implementation is buggy and will remove trailing slashes
    340346 *          that would normally specify a directory.  Don't depend on this.
    341347 */
    342 RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, char *pszAbsPath, size_t cchAbsPath);
     348RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, char *pszAbsPath, size_t cbAbsPath);
     349
     350/**
     351 * Get the absolute path (no symlinks, no . or .. components), assuming the
     352 * given base path as the current directory.
     353 *
     354 * The resulting path doesn't have to exist.
     355 *
     356 * @returns iprt status code.
     357 * @param   pszBase         The base path to act like a current directory.
     358 *                          When NULL, the actual cwd is used (i.e. the call
     359 *                          is equivalent to RTPathAbs(pszPath, ...).
     360 * @param   pszPath         The path to resolve.
     361 * @param   fFlags          One of the RTPATH_STR_F_STYLE_XXX flags combined
     362 *                          with any of the RTPATHABS_F_XXX ones.  Most
     363 *                          users will pass RTPATH_STR_F_STYLE_HOST (0).
     364 * @param   pszAbsPath      Where to store the absolute path.
     365 * @param   pcbAbsPath      Hold the size of the buffer when called.  The return
     366 *                          value is the string length on success, and the
     367 *                          required (or slightly more in some case) buffer
     368 *                          size, including terminator, on VERR_BUFFER_OVERFLOW
     369 *                          failures.
     370 */
     371RTDECL(int) RTPathAbsExEx(const char *pszBase, const char *pszPath, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath);
     372
     373/** @name RTPATHABS_F_XXX - Flags for RTPathAbsEx.
     374 * @note The RTPATH_F_STR_XXX style flags also applies.
     375 * @{ */
     376/** Treat specified base directory as a root that cannot be ascended beyond.  */
     377#define RTPATHABS_F_STOP_AT_BASE    RT_BIT_32(16)
     378/** Treat CWD as a root that cannot be ascended beyond.  */
     379#define RTPATHABS_F_STOP_AT_CWD     RT_BIT_32(17)
     380/** @} */
    343381
    344382/**
     
    619657 * RTPATH_PROP_RELATIVE will always be set together with this.  */
    620658#define RTPATH_PROP_DOTDOT_REFS     UINT16_C(0x1000)
     659/** Special UNC root.
     660 * The share name is not sacred when this is set. */
     661#define RTPATH_PROP_SPECIAL_UNC     UINT16_C(0x2000)
    621662
    622663
     
    714755 *
    715756 * @returns IPRT status code.
    716  * @retval  VERR_BUFFER_OVERFLOW if @a cbDstPath is less than or equal to
    717  *          RTPATHPARSED::cchPath.
     757 * @retval  VERR_BUFFER_OVERFLOW if the destination buffer is too small.
     758 *          The necessary length is @a pParsed->cchPath + 1 (updated).
    718759 *
    719760 * @param   pszSrcPath          The source path.
    720  * @param   pParsed             The parser output for @a pszSrcPath.
     761 * @param   pParsed             The parser output for @a pszSrcPath.  Caller may
     762 *                              eliminate elements by setting their length to
     763 *                              zero.  The cchPath member is updated.
    721764 * @param   fFlags              Combination of RTPATH_STR_F_STYLE_XXX.
    722765 *                              Most users will pass 0.
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