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