Changeset 5736 in vbox
- Timestamp:
- Nov 13, 2007 11:57:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r5735 r5736 2837 2837 * @param pcbBuf The buffer size on input. The size of the result on output. 2838 2838 * @param cbUnit The unit size to apply when converting. 2839 * The high bit is used to indicate unicode string. 2839 2840 * @param paVars The array of variables to convert. 2840 2841 * @param cVars The number of variables. … … 2866 2867 { 2867 2868 uint64_t u64 = paVars[i].u.u64Number; 2868 switch (cbUnit )2869 switch (cbUnit & 0x1f) 2869 2870 { 2870 2871 case 1: … … 2898 2899 case DBGCVAR_TYPE_SYMBOL: 2899 2900 { 2901 bool fOverflow = false; 2900 2902 const char *psz = paVars[i].u.pszString; 2901 2903 size_t cbString = strlen(psz); 2902 if (cbString > (uintptr_t)(uEnd.pu8 - u.pu8)) 2903 cbString = uEnd.pu8 - u.pu8; 2904 2905 size_t cbCopy = cbString & ~(cbUnit - 1); 2906 memcpy(u.pu8, psz, cbCopy); 2907 u.pu8 += cbCopy; 2908 psz += cbCopy; 2909 2910 size_t cbReminder = cbString & (cbUnit - 1); 2911 if (cbReminder) 2904 if (cbUnit & RT_BIT_32(31)) 2912 2905 { 2913 memcpy(u.pu8, psz, cbString & (cbUnit - 1)); 2914 memset(u.pu8 + cbReminder, 0, cbUnit - cbReminder); 2915 u.pu8 += cbUnit; 2906 /* Explode char to unit. */ 2907 if (cbString > (uintptr_t)(uEnd.pu8 - u.pu8) * (cbUnit & 0x1f)) 2908 { 2909 pCmdHlp->pfnVBoxError(pCmdHlp, VERR_TOO_MUCH_DATA, "Max %d bytes.\n", uEnd.pu8 - (uint8_t *)pvBuf); 2910 return VERR_TOO_MUCH_DATA; 2911 } 2912 while (*psz) 2913 { 2914 switch (cbUnit & 0x1f) 2915 { 2916 case 1: *u.pu8++ = *psz; break; 2917 case 2: *u.pu16++ = *psz; break; 2918 case 4: *u.pu32++ = *psz; break; 2919 case 8: *u.pu64++ = *psz; break; 2920 } 2921 psz++; 2922 } 2923 } 2924 else 2925 { 2926 /* Raw copy with zero padding if the size isn't aligned. */ 2927 if (cbString > (uintptr_t)(uEnd.pu8 - u.pu8)) 2928 { 2929 pCmdHlp->pfnVBoxError(pCmdHlp, VERR_TOO_MUCH_DATA, "Max %d bytes.\n", uEnd.pu8 - (uint8_t *)pvBuf); 2930 return VERR_TOO_MUCH_DATA; 2931 } 2932 2933 size_t cbCopy = cbString & ~(cbUnit - 1); 2934 memcpy(u.pu8, psz, cbCopy); 2935 u.pu8 += cbCopy; 2936 psz += cbCopy; 2937 2938 size_t cbReminder = cbString & (cbUnit - 1); 2939 if (cbReminder) 2940 { 2941 memcpy(u.pu8, psz, cbString & (cbUnit - 1)); 2942 memset(u.pu8 + cbReminder, 0, cbUnit - cbReminder); 2943 u.pu8 += cbUnit; 2944 } 2916 2945 } 2917 2946 break; … … 3088 3117 case 'a': 3089 3118 case 'b': cbUnit = 1; break; 3090 case 'u': 3119 case 'u': cbUnit = 2 | RT_BIT_32(31); break; 3091 3120 case 'w': cbUnit = 2; break; 3092 3121 case 'd': cbUnit = 4; break;
Note:
See TracChangeset
for help on using the changeset viewer.