Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65a064d6 authored by Deepak Kumar Singh's avatar Deepak Kumar Singh
Browse files

soc: qcom: qmi_encdec: Restrict string length in decode



The QMI TLV value for strings in a lot of qmi element info structures
account for null terminated strings with MAX_LEN + 1. If a string is
actually MAX_LEN + 1 length, this will cause an out of bounds access
when the NULL character is appended in decoding.

CR-Fixed: 2359244
Change-Id: I4d789bc6017ff58458f77fe875ca4e175a4f1357
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
Signed-off-by: default avatarDeepak Kumar Singh <deesin@codeaurora.org>
parent db401cc9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016, 2019 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -706,8 +706,8 @@ static int qmi_decode_string_elem(struct elem_info *ei_array, void *buf_dst,
		decoded_bytes += rc;
	}

	if (string_len > temp_ei->elem_len) {
		pr_err("%s: String len %d > Max Len %d\n",
	if (string_len >= temp_ei->elem_len) {
		pr_err("%s: String len %d >= Max Len %d\n",
			__func__, string_len, temp_ei->elem_len);
		return -ETOOSMALL;
	} else if (string_len > tlv_len) {