Files
tubestation/ipc/glue/InputStreamParams.ipdlh
Andrew Sutherland 52ee093e9a Bug 1320796 - Always seek decrypted streams on first read. r=dom-storage-reviewers,janv
In cases where Available() is called on a DecryptingInputStream in one process
and then serialized and deserialized to another process, if the underlying
stream retains its position, then the deserialized DecryptingInputStream will
be in a broken state because the serialization does not propagate the internal
state that makes the altered stream position okay.

This is because when restoring state with its final restorative Seek(), the
call to DecryptingInputStream::Seek will invoke ParseNextChunk() which will
perform a read (if possible).

This fix consists of a minor change to seek the underlying stream to its
start in EnsureBuffers which will always be called exactly once before we do
any I/O, and will only happen when we were going to do I/O anyways, so this
does not induce any I/O when it would not have happened.

This patch originally contained test changes to
dom/quota/test/gtest/TestEncryptedStream.cpp but they have now been split out
in consultation with the reviewer, :janv.  Specifically the test required the
StringInputStream to serialize its offset but there is additional work to be
done for the requested XPCOM changes to correspond to that.  The test changes
will land as part of that follow-up stack.

The changes were made in order to test serialization and ensure that we also
have coverage for not calling the side-effect including Available() method
prior to reads (in order to be consistent with what we see with http request
bodies when the socket process is in use).  If the fix is commented out and
testing with the test, the test will fail permutations starting with
`DOM_Quota_EncryptedStream_Parametrized/ParametrizedCryptTest.DummyCipherStrategy_SerializeRoundtrip`.

In order to stick with the TestEncryptedStream.cpp GTest not using a file input
stream, DecryptingInputStream needed to have its serialization logic
generalized to support other serializable streams in the test.  That change has
been retained.

Differential Revision: https://phabricator.services.mozilla.com/D241157
2025-03-26 01:31:06 +00:00

102 lines
1.9 KiB
Plaintext

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include ProtocolTypes;
using struct mozilla::void_t from "mozilla/ipc/IPCCore.h";
[RefCounted] using mozilla::ipc::DataPipeReceiver from "mozilla/ipc/DataPipe.h";
[RefCounted] using mozilla::RemoteLazyInputStream from "mozilla/RemoteLazyInputStream.h";
namespace mozilla {
namespace ipc {
struct HeaderEntry
{
nsCString name;
nsCString value;
};
struct StringInputStreamParams
{
nsCString data;
};
struct FileInputStreamParams
{
FileDescriptor fileDescriptor;
int32_t behaviorFlags;
int32_t ioFlags;
};
struct MultiplexInputStreamParams
{
InputStreamParams[] streams;
uint32_t currentStream;
nsresult status;
bool startedReadingCurrent;
};
struct SlicedInputStreamParams
{
InputStreamParams stream;
uint64_t start;
uint64_t length;
uint64_t curPos;
bool closed;
};
struct RemoteLazyInputStreamParams
{
RemoteLazyInputStream stream;
};
struct DataPipeReceiverStreamParams
{
DataPipeReceiver pipe;
};
union InputStreamParams
{
StringInputStreamParams;
FileInputStreamParams;
BufferedInputStreamParams;
MIMEInputStreamParams;
MultiplexInputStreamParams;
SlicedInputStreamParams;
RemoteLazyInputStreamParams;
InputStreamLengthWrapperParams;
EncryptedFileInputStreamParams;
DataPipeReceiverStreamParams;
};
struct EncryptedFileInputStreamParams
{
InputStreamParams inputStreamParams;
uint8_t[] key;
uint32_t blockSize;
};
struct BufferedInputStreamParams
{
InputStreamParams? optionalStream;
uint32_t bufferSize;
};
struct MIMEInputStreamParams
{
InputStreamParams? optionalStream;
HeaderEntry[] headers;
bool startedReading;
};
struct InputStreamLengthWrapperParams
{
InputStreamParams stream;
int64_t length;
bool consumed;
};
} // namespace ipc
} // namespace mozilla