@@ 13,6 13,7 @@
#include "local.h"
#define ANIM_STEPS 10
+#define BUFSIZE 4096
#define CELL_SIZE 32
#define DEFAULT_WIDTH 1280
#define DEFAULT_HEIGHT 720
@@ 860,16 861,16 @@ step_animation(void)
SDL_Surface*
try_load(const char* filename)
{
- char tex_pathname[4096];
+ char tex_pathname[BUFSIZE];
SDL_Surface* surface = NULL;
- sprintf(tex_pathname, "%s/%s", DATADIR, filename);
+ snprintf(tex_pathname, BUFSIZE, "%s/%s", DATADIR, filename);
surface = IMG_Load(tex_pathname);
if (!surface)
{
print_debug("try_load: IMG_Load failed (%s): %s", tex_pathname,
IMG_GetError());
- sprintf(tex_pathname, "./%s", filename);
+ snprintf(tex_pathname, BUFSIZE, "./%s", filename);
print_debug("try_load: trying %s", tex_pathname);
surface = IMG_Load(tex_pathname);
if (!surface)
@@ 888,7 889,7 @@ main(int argc, char** argv)
{
SDL_Event event;
int px, py;
- char datafile_pathname[4096];
+ char datafile_pathname[BUFSIZE];
atexit(&cleanup);
@@ 924,12 925,14 @@ main(int argc, char** argv)
}
else
{
- sprintf(datafile_pathname, "%s/%s", DATADIR, DEFAULT_DATAFILE);
+ snprintf(datafile_pathname, BUFSIZE, "%s/%s", DATADIR,
+ DEFAULT_DATAFILE);
if (load_labyrinth(datafile_pathname) < 0)
{
print_debug("fopen failed: %s (%s)", strerror(errno),
datafile_pathname);
- sprintf(datafile_pathname, "./%s", DEFAULT_DATAFILE);
+ snprintf(datafile_pathname, BUFSIZE, "./%s",
+ DEFAULT_DATAFILE);
print_debug("trying %s", datafile_pathname);
if (load_labyrinth(datafile_pathname) < 0)
{