Explorar o código

msm: camera: isp: Add logic to make null terminated string

copy_from_user function is copying one extra byte using
sizeof(input_buf) and also string is not null terminated.
So Added logic to avoid copying one extra byte and making
string null terminated.

CRs-Fixed: 3422931
Change-Id: I4657ad17adc2e8a82f1ff39c2493089412193f52
Signed-off-by: Dharmender Sharma <[email protected]>
Dharmender Sharma %!s(int64=2) %!d(string=hai) anos
pai
achega
dde3e48d13
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

+ 4 - 2
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -14886,16 +14886,18 @@ static ssize_t cam_ife_hw_mgr_perfcnt_write(
 	size_t size, loff_t *loff_t)
 {
 	char *delimiter1, *delimiter2;
-	char input_buf[16];
+	char input_buf[16] = {'\0'};
 	uint32_t counter_idx = 0, counter_val = 0;
 	struct cam_ife_hw_mgr_debug *debug_cfg = &g_ife_hw_mgr.debug_cfg;
 
 	if (size >= 16)
 		return -EINVAL;
 
-	if (copy_from_user(input_buf, ubuf, sizeof(input_buf)))
+	if (copy_from_user(input_buf, ubuf, size))
 		return -EFAULT;
 
+	input_buf[size] = '\0';
+
 	if ((!g_ife_hw_mgr.isp_caps.num_ife_perf_counters) &&
 		(!g_ife_hw_mgr.isp_caps.num_sfe_perf_counters))
 		return -EBADF;