Bug 1822889 - Fix problems in ObfuscatingVFS with decoding frames read from the WAL file during recovery; r=dom-storage-reviewers,asuth,hsingh

Differential Revision: https://phabricator.services.mozilla.com/D172824
This commit is contained in:
Jan Varga 2023-04-04 14:10:39 +00:00
Родитель 8bcb463d80
Коммит ac281d953a
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -101,6 +101,8 @@ using u8 = unsigned char;
*/ */
#define OBFS_PGSZ 8192 #define OBFS_PGSZ 8192
#define WAL_FRAMEHDRSIZE 24
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom::quota; using namespace mozilla::dom::quota;
@ -273,6 +275,7 @@ static void obfsDecode(ObfsFile* p, /* File containing page to be obfuscated */
Span{a + nByte - kReservedBytes, kIvBytes}, Span{a + nByte - kReservedBytes, kIvBytes},
Span{a + i, static_cast<unsigned>(payloadLength)}, Span{a + i, static_cast<unsigned>(payloadLength)},
Span{a + i, static_cast<unsigned>(payloadLength)}); Span{a + i, static_cast<unsigned>(payloadLength)});
memset(a + nByte - kReservedBytes, 0, kIvBytes);
} }
/* /*
@ -310,8 +313,9 @@ static int obfsRead(sqlite3_file* pFile, void* zBuf, int iAmt,
pFile = ORIGFILE(pFile); pFile = ORIGFILE(pFile);
rc = pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst); rc = pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst);
if (rc == SQLITE_OK) { if (rc == SQLITE_OK) {
if (iAmt == OBFS_PGSZ && !p->inCkpt) { if ((iAmt == OBFS_PGSZ || iAmt == OBFS_PGSZ + WAL_FRAMEHDRSIZE) &&
obfsDecode(p, (u8*)zBuf, iAmt); !p->inCkpt) {
obfsDecode(p, ((u8*)zBuf) + iAmt - OBFS_PGSZ, OBFS_PGSZ);
} }
} else if (rc == SQLITE_IOERR_SHORT_READ && iOfst == 0 && iAmt >= 100) { } else if (rc == SQLITE_IOERR_SHORT_READ && iOfst == 0 && iAmt >= 100) {
static const unsigned char aEmptyDb[] = { static const unsigned char aEmptyDb[] = {