Changeset 16762 in vbox
- Timestamp:
- Feb 14, 2009 8:21:28 AM (16 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/base64.cpp
r16760 r16762 245 245 * Process input in groups of 4 input / 3 output chars. 246 246 */ 247 uint8_t *pbData = (uint8_t *)pbData;248 247 uint8_t u8Trio[3]; 248 uint8_t *pbData = (uint8_t *)pvData; 249 uint8_t u8 = BASE64_INVALID; 249 250 unsigned c6Bits = 0; 250 uint8_t u8 = BASE64_INVALID;251 251 unsigned ch; 252 252 AssertCompile(sizeof(char) == sizeof(uint8_t)); 253 253 254 const char *pszCurStart; 254 255 for (;;) 255 256 { 257 pszCurStart = pszString; 256 258 /* The first 6-bit group. */ 257 while ((u8 = g_au8CharToVal[ch = *pszString]) != BASE64_SPACE)259 while ((u8 = g_au8CharToVal[ch = *pszString]) == BASE64_SPACE) 258 260 pszString++; 259 261 if (u8 >= 64) … … 262 264 break; 263 265 } 264 u8Trio[0] = u8; 266 u8Trio[0] = u8 << 2; 267 pszString++; 265 268 266 269 /* The second 6-bit group. */ 267 while ((u8 = g_au8CharToVal[ch = *pszString]) != BASE64_SPACE)270 while ((u8 = g_au8CharToVal[ch = *pszString]) == BASE64_SPACE) 268 271 pszString++; 269 272 if (u8 >= 64) … … 272 275 break; 273 276 } 274 u8Trio[0] |= (u8 & 0x3) << 6; 275 u8Trio[1] = u8 >> 2; 277 u8Trio[0] |= u8 >> 4; 278 u8Trio[1] = u8 << 4; 279 pszString++; 276 280 277 281 /* The third 6-bit group. */ 278 while ((u8 = g_au8CharToVal[ch = *pszString]) != BASE64_SPACE)282 while ((u8 = g_au8CharToVal[ch = *pszString]) == BASE64_SPACE) 279 283 pszString++; 280 284 if (u8 >= 64) … … 283 287 break; 284 288 } 285 u8Trio[1] |= (u8 & 0xf) << 4; 286 u8Trio[2] = u8 >> 4; 289 u8Trio[1] |= u8 >> 2; 290 u8Trio[2] = u8 << 6; 291 pszString++; 287 292 288 293 /* The fourth 6-bit group. */ 289 while ((u8 = g_au8CharToVal[ch = *pszString]) != BASE64_SPACE)294 while ((u8 = g_au8CharToVal[ch = *pszString]) == BASE64_SPACE) 290 295 pszString++; 291 296 if (u8 >= 64) … … 294 299 break; 295 300 } 296 u8Trio[2] |= u8 << 2; 301 u8Trio[2] |= u8; 302 pszString++; 297 303 298 304 /* flush the trio */ … … 342 348 * Check padding vs. pending sextets, if anything left to do finish it off. 343 349 */ 344 if ( c6Bits + cbPad != 4345 && c6Bits + cbPad != 0)346 return VERR_INVALID_BASE64_ENCODING;347 if (c6Bits)348 { 350 if (c6Bits || cbPad) 351 { 352 if (c6Bits + cbPad != 4) 353 return VERR_INVALID_BASE64_ENCODING; 354 349 355 switch (c6Bits) 350 356 { -
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r15821 r16762 50 50 PROGRAMS += \ 51 51 tstAvl \ 52 tstBase64 \ 52 53 tstBitOperations \ 53 54 tstCidr \ … … 128 129 tstAvl_SOURCES = tstAvl.cpp 129 130 131 tstBase64_TEMPLATE = VBOXR3TSTEXE 132 tstBase64_SOURCES = tstBase64.cpp 133 130 134 tstBitOperations_TEMPLATE = VBOXR3TSTEXE 131 135 tstBitOperations_SOURCES = tstBitOperations.cpp
Note:
See TracChangeset
for help on using the changeset viewer.