mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-19 20:34:19 -07:00
Max file name length is actually 253 + null term
More than that and fatfs will truncate like name~1 Also dir_read already accounts for null term in buf size, dont malloc +1
This commit is contained in:
@@ -43,7 +43,7 @@ static RpcSessionContext rpc_session[TEST_RPC_SESSIONS];
|
||||
|
||||
#define TAG "UnitTestsRpc"
|
||||
#define MAX_RECEIVE_OUTPUT_TIMEOUT 3000
|
||||
#define MAX_NAME_LENGTH 255
|
||||
#define MAX_NAME_LENGTH 254
|
||||
#define MAX_DATA_SIZE 512u // have to be exact as in rpc_storage.c
|
||||
#define TEST_DIR TEST_DIR_NAME "/"
|
||||
#define TEST_DIR_NAME EXT_PATH("unit_tests_tmp")
|
||||
@@ -186,7 +186,7 @@ static void clean_directory(Storage* fs_api, const char* clean_dir) {
|
||||
File* dir = storage_file_alloc(fs_api);
|
||||
if(storage_dir_open(dir, clean_dir)) {
|
||||
FileInfo fileinfo;
|
||||
char* name = malloc(MAX_NAME_LENGTH + 1);
|
||||
char* name = malloc(MAX_NAME_LENGTH);
|
||||
while(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
|
||||
size_t size = strlen(clean_dir) + strlen(name) + 1 + 1;
|
||||
char* fullname = malloc(size);
|
||||
@@ -598,7 +598,7 @@ static void test_rpc_storage_list_create_expected_list(
|
||||
|
||||
while(!finish) {
|
||||
FileInfo fileinfo;
|
||||
char* name = malloc(MAX_NAME_LENGTH + 1);
|
||||
char* name = malloc(MAX_NAME_LENGTH);
|
||||
if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
|
||||
if(i == COUNT_OF(list->file)) {
|
||||
list->file_count = i;
|
||||
|
||||
+5
-3
@@ -1,5 +1,7 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
#define MAX_NAME_LEN 254
|
||||
|
||||
static void wifi_marauder_scene_script_select_callback(void* context, uint32_t index) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
@@ -35,10 +37,10 @@ void wifi_marauder_scene_script_select_on_enter(void* context) {
|
||||
File* dir_scripts = storage_file_alloc(app->storage);
|
||||
if(storage_dir_open(dir_scripts, MARAUDER_APP_FOLDER_SCRIPTS)) {
|
||||
FileInfo file_info;
|
||||
char file_path[255];
|
||||
char file_path[MAX_NAME_LEN];
|
||||
app->script_list_count = 0;
|
||||
// Goes through the files in the folder counting the ones that end with the json extension
|
||||
while(storage_dir_read(dir_scripts, &file_info, file_path, 255)) {
|
||||
while(storage_dir_read(dir_scripts, &file_info, file_path, MAX_NAME_LEN)) {
|
||||
app->script_list_count++;
|
||||
}
|
||||
if(app->script_list_count > 0) {
|
||||
@@ -48,7 +50,7 @@ void wifi_marauder_scene_script_select_on_enter(void* context) {
|
||||
storage_dir_open(dir_scripts, MARAUDER_APP_FOLDER_SCRIPTS);
|
||||
// Read the files again from the beginning, adding the scripts in the list
|
||||
int script_index = 0;
|
||||
while(storage_dir_read(dir_scripts, &file_info, file_path, 255)) {
|
||||
while(storage_dir_read(dir_scripts, &file_info, file_path, MAX_NAME_LEN)) {
|
||||
app->script_list[script_index] = furi_string_alloc();
|
||||
path_extract_filename_no_ext(file_path, app->script_list[script_index]);
|
||||
submenu_add_item(
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "gui/modules/file_browser_worker.h"
|
||||
|
||||
#define MAX_LEN_PX 110
|
||||
#define MAX_NAME_LEN 255
|
||||
#define MAX_NAME_LEN 254
|
||||
#define FRAME_HEIGHT 12
|
||||
#define MENU_ITEMS 5u
|
||||
#define MOVE_OFFSET 5u
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#define ASSETS_DIR "assets"
|
||||
#define BROWSER_ROOT STORAGE_ANY_PATH_PREFIX
|
||||
#define FILE_NAME_LEN_MAX 256
|
||||
#define FILE_NAME_LEN_MAX 254
|
||||
#define LONG_LOAD_THRESHOLD 100
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#define TAG "RpcStorage"
|
||||
|
||||
#define MAX_NAME_LENGTH 255
|
||||
#define MAX_NAME_LENGTH 254
|
||||
|
||||
static const size_t MAX_DATA_SIZE = 512;
|
||||
|
||||
@@ -282,7 +282,7 @@ static void rpc_system_storage_list_process(const PB_Main* request, void* contex
|
||||
|
||||
while(!finish) {
|
||||
FileInfo fileinfo;
|
||||
char* name = malloc(MAX_NAME_LENGTH + 1);
|
||||
char* name = malloc(MAX_NAME_LENGTH);
|
||||
if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
|
||||
if(path_contains_only_ascii(name)) {
|
||||
if(i == COUNT_OF(list->file)) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <storage/storage_sd_api.h>
|
||||
#include <power/power_service/power.h>
|
||||
|
||||
#define MAX_NAME_LENGTH 255
|
||||
#define MAX_NAME_LENGTH 254
|
||||
|
||||
static void storage_cli_print_usage() {
|
||||
printf("Usage:\r\n");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <toolbox/dir_walk.h>
|
||||
#include "toolbox/path.h"
|
||||
|
||||
#define MAX_NAME_LENGTH 256
|
||||
#define MAX_NAME_LENGTH 254
|
||||
#define FILE_BUFFER_SIZE 512
|
||||
|
||||
#define TAG "StorageAPI"
|
||||
@@ -893,7 +893,7 @@ bool storage_simply_remove_recursive(Storage* storage, const char* path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char* name = malloc(MAX_NAME_LENGTH + 1); //-V799
|
||||
char* name = malloc(MAX_NAME_LENGTH); //-V799
|
||||
File* dir = storage_file_alloc(storage);
|
||||
cur_dir = furi_string_alloc_set(path);
|
||||
bool go_deeper = false;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#define TAG "libmgr"
|
||||
|
||||
#define MAX_NAME_LEN 254
|
||||
|
||||
ARRAY_DEF(FlipperApplicationList, FlipperApplication*, M_PTR_OPLIST)
|
||||
#define M_OPL_FlipperApplicationList_t() ARRAY_OPLIST(FlipperApplicationList, M_PTR_OPLIST)
|
||||
|
||||
@@ -103,7 +105,7 @@ PluginManagerError plugin_manager_load_single(PluginManager* manager, const char
|
||||
|
||||
PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* path) {
|
||||
File* directory = storage_file_alloc(manager->storage);
|
||||
char file_name_buffer[256];
|
||||
char file_name_buffer[MAX_NAME_LEN];
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
do {
|
||||
if(!storage_dir_open(directory, path)) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "dir_walk.h"
|
||||
#include <m-list.h>
|
||||
|
||||
#define MAX_NAME_LEN 254
|
||||
|
||||
LIST_DEF(DirIndexList, uint32_t);
|
||||
|
||||
struct DirWalk {
|
||||
@@ -56,12 +58,12 @@ static bool dir_walk_filter(DirWalk* dir_walk, const char* name, FileInfo* filei
|
||||
static DirWalkResult
|
||||
dir_walk_iter(DirWalk* dir_walk, FuriString* return_path, FileInfo* fileinfo) {
|
||||
DirWalkResult result = DirWalkError;
|
||||
char* name = malloc(256); // FIXME: remove magic number
|
||||
char* name = malloc(MAX_NAME_LEN); // FIXME: remove magic number
|
||||
FileInfo info;
|
||||
bool end = false;
|
||||
|
||||
while(!end) {
|
||||
storage_dir_read(dir_walk->file, &info, name, 255);
|
||||
storage_dir_read(dir_walk->file, &info, name, MAX_NAME_LEN);
|
||||
|
||||
if(storage_file_get_error(dir_walk->file) == FSE_OK) {
|
||||
result = DirWalkOK;
|
||||
@@ -119,7 +121,7 @@ static DirWalkResult
|
||||
break;
|
||||
}
|
||||
|
||||
if(!storage_dir_read(dir_walk->file, &info, name, 255)) {
|
||||
if(!storage_dir_read(dir_walk->file, &info, name, MAX_NAME_LEN)) {
|
||||
result = DirWalkError;
|
||||
end = true;
|
||||
break;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <toolbox/path.h>
|
||||
|
||||
#define TAG "TarArch"
|
||||
#define MAX_NAME_LEN 255
|
||||
#define MAX_NAME_LEN 254
|
||||
#define FILE_BLOCK_SIZE 512
|
||||
|
||||
#define FILE_OPEN_NTRIES 10
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC 0
|
||||
#define UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN 255u
|
||||
#define UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN 254u
|
||||
#define UPDATE_OPERATION_MIN_MANIFEST_VERSION 2
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user