mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1042387 - Add file descriptors count check r=jrmuizel
This commit is contained in:
parent
63f391665c
commit
c0eceb28a8
@ -49,8 +49,6 @@ ParamTraits<FenceHandle>::Write(Message* aMsg,
|
||||
flattenable->flatten(data, nbytes, fds, nfds);
|
||||
#endif
|
||||
aMsg->WriteSize(nbytes);
|
||||
aMsg->WriteSize(nfds);
|
||||
|
||||
aMsg->WriteBytes(data, nbytes);
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
// These buffers can't die in transit because they're created
|
||||
@ -65,15 +63,14 @@ ParamTraits<FenceHandle>::Read(const Message* aMsg,
|
||||
void** aIter, paramType* aResult)
|
||||
{
|
||||
size_t nbytes;
|
||||
size_t nfds;
|
||||
const char* data;
|
||||
|
||||
if (!aMsg->ReadSize(aIter, &nbytes) ||
|
||||
!aMsg->ReadSize(aIter, &nfds) ||
|
||||
!aMsg->ReadBytes(aIter, &data, nbytes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t nfds = aMsg->num_fds();
|
||||
int fds[nfds];
|
||||
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
@ -141,8 +138,6 @@ ParamTraits<FenceHandleFromChild>::Write(Message* aMsg,
|
||||
flattenable->flatten(data, nbytes, fds, nfds);
|
||||
#endif
|
||||
aMsg->WriteSize(nbytes);
|
||||
aMsg->WriteSize(nfds);
|
||||
|
||||
aMsg->WriteBytes(data, nbytes);
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
// If the Fence was shared cross-process, SCM_RIGHTS does
|
||||
@ -166,15 +161,14 @@ ParamTraits<FenceHandleFromChild>::Read(const Message* aMsg,
|
||||
void** aIter, paramType* aResult)
|
||||
{
|
||||
size_t nbytes;
|
||||
size_t nfds;
|
||||
const char* data;
|
||||
|
||||
if (!aMsg->ReadSize(aIter, &nbytes) ||
|
||||
!aMsg->ReadSize(aIter, &nfds) ||
|
||||
!aMsg->ReadBytes(aIter, &data, nbytes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t nfds = aMsg->num_fds();
|
||||
int fds[nfds];
|
||||
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
|
@ -97,8 +97,6 @@ ParamTraits<MagicGrallocBufferHandle>::Write(Message* aMsg,
|
||||
aMsg->WriteInt(aParam.mRef.mOwner);
|
||||
aMsg->WriteInt64(aParam.mRef.mKey);
|
||||
aMsg->WriteSize(nbytes);
|
||||
aMsg->WriteSize(nfds);
|
||||
|
||||
aMsg->WriteBytes(data, nbytes);
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
// These buffers can't die in transit because they're created
|
||||
@ -113,7 +111,6 @@ ParamTraits<MagicGrallocBufferHandle>::Read(const Message* aMsg,
|
||||
void** aIter, paramType* aResult)
|
||||
{
|
||||
size_t nbytes;
|
||||
size_t nfds;
|
||||
const char* data;
|
||||
int owner;
|
||||
int64_t index;
|
||||
@ -121,12 +118,12 @@ ParamTraits<MagicGrallocBufferHandle>::Read(const Message* aMsg,
|
||||
if (!aMsg->ReadInt(aIter, &owner) ||
|
||||
!aMsg->ReadInt64(aIter, &index) ||
|
||||
!aMsg->ReadSize(aIter, &nbytes) ||
|
||||
!aMsg->ReadSize(aIter, &nfds) ||
|
||||
!aMsg->ReadBytes(aIter, &data, nbytes)) {
|
||||
printf_stderr("ParamTraits<MagicGrallocBufferHandle>::Read() failed to read a message\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t nfds = aMsg->num_fds();
|
||||
int fds[nfds];
|
||||
bool sameProcess = (XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
for (size_t n = 0; n < nfds; ++n) {
|
||||
|
@ -159,6 +159,10 @@ void Message::EnsureFileDescriptorSet() {
|
||||
file_descriptor_set_ = new FileDescriptorSet;
|
||||
}
|
||||
|
||||
uint32_t Message::num_fds() const {
|
||||
return file_descriptor_set() ? file_descriptor_set()->size() : 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace IPC
|
||||
|
@ -204,6 +204,10 @@ class Message : public Pickle {
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
uint32_t num_fds() const;
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
static bool Dispatch(const Message* msg, T* obj, void (T::*func)()) {
|
||||
(obj->*func)();
|
||||
|
Loading…
Reference in New Issue
Block a user