A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

logf: Fix two issues with logf_panic_dump()

* It had a (read) buffer overflow when dumping the stuff on the back half of the buffer
* a highly questionable code construct was nuked

Change-Id: I7f6f119524fc2095f788fc9b3d356459955d3ace

+9 -4
+1 -1
firmware/export/logf.h
··· 31 31 32 32 #define MAX_LOGF_SIZE 16384 33 33 34 - extern unsigned char logfbuffer[MAX_LOGF_SIZE]; 34 + extern unsigned char logfbuffer[MAX_LOGF_SIZE + 1]; 35 35 extern int logfindex; 36 36 extern bool logfwrap; 37 37 extern bool logfenabled;
+8 -3
firmware/logf.c
··· 61 61 #ifdef ROCKBOX_HAS_LOGF 62 62 63 63 #ifndef __PCTOOL__ 64 - unsigned char logfbuffer[MAX_LOGF_SIZE]; 64 + unsigned char logfbuffer[MAX_LOGF_SIZE + 1]; 65 65 int logfindex; 66 66 bool logfwrap; 67 67 bool logfenabled = true; ··· 272 272 return; 273 273 } 274 274 275 + /* Explicitly null-terminate our buffer */ 276 + logfbuffer[MAX_LOGF_SIZE] = 0; 277 + 275 278 lcd_puts(1, (*y)++, "start of logf data"); 276 279 lcd_update(); 280 + 281 + /* The intent is to dump the newest log entries first! */ 277 282 i = logfindex - 2; /* The last actual characer (i.e. not '\0') */ 278 - 279 283 while(i >= 0) 280 284 { 281 285 while(logfbuffer[i] != 0 && i>=0) ··· 300 304 } 301 305 if(strlen( &logfbuffer[i + 1]) > 0) 302 306 { 303 - lcd_putsf(1, (*y)++, "%*s", (MAX_LOGF_SIZE-i) &logfbuffer[i + 1]); 307 + lcd_putsf(1, (*y)++, "%*s", &logfbuffer[i + 1]); 304 308 lcd_update(); 305 309 } 306 310 } 307 311 i--; 308 312 } 313 + 309 314 lcd_puts(1, (*y)++, "end of logf data"); 310 315 lcd_update(); 311 316 }