File kqlives-code_cleanup.patch of Package kqlives

--- include/kq.h
+++ include/kq.h
@@ -345,10 +345,14 @@
  *
  * Contains a list of the special items in the player's party (Opal Armor et al)
  */
+ 
+#define SPECIAL_ITMES_NAMELEN 38
+#define SPECIAL_ITMES_DESCRLEN 40
+
 typedef struct
 {
-	unsigned char name[38];
-	unsigned char description[40];
+	unsigned char name[SPECIAL_ITMES_NAMELEN];
+	unsigned char description[SPECIAL_ITMES_DESCRLEN];
 	short icon;
 } s_special_item;
 
--- maps/mapdiff.c
+++ maps/mapdiff.c
@@ -139,7 +139,7 @@
           || (_cmdnum) || (_atype) || (_snapback) || (_facehero) || (_transl)
           || (_script)) {
          sprintf (strbuf, "\nCharacter %d:\tmap 1 value:\tmap 2 value:\n", i);
-         fprintf (stdout, strbuf);
+         fprintf (stdout, "%s", strbuf);
          for (j = 0; j < (signed) strlen (strbuf) + 4; j++)
             fprintf (stdout, "=");
          fprintf (stdout, "\n");
@@ -682,8 +682,8 @@
 
    sprintf (strbuf, "Could not load \"%s\"\n", problem_file);
    strcat (strncpy (err_msg, strbuf, sizeof (err_msg) - 1), "\n");
-   TRACE (strbuf);
-   allegro_message (err_msg);
+   TRACE ("%s", strbuf);
+   allegro_message ("%s", err_msg);
 }                               /* error_load () */
 
 
@@ -781,7 +781,7 @@
     */
    if (gmap1.xsize != gmap2.xsize || gmap1.ysize != gmap2.ysize) {
       sprintf (strbuf, "The maps are different sizes. Exiting.\n");
-      allegro_message (strbuf);
+      allegro_message ("%s", strbuf);
       exit (EXIT_FAILURE);
    }
 }                               /* load_maps () */
--- maps/mapdump.c
+++ maps/mapdump.c
@@ -96,7 +96,7 @@
 
    strcat (strncpy (err_msg, problem_file, sizeof (err_msg) - 1), "\n");
    TRACE ("%s: could not load %s\n", allegro_error, problem_file);
-   allegro_message (err_msg);
+   allegro_message ("%s", err_msg);
 }                               /* error_load () */
 
 
--- maps/mapedit.c
+++ maps/mapedit.c
@@ -1295,7 +1295,7 @@
 
    if (grab_tile) {
       print_sfont (column[4], row[4], "Currently grabbing:", double_buffer);
-      sprintf (strbuf, dt[draw_mode_display]);
+      sprintf (strbuf, "%s", dt[draw_mode_display]);
       print_sfont (column[4] + 24, row[5], strbuf, double_buffer);
    }                            // if (grab_tile)
 
@@ -2099,7 +2099,7 @@
 
    strcat (strncpy (err_msg, msg, sizeof (err_msg) - 1), "\n");
    TRACE ("%s\n%s\n", msg, allegro_error);
-   allegro_message (err_msg);
+   allegro_message ("%s", err_msg);
 
    ff = fopen ("mapdraw.log", "a");
    if (!ff)
--- maps/mapshared.c
+++ maps/mapshared.c
@@ -288,7 +288,7 @@
       else {
          sprintf (strbuf, "Could not find file: %s.\n", pcx_file);
 
-         allegro_message (strbuf);
+         allegro_message ("%s", strbuf);
          if (critical) {
             /* This means that this file is critical to the program, so we need to
              * exit the program completely, as this cannot be recovered from.
--- src/intrface.c
+++ src/intrface.c
@@ -1045,8 +1045,8 @@
    int icon = lua_tonumber(L, 3);
    int index = lua_tonumber(L, 4);
 
-   strncpy(special_items[index].name, name, 40);
-   strncpy(special_items[index].description, description, 40);
+   strncpy(special_items[index].name, name, SPECIAL_ITMES_NAMELEN);
+   strncpy(special_items[index].description, description, SPECIAL_ITMES_DESCRLEN);
    special_items[index].icon = icon;
    return 0;
 }
--- src/movement.c
+++ src/movement.c
@@ -235,7 +235,7 @@
 
       /*  FIXME: check to see if the buffer is long enough?  */
       snprintf (temp, sizeof (temp), "%c%d", value, repetition);
-      strncat (buffer, temp, sizeof (buffer));
+      strncat (buffer, temp, sizeof (buffer) - strlen (buffer) - 1);
    }
 
    if (strlen (buffer) < (unsigned int) size) {
openSUSE Build Service is sponsored by