lib: qmi_encdec: Fix initialization error in string encode/decode

The string length variable in string encode/decode function is not
initialized to zero. It may result in decoding failure in case it is
initialized to some garbage value from stack.

Initialize the variables to zero to avoid decoding failure.

Change-Id: I77c8dca296f1070f7bd7e6b79c7dc898c3fc23b4
Signed-off-by: Atish Kumar Patra <apatra@codeaurora.org>
This commit is contained in:
Atish Kumar Patra 2015-06-15 12:13:17 -06:00 committed by Gerrit - the friendly Code Review server
parent a29b806cb7
commit 19270cdbdf
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2015, 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
@ -361,8 +361,8 @@ static int qmi_encode_string_elem(struct elem_info *ei_array,
int rc;
int encoded_bytes = 0;
struct elem_info *temp_ei = ei_array;
uint32_t string_len;
uint32_t string_len_sz;
uint32_t string_len = 0;
uint32_t string_len_sz = 0;
string_len = strlen(buf_src);
string_len_sz = temp_ei->elem_len <= U8_MAX ?
@ -696,8 +696,8 @@ static int qmi_decode_string_elem(struct elem_info *ei_array, void *buf_dst,
{
int rc;
int decoded_bytes = 0;
uint32_t string_len;
uint32_t string_len_sz;
uint32_t string_len = 0;
uint32_t string_len_sz = 0;
struct elem_info *temp_ei = ei_array;
if (dec_level == 1) {