Package: rrootage / 0.23a-12

03_texture_filename.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (C) 2005  Miriam Ruiz <little_miry@yahoo.es>
# Copyright (C) 2005  Dafydd Harries <daf@debian.org>
# Distributed under the same license as the game. See debian/copyright.

Index: rrootage-0.23a/src/screen.c
===================================================================
--- rrootage-0.23a.orig/src/screen.c	2007-08-29 19:50:13.000000000 +0000
+++ rrootage-0.23a/src/screen.c	2007-08-29 19:55:06.000000000 +0000
@@ -73,10 +73,14 @@
 void loadGLTexture(char *fileName, GLuint *texture) {
   SDL_Surface *surface;
 
-  char name[32];
-  strcpy(name, SHARE_LOC);
-  strcat(name, "images/");
-  strcat(name, fileName);
+  char name[256];
+
+  if (snprintf(name, 256, "%s%s%s", SHARE_LOC, "images/", fileName) >= 256) {
+    fprintf(stderr, "Texture filename too long: %s\n", fileName);
+    SDL_Quit();
+    exit(1);
+  }
+
   surface = SDL_LoadBMP(name);
   if ( !surface ) {
     fprintf(stderr, "Unable to load texture: %s\n", SDL_GetError());