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

Commit 51d26011 authored by Aditya Kodukula's avatar Aditya Kodukula Committed by Gerrit - the friendly Code Review server
Browse files

qcacmn: Add a check to ensure validity of ini file

The function qdf_ini_parse returns QDF_STATUS as SUCCESS even if no
fields are read from the ini file. Because of this even if the
ini file is corrupted and no values are read from it the function
still returns SUCCESS.

So, to avoid that and ensure that the ini file is not corrupted,
add a variable ini_read_count to count the number of fields read
from the ini file and return SUCCESS only if its value is not zero.

Change-Id: I5ec9a9cdc9780b6c9487f6ac64b411b81328d75c
CRs-Fixed: 2804937
parent a117325b
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2018 The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for
 * any purpose with or without fee is hereby granted, provided that the
@@ -30,6 +30,7 @@ QDF_STATUS qdf_ini_parse(const char *ini_path, void *context,
	QDF_STATUS status;
	char *fbuf;
	char *cursor;
	int ini_read_count = 0;

	status = qdf_file_read(ini_path, &fbuf);
	if (QDF_IS_STATUS_ERROR(status)) {
@@ -99,6 +100,8 @@ QDF_STATUS qdf_ini_parse(const char *ini_path, void *context,
			status = item_cb(context, key, value);
			if (QDF_IS_STATUS_ERROR(status))
				goto free_fbuf;
			else
				ini_read_count++;
		} else if (key[0] == '[') {
			qdf_size_t len = qdf_str_len(key);

@@ -119,7 +122,11 @@ QDF_STATUS qdf_ini_parse(const char *ini_path, void *context,
			cursor++;
	}

	qdf_debug("INI values read: %d", ini_read_count);
	if (ini_read_count != 0)
		status = QDF_STATUS_SUCCESS;
	else
		status = QDF_STATUS_E_FAILURE;

free_fbuf:
	qdf_file_buf_free(fbuf);