Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers.cc

Issue 2688233002: Add null checks to the parameters of glGet* calls. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
6 6
7 namespace gpu { 7 namespace gpu {
8 namespace gles2 { 8 namespace gles2 {
9 9
10 // Custom Handlers 10 // Custom Handlers
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 *static_cast<const volatile gles2::cmds::GetActiveUniformBlockiv*>( 221 *static_cast<const volatile gles2::cmds::GetActiveUniformBlockiv*>(
222 cmd_data); 222 cmd_data);
223 GLuint program = static_cast<GLuint>(c.program); 223 GLuint program = static_cast<GLuint>(c.program);
224 GLuint uniformBlockIndex = static_cast<GLuint>(c.index); 224 GLuint uniformBlockIndex = static_cast<GLuint>(c.index);
225 GLenum pname = static_cast<GLenum>(c.pname); 225 GLenum pname = static_cast<GLenum>(c.pname);
226 unsigned int buffer_size = 0; 226 unsigned int buffer_size = 0;
227 typedef cmds::GetActiveUniformBlockiv::Result Result; 227 typedef cmds::GetActiveUniformBlockiv::Result Result;
228 Result* result = GetSharedMemoryAndSizeAs<Result*>( 228 Result* result = GetSharedMemoryAndSizeAs<Result*>(
229 c.params_shm_id, c.params_shm_offset, &buffer_size); 229 c.params_shm_id, c.params_shm_offset, &buffer_size);
230 GLint* params = result ? result->GetData() : NULL; 230 GLint* params = result ? result->GetData() : NULL;
231 if (params == NULL) {
232 return error::kOutOfBounds;
233 }
231 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); 234 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
232 GLsizei length = 0; 235 GLsizei length = 0;
233 error::Error error = DoGetActiveUniformBlockiv( 236 error::Error error = DoGetActiveUniformBlockiv(
234 program, uniformBlockIndex, pname, bufsize, &length, params); 237 program, uniformBlockIndex, pname, bufsize, &length, params);
235 if (error != error::kNoError) { 238 if (error != error::kNoError) {
236 return error; 239 return error;
237 } 240 }
238 if (length > bufsize) { 241 if (length > bufsize) {
239 return error::kOutOfBounds; 242 return error::kOutOfBounds;
240 } 243 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 const volatile gles2::cmds::GetInternalformativ& c = 441 const volatile gles2::cmds::GetInternalformativ& c =
439 *static_cast<const volatile gles2::cmds::GetInternalformativ*>(cmd_data); 442 *static_cast<const volatile gles2::cmds::GetInternalformativ*>(cmd_data);
440 GLenum target = static_cast<GLenum>(c.target); 443 GLenum target = static_cast<GLenum>(c.target);
441 GLenum internalformat = static_cast<GLenum>(c.format); 444 GLenum internalformat = static_cast<GLenum>(c.format);
442 GLenum pname = static_cast<GLenum>(c.pname); 445 GLenum pname = static_cast<GLenum>(c.pname);
443 unsigned int buffer_size = 0; 446 unsigned int buffer_size = 0;
444 typedef cmds::GetInternalformativ::Result Result; 447 typedef cmds::GetInternalformativ::Result Result;
445 Result* result = GetSharedMemoryAndSizeAs<Result*>( 448 Result* result = GetSharedMemoryAndSizeAs<Result*>(
446 c.params_shm_id, c.params_shm_offset, &buffer_size); 449 c.params_shm_id, c.params_shm_offset, &buffer_size);
447 GLint* params = result ? result->GetData() : NULL; 450 GLint* params = result ? result->GetData() : NULL;
451 if (params == NULL) {
452 return error::kOutOfBounds;
453 }
448 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); 454 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
449 GLsizei length = 0; 455 GLsizei length = 0;
450 error::Error error = DoGetInternalformativ(target, internalformat, pname, 456 error::Error error = DoGetInternalformativ(target, internalformat, pname,
451 bufsize, &length, params); 457 bufsize, &length, params);
452 if (error != error::kNoError) { 458 if (error != error::kNoError) {
453 return error; 459 return error;
454 } 460 }
455 if (length > bufsize) { 461 if (length > bufsize) {
456 return error::kOutOfBounds; 462 return error::kOutOfBounds;
457 } 463 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 const volatile void* cmd_data) { 650 const volatile void* cmd_data) {
645 const volatile gles2::cmds::GetUniformfv& c = 651 const volatile gles2::cmds::GetUniformfv& c =
646 *static_cast<const volatile gles2::cmds::GetUniformfv*>(cmd_data); 652 *static_cast<const volatile gles2::cmds::GetUniformfv*>(cmd_data);
647 GLuint program = static_cast<GLuint>(c.program); 653 GLuint program = static_cast<GLuint>(c.program);
648 GLint location = static_cast<GLint>(c.location); 654 GLint location = static_cast<GLint>(c.location);
649 unsigned int buffer_size = 0; 655 unsigned int buffer_size = 0;
650 typedef cmds::GetUniformfv::Result Result; 656 typedef cmds::GetUniformfv::Result Result;
651 Result* result = GetSharedMemoryAndSizeAs<Result*>( 657 Result* result = GetSharedMemoryAndSizeAs<Result*>(
652 c.params_shm_id, c.params_shm_offset, &buffer_size); 658 c.params_shm_id, c.params_shm_offset, &buffer_size);
653 GLfloat* params = result ? result->GetData() : NULL; 659 GLfloat* params = result ? result->GetData() : NULL;
660 if (params == NULL) {
661 return error::kOutOfBounds;
662 }
654 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); 663 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
655 GLsizei length = 0; 664 GLsizei length = 0;
656 error::Error error = 665 error::Error error =
657 DoGetUniformfv(program, location, bufsize, &length, params); 666 DoGetUniformfv(program, location, bufsize, &length, params);
658 if (error != error::kNoError) { 667 if (error != error::kNoError) {
659 return error; 668 return error;
660 } 669 }
661 if (length > bufsize) { 670 if (length > bufsize) {
662 return error::kOutOfBounds; 671 return error::kOutOfBounds;
663 } 672 }
664 result->SetNumResults(length); 673 result->SetNumResults(length);
665 return error::kNoError; 674 return error::kNoError;
666 } 675 }
667 676
668 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformiv( 677 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformiv(
669 uint32_t immediate_data_size, 678 uint32_t immediate_data_size,
670 const volatile void* cmd_data) { 679 const volatile void* cmd_data) {
671 const volatile gles2::cmds::GetUniformiv& c = 680 const volatile gles2::cmds::GetUniformiv& c =
672 *static_cast<const volatile gles2::cmds::GetUniformiv*>(cmd_data); 681 *static_cast<const volatile gles2::cmds::GetUniformiv*>(cmd_data);
673 GLuint program = static_cast<GLuint>(c.program); 682 GLuint program = static_cast<GLuint>(c.program);
674 GLint location = static_cast<GLint>(c.location); 683 GLint location = static_cast<GLint>(c.location);
675 unsigned int buffer_size = 0; 684 unsigned int buffer_size = 0;
676 typedef cmds::GetUniformiv::Result Result; 685 typedef cmds::GetUniformiv::Result Result;
677 Result* result = GetSharedMemoryAndSizeAs<Result*>( 686 Result* result = GetSharedMemoryAndSizeAs<Result*>(
678 c.params_shm_id, c.params_shm_offset, &buffer_size); 687 c.params_shm_id, c.params_shm_offset, &buffer_size);
679 GLint* params = result ? result->GetData() : NULL; 688 GLint* params = result ? result->GetData() : NULL;
689 if (params == NULL) {
690 return error::kOutOfBounds;
691 }
680 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); 692 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
681 GLsizei length = 0; 693 GLsizei length = 0;
682 error::Error error = 694 error::Error error =
683 DoGetUniformiv(program, location, bufsize, &length, params); 695 DoGetUniformiv(program, location, bufsize, &length, params);
684 if (error != error::kNoError) { 696 if (error != error::kNoError) {
685 return error; 697 return error;
686 } 698 }
687 if (length > bufsize) { 699 if (length > bufsize) {
688 return error::kOutOfBounds; 700 return error::kOutOfBounds;
689 } 701 }
690 result->SetNumResults(length); 702 result->SetNumResults(length);
691 return error::kNoError; 703 return error::kNoError;
692 } 704 }
693 705
694 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformuiv( 706 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformuiv(
695 uint32_t immediate_data_size, 707 uint32_t immediate_data_size,
696 const volatile void* cmd_data) { 708 const volatile void* cmd_data) {
697 const volatile gles2::cmds::GetUniformuiv& c = 709 const volatile gles2::cmds::GetUniformuiv& c =
698 *static_cast<const volatile gles2::cmds::GetUniformuiv*>(cmd_data); 710 *static_cast<const volatile gles2::cmds::GetUniformuiv*>(cmd_data);
699 GLuint program = static_cast<GLuint>(c.program); 711 GLuint program = static_cast<GLuint>(c.program);
700 GLint location = static_cast<GLint>(c.location); 712 GLint location = static_cast<GLint>(c.location);
701 unsigned int buffer_size = 0; 713 unsigned int buffer_size = 0;
702 typedef cmds::GetUniformuiv::Result Result; 714 typedef cmds::GetUniformuiv::Result Result;
703 Result* result = GetSharedMemoryAndSizeAs<Result*>( 715 Result* result = GetSharedMemoryAndSizeAs<Result*>(
704 c.params_shm_id, c.params_shm_offset, &buffer_size); 716 c.params_shm_id, c.params_shm_offset, &buffer_size);
705 GLuint* params = result ? result->GetData() : NULL; 717 GLuint* params = result ? result->GetData() : NULL;
718 if (params == NULL) {
719 return error::kOutOfBounds;
720 }
706 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); 721 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
707 GLsizei length = 0; 722 GLsizei length = 0;
708 error::Error error = 723 error::Error error =
709 DoGetUniformuiv(program, location, bufsize, &length, params); 724 DoGetUniformuiv(program, location, bufsize, &length, params);
710 if (error != error::kNoError) { 725 if (error != error::kNoError) {
711 return error; 726 return error;
712 } 727 }
713 if (length > bufsize) { 728 if (length > bufsize) {
714 return error::kOutOfBounds; 729 return error::kOutOfBounds;
715 } 730 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 const volatile gles2::cmds::GetVertexAttribPointerv& c = 809 const volatile gles2::cmds::GetVertexAttribPointerv& c =
795 *static_cast<const volatile gles2::cmds::GetVertexAttribPointerv*>( 810 *static_cast<const volatile gles2::cmds::GetVertexAttribPointerv*>(
796 cmd_data); 811 cmd_data);
797 GLuint index = static_cast<GLuint>(c.index); 812 GLuint index = static_cast<GLuint>(c.index);
798 GLenum pname = static_cast<GLenum>(c.pname); 813 GLenum pname = static_cast<GLenum>(c.pname);
799 unsigned int buffer_size = 0; 814 unsigned int buffer_size = 0;
800 typedef cmds::GetVertexAttribPointerv::Result Result; 815 typedef cmds::GetVertexAttribPointerv::Result Result;
801 Result* result = GetSharedMemoryAndSizeAs<Result*>( 816 Result* result = GetSharedMemoryAndSizeAs<Result*>(
802 c.pointer_shm_id, c.pointer_shm_offset, &buffer_size); 817 c.pointer_shm_id, c.pointer_shm_offset, &buffer_size);
803 GLuint* params = result ? result->GetData() : NULL; 818 GLuint* params = result ? result->GetData() : NULL;
819 if (params == NULL) {
820 return error::kOutOfBounds;
821 }
804 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); 822 GLsizei bufsize = Result::ComputeMaxResults(buffer_size);
805 GLsizei length = 0; 823 GLsizei length = 0;
806 error::Error error = 824 error::Error error =
807 DoGetVertexAttribPointerv(index, pname, bufsize, &length, params); 825 DoGetVertexAttribPointerv(index, pname, bufsize, &length, params);
808 if (error != error::kNoError) { 826 if (error != error::kNoError) {
809 return error; 827 return error;
810 } 828 }
811 if (length > bufsize) { 829 if (length > bufsize) {
812 return error::kOutOfBounds; 830 return error::kOutOfBounds;
813 } 831 }
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 // TODO(geofflang): Handle PIXEL_UNPACK_BUFFER case. 2622 // TODO(geofflang): Handle PIXEL_UNPACK_BUFFER case.
2605 const void* data = GetSharedMemoryAs<const void*>( 2623 const void* data = GetSharedMemoryAs<const void*>(
2606 c.data_shm_id, c.data_shm_offset, image_size); 2624 c.data_shm_id, c.data_shm_offset, image_size);
2607 return DoCompressedTexSubImage3D( 2625 return DoCompressedTexSubImage3D(
2608 target, level, xoffset, yoffset, zoffset, width, height, depth, 2626 target, level, xoffset, yoffset, zoffset, width, height, depth,
2609 format, image_size, data); 2627 format, image_size, data);
2610 } 2628 }
2611 2629
2612 } // namespace gles2 2630 } // namespace gles2
2613 } // namespace gpu 2631 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698