diff options
| author | 2018-07-30 20:08:36 -0500 | |
|---|---|---|
| committer | 2018-07-30 20:08:36 -0500 | |
| commit | 2482aca7c32679339b2c79cb7f1d46234539a9ef (patch) | |
| tree | 92f7979f9fbadf1aae49f73156c3478d2cb5c2f3 /src/core/hle | |
| parent | Merge pull request #827 from lioncash/log (diff) | |
| download | yuzu-2482aca7c32679339b2c79cb7f1d46234539a9ef.tar.gz yuzu-2482aca7c32679339b2c79cb7f1d46234539a9ef.tar.xz yuzu-2482aca7c32679339b2c79cb7f1d46234539a9ef.zip | |
nvhost_ctrl_gpu: Only read the input parameters if they are actually there.
Passing nullptr to memcpy is undefined behavior.
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index 44e062f50..010072a5b 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | |||
| @@ -97,7 +97,9 @@ u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& | |||
| 97 | u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output) { | 97 | u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output) { |
| 98 | LOG_DEBUG(Service_NVDRV, "called"); | 98 | LOG_DEBUG(Service_NVDRV, "called"); |
| 99 | IoctlActiveSlotMask params{}; | 99 | IoctlActiveSlotMask params{}; |
| 100 | std::memcpy(¶ms, input.data(), input.size()); | 100 | if (input.size() > 0) { |
| 101 | std::memcpy(¶ms, input.data(), input.size()); | ||
| 102 | } | ||
| 101 | params.slot = 0x07; | 103 | params.slot = 0x07; |
| 102 | params.mask = 0x01; | 104 | params.mask = 0x01; |
| 103 | std::memcpy(output.data(), ¶ms, output.size()); | 105 | std::memcpy(output.data(), ¶ms, output.size()); |
| @@ -107,7 +109,9 @@ u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector | |||
| 107 | u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output) { | 109 | u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output) { |
| 108 | LOG_DEBUG(Service_NVDRV, "called"); | 110 | LOG_DEBUG(Service_NVDRV, "called"); |
| 109 | IoctlZcullGetCtxSize params{}; | 111 | IoctlZcullGetCtxSize params{}; |
| 110 | std::memcpy(¶ms, input.data(), input.size()); | 112 | if (input.size() > 0) { |
| 113 | std::memcpy(¶ms, input.data(), input.size()); | ||
| 114 | } | ||
| 111 | params.size = 0x1; | 115 | params.size = 0x1; |
| 112 | std::memcpy(output.data(), ¶ms, output.size()); | 116 | std::memcpy(output.data(), ¶ms, output.size()); |
| 113 | return 0; | 117 | return 0; |
| @@ -116,7 +120,11 @@ u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u | |||
| 116 | u32 nvhost_ctrl_gpu::ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output) { | 120 | u32 nvhost_ctrl_gpu::ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output) { |
| 117 | LOG_DEBUG(Service_NVDRV, "called"); | 121 | LOG_DEBUG(Service_NVDRV, "called"); |
| 118 | IoctlNvgpuGpuZcullGetInfoArgs params{}; | 122 | IoctlNvgpuGpuZcullGetInfoArgs params{}; |
| 119 | std::memcpy(¶ms, input.data(), input.size()); | 123 | |
| 124 | if (input.size() > 0) { | ||
| 125 | std::memcpy(¶ms, input.data(), input.size()); | ||
| 126 | } | ||
| 127 | |||
| 120 | params.width_align_pixels = 0x20; | 128 | params.width_align_pixels = 0x20; |
| 121 | params.height_align_pixels = 0x20; | 129 | params.height_align_pixels = 0x20; |
| 122 | params.pixel_squares_by_aliquots = 0x400; | 130 | params.pixel_squares_by_aliquots = 0x400; |