tinyusb: Fix a strncpy-related warning caused by a wrong argument

The issue was in using with `strncpy` a size of source array instead of using a size of destination array.
This commit is contained in:
Andrei Gramakov
2020-09-29 15:06:39 +02:00
parent 96d59ff3e9
commit ab33f55e1b

View File

@@ -83,11 +83,11 @@ static esp_err_t apply_path(char const *path)
ESP_LOGE(TAG, "The path is too long; maximum is %d characters", VFS_TUSB_MAX_PATH); ESP_LOGE(TAG, "The path is too long; maximum is %d characters", VFS_TUSB_MAX_PATH);
return ESP_ERR_INVALID_ARG; return ESP_ERR_INVALID_ARG;
} }
strncpy(s_vfstusb.vfs_path, path, path_len); strncpy(s_vfstusb.vfs_path, path, (VFS_TUSB_MAX_PATH - 1));
} else { } else {
strncpy(s_vfstusb.vfs_path, strncpy(s_vfstusb.vfs_path,
VFS_TUSB_PATH_DEFAULT, VFS_TUSB_PATH_DEFAULT,
strlen(VFS_TUSB_PATH_DEFAULT) + 1); (VFS_TUSB_MAX_PATH - 1));
} }
ESP_LOGV(TAG, "Path is set to `%s`", s_vfstusb.vfs_path); ESP_LOGV(TAG, "Path is set to `%s`", s_vfstusb.vfs_path);
return ESP_OK; return ESP_OK;