Changeset 84632 in vbox for trunk/src/VBox/Runtime/r3/linux
- Timestamp:
- Jun 2, 2020 11:07:28 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 138378
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/linux/sysfs.cpp
r82968 r84632 66 66 */ 67 67 static int rtLinuxConstructPathV(char *pszBuf, size_t cchBuf, 68 69 70 { 71 size_t c chPrefix = strlen(pszPrefix);68 const char *pszPrefix, 69 const char *pszFormat, va_list va) 70 { 71 size_t const cchPrefix = strlen(pszPrefix); 72 72 AssertReturn(pszPrefix[cchPrefix - 1] == '/', VERR_INVALID_PARAMETER); 73 73 AssertReturn(cchBuf > cchPrefix + 1, VERR_INVALID_PARAMETER); 74 74 75 /** @todo While RTStrPrintfV prevents overflows, it doesn't make it easy to 76 * check for truncations. RTPath should provide some formatters and 77 * joiners which can take over this rather common task that is 78 * performed here. */ 79 size_t cch = RTStrPrintfV(pszBuf, cchBuf, pszFormat, va); 75 ssize_t cch = RTStrPrintf2V(pszBuf, cchBuf, pszFormat, va); 76 AssertReturn(cch > 0, VERR_BUFFER_OVERFLOW); 77 80 78 if (*pszBuf != '/') 81 79 { 82 AssertReturn(cchBuf >= cch + cchPrefix + 1, VERR_BUFFER_OVERFLOW);83 memmove(pszBuf + cchPrefix, pszBuf, cch + 1);80 AssertReturn(cchBuf >= (size_t)cch + cchPrefix + 1, VERR_BUFFER_OVERFLOW); 81 memmove(pszBuf + cchPrefix, pszBuf, (size_t)cch + 1); 84 82 memcpy(pszBuf, pszPrefix, cchPrefix); 85 cch += cchPrefix;86 83 } 87 84 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.