Jelajahi Sumber

qcacld-3.0: Fix buffer over flow in hdd state ctrl

In hdd state ctrl API buf used beyond its size.

Increase buf size to 3 to get rid of buffer over flow.

CRs-fixed: 2029584
Change-Id: Ie353d449f167bee05833841350d61dc0935786fc
SaidiReddy Yenuga 8 tahun lalu
induk
melakukan
c356f15969
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      core/hdd/src/wlan_hdd_main.c

+ 4 - 4
core/hdd/src/wlan_hdd_main.c

@@ -10547,23 +10547,23 @@ static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp,
 						size_t count,
 						loff_t *f_pos)
 {
-	char buf;
+	char buf[3];
 	static const char wlan_off_str[] = "OFF";
 	static const char wlan_on_str[] = "ON";
 	int ret;
 	unsigned long rc;
 
-	if (copy_from_user(&buf, user_buf, 3)) {
+	if (copy_from_user(buf, user_buf, 3)) {
 		pr_err("Failed to read buffer\n");
 		return -EINVAL;
 	}
 
-	if (strncmp(&buf, wlan_off_str, strlen(wlan_off_str)) == 0) {
+	if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) {
 		pr_debug("Wifi turning off from UI\n");
 		goto exit;
 	}
 
-	if (strncmp(&buf, wlan_on_str, strlen(wlan_on_str)) != 0) {
+	if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) {
 		pr_err("Invalid value received from framework");
 		goto exit;
 	}