OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/nacl/nacl_ipc_adapter.h" | 5 #include "chrome/nacl/nacl_ipc_adapter.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 nacl_desc.reset(new NaClDescWrapper(ipc_adapter->MakeNaClDesc())); | 428 nacl_desc.reset(new NaClDescWrapper(ipc_adapter->MakeNaClDesc())); |
429 // Send back a message that the channel was created. | 429 // Send back a message that the channel was created. |
430 scoped_ptr<IPC::Message> response( | 430 scoped_ptr<IPC::Message> response( |
431 new PpapiHostMsg_ChannelCreated(channel_handle)); | 431 new PpapiHostMsg_ChannelCreated(channel_handle)); |
432 task_runner_->PostTask(FROM_HERE, | 432 task_runner_->PostTask(FROM_HERE, |
433 base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this, | 433 base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this, |
434 base::Passed(&response))); | 434 base::Passed(&response))); |
435 break; | 435 break; |
436 } | 436 } |
437 case ppapi::proxy::SerializedHandle::FILE: | 437 case ppapi::proxy::SerializedHandle::FILE: |
438 // IMPORTANT: The NaClDescIoDescFromHandleAllocCtor function creates | |
439 // a NaClDesc that checks the flags before reading and writing. This | |
440 // is necessary since PPB_FileIO now sends a file descriptor which may | |
441 // have write capabilities, and we don't want the plugin to be able to | |
dmichael (off chromium)
2013/07/18 20:28:09
"may have write capabilities"... we intend not to
bbudge
2013/07/18 21:28:16
It's non-trivial to create and share a fd with dif
| |
442 // write with it and so bypass quota checks, which still happen in the | |
443 // host. | |
438 nacl_desc.reset(new NaClDescWrapper(NaClDescIoDescFromHandleAllocCtor( | 444 nacl_desc.reset(new NaClDescWrapper(NaClDescIoDescFromHandleAllocCtor( |
439 #if defined(OS_WIN) | 445 #if defined(OS_WIN) |
440 iter->descriptor(), | 446 iter->descriptor(), |
441 #else | 447 #else |
442 iter->descriptor().fd, | 448 iter->descriptor().fd, |
443 #endif | 449 #endif |
444 TranslatePepperFileReadWriteOpenFlags(iter->open_flag())))); | 450 TranslatePepperFileReadWriteOpenFlags(iter->open_flag())))); |
445 break; | 451 break; |
446 case ppapi::proxy::SerializedHandle::INVALID: { | 452 case ppapi::proxy::SerializedHandle::INVALID: { |
447 // Nothing to do. TODO(dmichael): Should we log this? Or is it | 453 // Nothing to do. TODO(dmichael): Should we log this? Or is it |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 header.flags = msg.flags(); | 583 header.flags = msg.flags(); |
578 header.num_fds = static_cast<int>(rewritten_msg->desc_count()); | 584 header.num_fds = static_cast<int>(rewritten_msg->desc_count()); |
579 | 585 |
580 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); | 586 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); |
581 locked_data_.to_be_received_.push(rewritten_msg); | 587 locked_data_.to_be_received_.push(rewritten_msg); |
582 } | 588 } |
583 | 589 |
584 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { | 590 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { |
585 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); | 591 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); |
586 } | 592 } |
OLD | NEW |