Skip to content

Commit efffb62

Browse files
committed
truncate boot_out.txt if it's long
Now this boot.py: ```py for i in range(1000): print(i) ``` creates a 512-byte boot_out.txt that ends ``` 88 89 ... ```
1 parent 694af3d commit efffb62

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

supervisor/shared/micropython.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
6060

6161
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
6262
if (boot_output != NULL) {
63-
vstr_add_strn(boot_output, str, len);
63+
// Ensure boot_out.txt is capped at 1 filesystem block and ends with a newline
64+
if (len + boot_output->len > 508) {
65+
vstr_add_str(boot_output, "...\n");
66+
boot_output = NULL;
67+
} else {
68+
vstr_add_strn(boot_output, str, len);
69+
}
6470
}
6571
#endif
6672

0 commit comments

Comments
 (0)