Skip to content

Commit 8a135f2

Browse files
authored
PicoPass: Fix name buffer size issues (#84)
1 parent c8d2411 commit 8a135f2

5 files changed

+8
-8
lines changed

picopass_device.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PicopassDevice* picopass_device_alloc() {
3131
void picopass_device_set_name(PicopassDevice* dev, const char* name) {
3232
furi_assert(dev);
3333

34-
strlcpy(dev->dev_name, name, PICOPASS_DEV_NAME_MAX_LEN);
34+
strlcpy(dev->dev_name, name, sizeof(dev->dev_name));
3535
}
3636

3737
// For use with Seader's virtual card processing.
@@ -343,7 +343,7 @@ bool picopass_file_select(PicopassDevice* dev) {
343343
FuriString* filename;
344344
filename = furi_string_alloc();
345345
path_extract_filename(dev->load_path, filename, true);
346-
strncpy(dev->dev_name, furi_string_get_cstr(filename), PICOPASS_DEV_NAME_MAX_LEN);
346+
strlcpy(dev->dev_name, furi_string_get_cstr(filename), sizeof(dev->dev_name));
347347
res = picopass_device_load_data(dev, dev->load_path, true);
348348
if(res) {
349349
picopass_device_set_name(dev, dev->dev_name);

picopass_device.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#endif
2020
#define LOCLASS_MACS_TO_COLLECT (LOCLASS_NUM_CSNS * LOCLASS_NUM_PER_CSN)
2121

22-
#define PICOPASS_DEV_NAME_MAX_LEN 22
22+
#define PICOPASS_DEV_NAME_MAX_LEN 129
2323
#define PICOPASS_READER_DATA_MAX_SIZE 64
2424
#define PICOPASS_MAX_APP_LIMIT 32
2525

@@ -119,7 +119,7 @@ typedef struct {
119119
Storage* storage;
120120
DialogsApp* dialogs;
121121
PicopassDeviceData dev_data;
122-
char dev_name[PICOPASS_DEV_NAME_MAX_LEN + 1];
122+
char dev_name[PICOPASS_DEV_NAME_MAX_LEN];
123123
FuriString* load_path;
124124
PicopassDeviceSaveFormat format;
125125
PicopassLoadingCallback loading_cb;

picopass_i.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "protocol/picopass_poller.h"
3434
#include "protocol/picopass_listener.h"
3535

36-
#define PICOPASS_TEXT_STORE_SIZE 128
36+
#define PICOPASS_TEXT_STORE_SIZE 129
3737

3838
#define PICOPASS_ICLASS_ELITE_DICT_FLIPPER_NAME APP_ASSETS_PATH("iclass_elite_dict.txt")
3939
#define PICOPASS_ICLASS_STANDARD_DICT_FLIPPER_NAME APP_ASSETS_PATH("iclass_standard_dict.txt")
@@ -90,7 +90,7 @@ struct Picopass {
9090
PicopassListener* listener;
9191
NfcDict* dict;
9292

93-
char text_store[PICOPASS_TEXT_STORE_SIZE + 1];
93+
char text_store[PICOPASS_TEXT_STORE_SIZE];
9494
FuriString* text_box_store;
9595
uint8_t byte_input_store[PICOPASS_BLOCK_LEN];
9696

scenes/picopass_scene_delete.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void picopass_scene_delete_on_enter(void* context) {
1111
Picopass* picopass = context;
1212

1313
// Setup Custom Widget view
14-
char temp_str[64];
14+
char temp_str[141];
1515
snprintf(temp_str, sizeof(temp_str), "\e#Delete %s?\e#", picopass->dev->dev_name);
1616
widget_add_text_box_element(
1717
picopass->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, temp_str, false);

scenes/picopass_scene_save_name.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void picopass_scene_save_name_on_enter(void* context) {
2828
picopass_scene_save_name_text_input_callback,
2929
picopass,
3030
picopass->text_store,
31-
PICOPASS_DEV_NAME_MAX_LEN,
31+
sizeof(picopass->text_store),
3232
dev_name_empty);
3333

3434
FuriString* folder_path;

0 commit comments

Comments
 (0)