Changeset 66768 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- May 4, 2017 12:59:27 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/iso9660vfs.cpp
r66767 r66768 794 794 uint32_t offEntryInDir = 0; 795 795 uint32_t const cbDir = pThis->Core.cbObject; 796 while (offEntryInDir + RT_ OFFSETOF(ISO9660DIRREC, achFileId) <= cbDir)796 while (offEntryInDir + RT_UOFFSETOF(ISO9660DIRREC, achFileId) <= cbDir) 797 797 { 798 798 PCISO9660DIRREC pDirRec = (PCISO9660DIRREC)&pThis->pbDir[offEntryInDir]; … … 1223 1223 && pDirRec->achFileId[0] == '\0') 1224 1224 { 1225 if (*pcbDirEntry < RT_ OFFSETOF(RTDIRENTRYEX, szName) + 2)1225 if (*pcbDirEntry < RT_UOFFSETOF(RTDIRENTRYEX, szName) + 2) 1226 1226 { 1227 *pcbDirEntry = RT_ OFFSETOF(RTDIRENTRYEX, szName) + 2;1227 *pcbDirEntry = RT_UOFFSETOF(RTDIRENTRYEX, szName) + 2; 1228 1228 return VERR_BUFFER_OVERFLOW; 1229 1229 } … … 1233 1233 } 1234 1234 else if ( pDirRec->bFileIdLength == 1 1235 && pDirRec->achFileId[0] == '\ 0')1235 && pDirRec->achFileId[0] == '\1') 1236 1236 { 1237 if (*pcbDirEntry < RT_ OFFSETOF(RTDIRENTRYEX, szName) + 3)1237 if (*pcbDirEntry < RT_UOFFSETOF(RTDIRENTRYEX, szName) + 3) 1238 1238 { 1239 *pcbDirEntry = RT_ OFFSETOF(RTDIRENTRYEX, szName) + 3;1239 *pcbDirEntry = RT_UOFFSETOF(RTDIRENTRYEX, szName) + 3; 1240 1240 return VERR_BUFFER_OVERFLOW; 1241 1241 } … … 1250 1250 PCRTUTF16 pwcSrc = (PCRTUTF16)&pDirRec->achFileId[0]; 1251 1251 PCRTUTF16 pwcSrcEnd = &pwcSrc[pDirRec->bFileIdLength / sizeof(RTUTF16)]; 1252 size_t cbDst = *pcbDirEntry - RT_ OFFSETOF(RTDIRENTRYEX, szName);1253 char *pszDst = pDirEntry->szName;1252 size_t cbDst = *pcbDirEntry - RT_UOFFSETOF(RTDIRENTRYEX, szName); 1253 size_t offDst = 0; 1254 1254 while ((uintptr_t)pwcSrc < (uintptr_t)pwcSrcEnd) 1255 1255 { … … 1258 1258 if (RT_FAILURE(rc)) 1259 1259 uc = '?'; 1260 else if (!uc) 1261 break; 1260 1262 size_t cchCp = RTStrCpSize(uc); 1261 if ( cchCp < cbDst)1263 if (offDst + cchCp < cbDst) 1262 1264 { 1263 cbDst -= cchCp;1264 pszDst = RTStrPutCp(pszDst, uc);1265 RTStrPutCp(&pDirEntry->szName[offDst], uc); 1266 offDst += cchCp; 1265 1267 } 1266 1268 else 1267 1269 { 1268 1270 /* Buffer overflow. Figure out how much we really need. */ 1269 size_t off = pszDst - &pDirEntry->szName[0]; 1270 off += cchCp; 1271 offDst += cchCp; 1271 1272 while ((uintptr_t)pwcSrc < (uintptr_t)pwcSrcEnd) 1272 1273 { 1273 1274 RTUtf16BigGetCpEx(&pwcSrc, &uc); 1274 off += RTStrCpSize(uc);1275 offDst += RTStrCpSize(uc); 1275 1276 } 1276 *pcbDirEntry = RT_ OFFSETOF(RTDIRENTRYEX, szName) + off+ 1;1277 *pcbDirEntry = RT_UOFFSETOF(RTDIRENTRYEX, szName) + offDst + 1; 1277 1278 return VERR_BUFFER_OVERFLOW; 1278 1279 } 1279 1280 } 1280 *pszDst = '\0'; 1281 pDirEntry->szName[offDst] = '\0'; 1282 pDirEntry->cbName = (uint16_t)offDst; 1281 1283 } 1282 1284 else 1283 1285 { 1284 1286 /* This is supposed to be upper case ASCII, however, purge the encoding anyway. */ 1285 size_t cbNeeded = RT_ OFFSETOF(RTDIRENTRYEX, szName) + pDirRec->bFileIdLength + 1;1287 size_t cbNeeded = RT_UOFFSETOF(RTDIRENTRYEX, szName) + pDirRec->bFileIdLength + 1; 1286 1288 if (*pcbDirEntry < cbNeeded) 1287 1289 {
Note:
See TracChangeset
for help on using the changeset viewer.