diff options
author | Felix Geyer <debfx-pkg@fobos.de> | 2010-06-25 23:32:17 +0200 |
---|---|---|
committer | Felix Geyer <debfx-pkg@fobos.de> | 2010-06-25 23:32:17 +0200 |
commit | 3cc524b669caddac0b3c8c8fd0b57eaff7f490eb (patch) | |
tree | 8f1ab6c92e9e9b5c24ffa2982cc11579a10a1764 /src/VBox/Runtime/common/string/stringalloc.cpp | |
parent | 4fc7368fb7c2191d0415356bc517ad2be123cd3c (diff) | |
download | virtualbox-3cc524b669caddac0b3c8c8fd0b57eaff7f490eb.tar.gz |
Imported Upstream version 3.2.6-dfsgupstream/3.2.6-dfsg
Diffstat (limited to 'src/VBox/Runtime/common/string/stringalloc.cpp')
-rw-r--r-- | src/VBox/Runtime/common/string/stringalloc.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/VBox/Runtime/common/string/stringalloc.cpp b/src/VBox/Runtime/common/string/stringalloc.cpp index 61f962bb7..be7d983eb 100644 --- a/src/VBox/Runtime/common/string/stringalloc.cpp +++ b/src/VBox/Runtime/common/string/stringalloc.cpp @@ -131,9 +131,9 @@ RT_EXPORT_SYMBOL(RTStrDupEx); RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax) { AssertPtr(pszString); - char *pszEnd = (char *)memchr(pszString, '\0', cchMax); - size_t cch = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax; - char *pszDst = (char *)RTMemAlloc(cch + 1); + char const *pszEnd = RTStrEnd(pszString, cchMax); + size_t cch = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax; + char *pszDst = (char *)RTMemAlloc(cch + 1); if (pszDst) { memcpy(pszDst, pszString, cch); @@ -261,7 +261,8 @@ RTDECL(int) RTStrATruncate(char **ppsz, size_t cchNew) else { AssertPtrReturn(pszOld, VERR_OUT_OF_RANGE); - char *pszZero = (char *)memchr(pszOld, '\0', cchNew + 63); + AssertPtrReturn(cchNew < ~(size_t)64, VERR_OUT_OF_RANGE); + char *pszZero = RTStrEnd(pszOld, cchNew + 63); AssertReturn(!pszZero || (size_t)(pszZero - pszOld) >= cchNew, VERR_OUT_OF_RANGE); pszOld[cchNew] = '\0'; if (!pszZero) |