]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915/gvt: Use snprintf() to prevent possible buffer overflow.
authorAleksei Gimbitskii <aleksei.gimbitskii@intel.com>
Tue, 23 Apr 2019 12:04:10 +0000 (15:04 +0300)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Thu, 25 Apr 2019 07:34:59 +0000 (15:34 +0800)
commit7d303e89f03c15cce937b7a0d58883c31b160308
treed4770ea1f4facd77cb9d714788f0098f131958f1
parentb57d2ec67ce993fb265e4afc9bee0d13f6b7184d
drm/i915/gvt: Use snprintf() to prevent possible buffer overflow.

For printing the intel_vgpu->id, a buffer with fixed length is allocated
on the stack. But if vgpu->id is greater than 6 characters, the buffer
overflow will happen. Even the string of the amount of max vgpu is less
that the length buffer right now, it's better to replace sprintf() with
snprintf().

v2:
- Increase the size of the buffer. (Colin Xu)

This patch fixed the critical issue #673 reported by klocwork.

Signed-off-by: Aleksei Gimbitskii <aleksei.gimbitskii@intel.com>
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Zhi Wang <zhi.a.wang@intel.com>
Cc: Colin Xu <colin.xu@intel.com>
Reviewed-by: Colin Xu <colin.xu@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/debugfs.c