Changeset 80764 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- Sep 13, 2019 6:52:50 AM (5 years ago)
- Location:
- trunk/src/VBox/Runtime/r3/win
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/env-win.cpp
r76553 r80764 173 173 } 174 174 175 RTDECL(int) RTEnvSetUtf8(const char *pszVar, const char *pszValue) 176 { 177 AssertReturn(strchr(pszVar, '=') == NULL, VERR_ENV_INVALID_VAR_NAME); 178 175 176 /** 177 * Worker common to RTEnvSetUtf8() and rtEnvSetExWorker(). 178 */ 179 int rtEnvSetUtf8Worker(const char *pchVar, size_t cchVar, const char *pszValue) 180 { 179 181 size_t cwcVar; 180 int rc = RTStrCalcUtf16LenEx(p szVar, RTSTR_MAX, &cwcVar);182 int rc = RTStrCalcUtf16LenEx(pchVar, cchVar, &cwcVar); 181 183 if (RT_SUCCESS(rc)) 182 184 { 183 185 size_t cwcValue; 184 rc = RTStrCalcUtf16LenEx(pszVa r, RTSTR_MAX, &cwcValue);186 rc = RTStrCalcUtf16LenEx(pszValue, RTSTR_MAX, &cwcValue); 185 187 if (RT_SUCCESS(rc)) 186 188 { … … 188 190 if (pwszTmp) 189 191 { 190 rc = RTStrToUtf16Ex(p szVar, RTSTR_MAX, &pwszTmp, cwcVar + 1, NULL);192 rc = RTStrToUtf16Ex(pchVar, cchVar, &pwszTmp, cwcVar + 1, NULL); 191 193 if (RT_SUCCESS(rc)) 192 194 { … … 212 214 213 215 216 RTDECL(int) RTEnvSetUtf8(const char *pszVar, const char *pszValue) 217 { 218 size_t cchVar = strlen(pszVar); 219 AssertReturn(memchr(pszVar, '=', cchVar) == NULL, VERR_ENV_INVALID_VAR_NAME); 220 return rtEnvSetUtf8Worker(pszVar, cchVar, pszValue); 221 } 222 223 214 224 RTDECL(int) RTEnvUnsetBad(const char *pszVar) 215 225 { -
trunk/src/VBox/Runtime/r3/win/utf8-win.cpp
r76553 r80764 39 39 40 40 41 41 42 RTR3DECL(int) RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag) 43 { 44 return RTStrUtf8ToCurrentCPExTag(ppszString, pszString, RTSTR_MAX, pszTag); 45 } 46 47 48 RTR3DECL(int) RTStrUtf8ToCurrentCPExTag(char **ppszString, const char *pszString, size_t cchString, const char *pszTag) 42 49 { 43 50 Assert(ppszString); … … 47 54 * Check for zero length input string. 48 55 */ 49 if ( !*pszString)56 if (cchString < 1 || !*pszString) 50 57 { 51 58 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag); … … 61 68 */ 62 69 PRTUTF16 pwszString = NULL; 63 int rc = RTStrToUtf16 (pszString, &pwszString);70 int rc = RTStrToUtf16Ex(pszString, cchString, &pwszString, 0, NULL); 64 71 if (RT_FAILURE(rc)) 65 72 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.