-
Notifications
You must be signed in to change notification settings - Fork 1
new tools + fixes #9
Changes from all commits
16934b9
2a0cdce
0a088b6
6809e31
e232ac0
4129090
a15cc00
10dce6b
fcce8b3
c72c97d
57c3d02
cf1ae87
c04bea8
a33c795
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ | |
.vscode | ||
|
||
# build | ||
/pico-key/build | ||
/pico-key/build | ||
|
||
# tests | ||
/tests/basic-keystroke-injection/build/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* filesystem.c | ||
* handles filesystem related tasks | ||
*/ | ||
|
||
#include "filesystem.h" | ||
|
||
// define where to erase | ||
uint32_t startAddress = 0x10000; | ||
uint32_t sizeBytes = 4096; | ||
|
||
// format the specified area | ||
void format(void) { | ||
printf("\nErasing flash...\n"); | ||
Check warning Code scanning / devskim These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning
Banned C function detected
|
||
|
||
// erase memory at specified range | ||
flash_range_erase(startAddress, sizeBytes); | ||
|
||
printf("Done.\n"); | ||
Check warning Code scanning / devskim These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning
Banned C function detected
|
||
} | ||
|
||
// seperate the duckyscript buffer | ||
void separate(const char *buffer, size_t buflen, char *array) { | ||
// check if the buffer is empty | ||
if (buflen == 0) { | ||
printf("Buffer is empty.\n"); | ||
Check warning Code scanning / devskim These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning
Banned C function detected
|
||
return; | ||
} | ||
|
||
// index | ||
size_t index = 0; | ||
|
||
// store in array | ||
for (size_t i = 0; i < buflen; i++) { | ||
array[index++] = buffer[i]; | ||
|
||
// insert a comma | ||
if (i < buflen - 1) { | ||
array[index++] = ','; | ||
} | ||
} | ||
|
||
// null-terminate the output | ||
array[index] = '\0'; | ||
} | ||
|
||
// write the data and keep it constant | ||
void write(const void *data, size_t len) { | ||
// format memory | ||
format(void) | ||
|
||
// check if the length exceeds the available space | ||
if (len > sizeBytes) { | ||
printf("Error: Data exceeds available space :/\n"); | ||
Check warning Code scanning / devskim These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning
Banned C function detected
|
||
return; | ||
} | ||
|
||
printf("\nWriting data to flash...\n"); | ||
Check warning Code scanning / devskim These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning
Banned C function detected
|
||
|
||
uint32_t ints = save_and_disable_interrupts(); | ||
|
||
// write data to flash | ||
flash_range_program(startAddress, data, len); | ||
|
||
restore_interrupts(ints); | ||
|
||
printf("Data written successfully.\n"); | ||
Check warning Code scanning / devskim These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning
Banned C function detected
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* filesystem.h | ||
* headers for filesystem related things | ||
*/ | ||
|
||
#ifndef FILESYSTEM_H | ||
#define FILESYSTEM_H | ||
|
||
#include "config.h" | ||
#include "pico/stdio.h" | ||
#include "pico/stdlib.h" | ||
#include "hardware/flash.h" | ||
#include "hardware/irq.h" | ||
#include "hardware/sync.h" | ||
|
||
void format(void); | ||
void seperate(const char *buffer, size_t buflen, char *array); | ||
void write(const void *data, size_t len); | ||
|
||
#endif // FILESYSTEM_H |
Check warning
Code scanning / devskim
These functions are historically error-prone and have been associated with a significant number of vulnerabilities. Most of these functions have safer alternatives, such as replacing 'strcpy' with 'strlcpy' or 'strcpy_s'. Warning