Changeset 34214 in vbox for trunk/src/VBox/Runtime/common/path/RTPathAppendEx.cpp
- Timestamp:
- Nov 19, 2010 5:18:15 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 67956
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/path/RTPathAppendEx.cpp
r34201 r34214 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - RTPathAppend 3 * IPRT - RTPathAppendEx 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009 Oracle Corporation7 * Copyright (C) 2009-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 105 105 106 106 107 RTDECL(int) RTPathAppend (char *pszPath, size_t cbPathDst, const char *pszAppend)107 RTDECL(int) RTPathAppendEx(char *pszPath, size_t cbPathDst, const char *pszAppend, size_t cchAppendMax) 108 108 { 109 109 char *pszPathEnd = RTStrEnd(pszPath, cbPathDst); … … 115 115 if (!pszAppend) 116 116 return VINF_SUCCESS; 117 size_t cchAppend = strlen(pszAppend);117 size_t cchAppend = RTStrNLen(pszAppend, cchAppendMax); 118 118 if (!cchAppend) 119 119 return VINF_SUCCESS; … … 122 122 if (cchAppend >= cbPathDst) 123 123 return VERR_BUFFER_OVERFLOW; 124 memcpy(pszPath, pszAppend, cchAppend + 1); 124 memcpy(pszPath, pszAppend, cchAppend); 125 pszPath[cchAppend] = '\0'; 125 126 return VINF_SUCCESS; 126 127 } … … 153 154 { 154 155 /* One slash is sufficient at this point. */ 155 while ( RTPATH_IS_SLASH(pszAppend[1]))156 while (cchAppend > 1 && RTPATH_IS_SLASH(pszAppend[1])) 156 157 pszAppend++, cchAppend--; 157 158 … … 163 164 { 164 165 /* No slashes needed in the appended bit. */ 165 while ( RTPATH_IS_SLASH(*pszAppend))166 while (cchAppend && RTPATH_IS_SLASH(*pszAppend)) 166 167 pszAppend++, cchAppend--; 167 168 … … 180 181 * What remains now is the just the copying. 181 182 */ 182 memcpy(pszPathEnd, pszAppend, cchAppend + 1); 183 memcpy(pszPathEnd, pszAppend, cchAppend); 184 pszPathEnd[cchAppend] = '\0'; 183 185 return VINF_SUCCESS; 184 186 }
Note:
See TracChangeset
for help on using the changeset viewer.