shithub: m8c

Download patch

ref: b76eb3af0f23c8904186f12f4d2669ec44ffb408
parent: 8114130a52e13ee9a8fe1d09a36814cdb3466b92
author: Ferrix Hovi <ferrix@ferrix.fi>
date: Thu Jun 2 13:30:30 EDT 2022

Replace remaining sprintfs

--- a/input.c
+++ b/input.c
@@ -63,7 +63,8 @@
 
   // Try to load the game controller database file
   char db_filename[1024] = {0};
-  sprintf(db_filename, "%sgamecontrollerdb.txt", SDL_GetPrefPath("", "m8c"));
+  snprintf(db_filename, sizeof(db_filename), "%sgamecontrollerdb.txt",
+           SDL_GetPrefPath("", "m8c"));
   SDL_Log("Trying to open game controller database from %s", db_filename);
   SDL_RWops *db_rw = SDL_RWFromFile(db_filename, "rb");
 
--- a/render.c
+++ b/render.c
@@ -187,7 +187,7 @@
     draw_character(&dcc);
 
     char buf[8];
-    sprintf(buf, "%02X %u", velocity, base_octave);
+    snprintf(buf, sizeof(buf), "%02X %u", velocity, base_octave);
 
     for (int i = 3; i >= 0; i--){
       dcc.c = buf[i];
--