bugfix (nvs): Fixed issues found by Coverity
* Fixed potential memory leak * Fixed wrong strncpy usage * Fixed potential out of bounds access
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ESP_NVS_H
|
||||
#define ESP_NVS_H
|
||||
|
||||
@@ -65,6 +57,7 @@ typedef nvs_handle_t nvs_handle IDF_DEPRECATED("Replace with nvs_handle_t");
|
||||
#define NVS_DEFAULT_PART_NAME "nvs" /*!< Default partition name of the NVS partition in the partition table */
|
||||
|
||||
#define NVS_PART_NAME_MAX_SIZE 16 /*!< maximum length of partition name (excluding null terminator) */
|
||||
#define NVS_KEY_NAME_MAX_SIZE 16 /*!< Maximal length of NVS key name (including null terminator) */
|
||||
|
||||
/**
|
||||
* @brief Mode of opening the non-volatile storage
|
||||
@@ -103,7 +96,7 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
char namespace_name[16]; /*!< Namespace to which key-value belong */
|
||||
char key[16]; /*!< Key of stored key-value pair */
|
||||
char key[NVS_KEY_NAME_MAX_SIZE]; /*!< Key of stored key-value pair */
|
||||
nvs_type_t type; /*!< Type of stored key-value pair */
|
||||
} nvs_entry_info_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user