浏览代码

qcacld-3.0: Correct string comparison logic while handling IOCTL

Upon receiving IOCTL RXFILTER-ADD or RXFILTER-REMOVE, driver compares
this string with the list of supported cmd strings. It uses
strncasecmp for comparison, the length of comparison is the length of
the string from the cmd list. Since position of RXFILTER is before
RXFILTER-ADD/REMOVE and only length of RXFILTER is matched with the
incoming command, it gives a false hit. This causes the IOCTL to be
ignored since the handler for RXFILTER is a dummy handler.

Calculate and use length of incoming cmd string for string comparison.

Change-Id: Ifd21d5371adb54882231c02b6c0a643258d028ae
CRs-Fixed: 2158443
Nachiket Kukade 7 年之前
父节点
当前提交
b7e0497148
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      core/hdd/src/wlan_hdd_ioctl.c

+ 7 - 2
core/hdd/src/wlan_hdd_ioctl.c

@@ -6865,7 +6865,8 @@ static int hdd_drv_cmd_process(struct hdd_adapter *adapter,
 	const int cmd_num_total = ARRAY_SIZE(hdd_drv_cmds);
 	uint8_t *cmd_i = NULL;
 	hdd_drv_cmd_handler_t handler = NULL;
-	int len = 0;
+	int len = 0, cmd_len = 0;
+	uint8_t *ptr;
 	bool args;
 
 	if (!adapter || !cmd || !priv_data) {
@@ -6873,6 +6874,10 @@ static int hdd_drv_cmd_process(struct hdd_adapter *adapter,
 		return -EINVAL;
 	}
 
+	/* Calculate length of the first word */
+	ptr = strchrnul(cmd, ' ');
+	cmd_len = ptr - cmd;
+
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 
 	for (i = 0; i < cmd_num_total; i++) {
@@ -6887,7 +6892,7 @@ static int hdd_drv_cmd_process(struct hdd_adapter *adapter,
 			return -EINVAL;
 		}
 
-		if (strncasecmp(cmd, cmd_i, len) == 0) {
+		if (len == cmd_len && strncasecmp(cmd, cmd_i, len) == 0) {
 			if (args && drv_cmd_validate(cmd, len))
 				return -EINVAL;