<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40504 >

2008/9/22 Marko Lindqvist:
>
>  Building Freeciv in Ubuntu Intrepid causes a lot of "format not a
> string literal and no format arguments" -warnings.

 S2_1 version


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/ailog.c freeciv/ai/ailog.c
--- freeciv/ai/ailog.c  2008-05-26 04:05:04.000000000 +0300
+++ freeciv/ai/ailog.c  2008-10-13 01:50:27.000000000 +0300
@@ -68,11 +68,11 @@
   my_vsnprintf(buffer2, sizeof(buffer2), msg, ap);
   va_end(ap);
 
-  cat_snprintf(buffer, sizeof(buffer), buffer2);
+  cat_snprintf(buffer, sizeof(buffer), "%s", buffer2);
   if (BV_ISSET(pplayer->debug, PLAYER_DEBUG_TECH)) {
     notify_conn(NULL, NULL, E_AI_DEBUG, "%s", buffer);
   }
-  freelog(minlevel, buffer);
+  freelog(minlevel, "%s", buffer);
 }
 
 /**************************************************************************
@@ -111,11 +111,11 @@
   my_vsnprintf(buffer2, sizeof(buffer2), msg, ap);
   va_end(ap);
 
-  cat_snprintf(buffer, sizeof(buffer), buffer2);
+  cat_snprintf(buffer, sizeof(buffer), "%s", buffer2);
   if (BV_ISSET(pplayer->debug, PLAYER_DEBUG_DIPLOMACY)) {
     notify_conn(NULL, NULL, E_AI_DEBUG, "%s", buffer);
   }
-  freelog(minlevel, buffer);
+  freelog(minlevel, "%s", buffer);
 }
 
 /**************************************************************************
@@ -146,11 +146,11 @@
   my_vsnprintf(buffer2, sizeof(buffer2), msg, ap);
   va_end(ap);
 
-  cat_snprintf(buffer, sizeof(buffer), buffer2);
+  cat_snprintf(buffer, sizeof(buffer), "%s", buffer2);
   if (pcity->debug) {
     notify_conn(NULL, NULL, E_AI_DEBUG, "%s", buffer);
   }
-  freelog(minlevel, buffer);
+  freelog(minlevel, "%s", buffer);
 }
 
 /**************************************************************************
@@ -206,11 +206,11 @@
   my_vsnprintf(buffer2, sizeof(buffer2), msg, ap);
   va_end(ap);
 
-  cat_snprintf(buffer, sizeof(buffer), buffer2);
+  cat_snprintf(buffer, sizeof(buffer), "%s", buffer2);
   if (punit->debug || messwin) {
     notify_conn(NULL, NULL, E_AI_DEBUG, "%s", buffer);
   }
-  freelog(minlevel, buffer);
+  freelog(minlevel, "%s", buffer);
 }
 
 /**************************************************************************
@@ -261,11 +261,11 @@
               type,
               TILE_XY(punit->tile),
              s, id, charge_x, charge_y);
-  cat_snprintf(buffer, sizeof(buffer), msg);
+  cat_snprintf(buffer, sizeof(buffer), "%s", msg);
   if (punit->debug) {
     notify_conn(NULL, NULL, E_AI_DEBUG, "%s", buffer);
   }
-  freelog(minlevel, buffer);
+  freelog(minlevel, "%s", buffer);
 }
 
 /**************************************************************************
@@ -315,7 +315,7 @@
   my_snprintf(buf, sizeof(buf), "  %s: %g sec turn, %g sec game", text,  \
            read_timer_seconds(aitimer[which][0]),                        \
            read_timer_seconds(aitimer[which][1]));                       \
-  freelog(LOG_NORMAL, buf);                                              \
+  freelog(LOG_NORMAL, "%s", buf);                                        \
   notify_conn(NULL, NULL, E_AI_DEBUG, "%s", buf);
 
   freelog(LOG_NORMAL, "  --- AI timing results ---");
diff -Nurd -X.diff_ignore freeciv/client/agents/cma_fec.c 
freeciv/client/agents/cma_fec.c
--- freeciv/client/agents/cma_fec.c     2008-05-26 04:05:05.000000000 +0300
+++ freeciv/client/agents/cma_fec.c     2008-10-13 02:18:49.000000000 +0300
@@ -290,7 +290,7 @@
   } else {
     if (!pcity->production.is_unit
        && improvement_has_flag(pcity->production.value, IF_GOLD)) {
-      my_snprintf(buffer, sizeof(buffer),
+      my_snprintf(buffer, sizeof(buffer), "%s",
                  improvement_name_translation(pcity->production.value));
       return buffer;
     }
diff -Nurd -X.diff_ignore freeciv/client/citydlg_common.c 
freeciv/client/citydlg_common.c
--- freeciv/client/citydlg_common.c     2008-05-26 04:05:28.000000000 +0300
+++ freeciv/client/citydlg_common.c     2008-10-13 02:30:06.000000000 +0300
@@ -211,7 +211,9 @@
      * be extended to return the longer of the two; in the meantime
      * translators can fudge it by changing this "filler" string. 
      */
-    my_snprintf(buffer, buffer_len, Q_("?filler:XXX/XXX XXX turns"));
+    /* TRANS: Use longer of "XXX turns" and "never" */
+    mystrlcpy(buffer, Q_("?filler:XXX/XXX XXX turns"), buffer_len);
+
     return;
   }
 
@@ -305,19 +307,21 @@
   if (target.is_unit) {
     struct unit_type *ptype = utype_by_number(target.value);
 
-    my_snprintf(buf[0], column_size, utype_name_translation(ptype));
-    my_snprintf(buf[1], column_size, utype_values_string(ptype));
+    mystrlcpy(buf[0], utype_name_translation(ptype), column_size);
+    mystrlcpy(buf[1], utype_values_string(ptype), column_size);
     my_snprintf(buf[2], column_size, "(%d)", unit_build_shield_cost(ptype));
   } else {
     struct player *pplayer = pcity ? city_owner(pcity) : game.player_ptr;
 
     /* Total & turns left meaningless on capitalization */
     if (improvement_has_flag(target.value, IF_GOLD)) {
-      my_snprintf(buf[0], column_size, 
improvement_name_translation(target.value));
+      mystrlcpy(buf[0], improvement_name_translation(target.value),
+               column_size);
       buf[1][0] = '\0';
       my_snprintf(buf[2], column_size, "---");
     } else {
-      my_snprintf(buf[0], column_size, 
improvement_name_translation(target.value));
+      mystrlcpy(buf[0], improvement_name_translation(target.value),
+               column_size);
 
       /* from city.c get_impr_name_ex() */
       if (pcity && is_building_replaced(pcity, target.value, RPT_CERTAIN)) {
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/dialogs.c 
freeciv/client/gui-gtk-2.0/dialogs.c
--- freeciv/client/gui-gtk-2.0/dialogs.c        2008-10-12 00:33:11.000000000 
+0300
+++ freeciv/client/gui-gtk-2.0/dialogs.c        2008-10-12 00:49:10.000000000 
+0300
@@ -1301,7 +1301,8 @@
 
   if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
     shell = gtk_message_dialog_new(NULL, 0,
-                                  GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, buf);
+                                  GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+                                  "%s", buf);
     gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Unit!"));
     setup_dialog(shell, toplevel);
     g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy),
@@ -1310,7 +1311,7 @@
   } else {
     shell = gtk_message_dialog_new(NULL, 0,
                                   GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
-                                  buf);
+                                  "%s", buf);
     gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
     setup_dialog(shell, toplevel);
     gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_YES);
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/pages.c 
freeciv/client/gui-gtk-2.0/pages.c
--- freeciv/client/gui-gtk-2.0/pages.c  2008-07-01 05:11:21.000000000 +0300
+++ freeciv/client/gui-gtk-2.0/pages.c  2008-10-12 00:49:10.000000000 +0300
@@ -1153,7 +1153,8 @@
 
   /* Show popup. */
   popup = gtk_message_dialog_new(NULL, 0,
-                                GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, buf);
+                                GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+                                "%s", buf);
   gtk_window_set_title(GTK_WINDOW(popup), _("Player/conn info"));
   setup_dialog(popup, toplevel);
   g_signal_connect(popup, "response", G_CALLBACK(gtk_widget_destroy), NULL);
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/repodlgs.c 
freeciv/client/gui-gtk-2.0/repodlgs.c
--- freeciv/client/gui-gtk-2.0/repodlgs.c       2008-05-26 04:05:10.000000000 
+0300
+++ freeciv/client/gui-gtk-2.0/repodlgs.c       2008-10-12 00:49:10.000000000 
+0300
@@ -819,7 +819,7 @@
       NULL,
       GTK_DIALOG_DESTROY_WITH_PARENT,
       GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
-      buf);
+      "%s", buf);
   setup_dialog(shell, gui_dialog_get_toplevel(dlg));
 
   g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), NULL);
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/cma_fe.c 
freeciv/client/gui-xaw/cma_fe.c
--- freeciv/client/gui-xaw/cma_fe.c     2008-05-26 04:05:12.000000000 +0300
+++ freeciv/client/gui-xaw/cma_fe.c     2008-10-12 00:49:10.000000000 +0300
@@ -379,8 +379,8 @@
   if (cmafec_preset_num()) {
     /* Add all CMA presets to the list. */
     for (i = 0; i < cmafec_preset_num(); i++) {
-      my_snprintf(preset_text[i], sizeof(preset_text[i]),
-                  cmafec_preset_get_descr(i));
+      mystrlcpy(preset_text[i], cmafec_preset_get_descr(i),
+               sizeof(preset_text[i]));
       preset_lines[i] = preset_text[i];
     }
     XawListChange(preset_list, preset_lines, cmafec_preset_num(), 0, True);
diff -Nurd -X.diff_ignore freeciv/client/helpdata.c freeciv/client/helpdata.c
--- freeciv/client/helpdata.c   2008-10-12 00:33:11.000000000 +0300
+++ freeciv/client/helpdata.c   2008-10-12 00:49:10.000000000 +0300
@@ -1331,8 +1331,8 @@
 
            output_type = preq->source.value.outputtype;
            oname = get_output_name(output_type);
-           astr_add(&outputs_or, oname);
-           astr_add(&outputs_and, oname);
+           astr_add(&outputs_or, "%s", oname);
+           astr_add(&outputs_and, "%s", oname);
          }
          break;
        case REQ_UNITCLASS:
@@ -1386,32 +1386,32 @@
 
           if (!harvested_only || pot->harvested) {
             if (prev2 != NULL) {
-              astr_add(&outputs_or,  prev2);
-              astr_add(&outputs_or,  Q_("?or:, "));
-              astr_add(&outputs_and, prev2);
-              astr_add(&outputs_and, Q_("?and:, "));
+              astr_add(&outputs_or,  "%s", prev2);
+              astr_add(&outputs_or,  "%s", Q_("?or:, "));
+              astr_add(&outputs_and, "%s", prev2);
+              astr_add(&outputs_and, "%s", Q_("?and:, "));
             }
             prev2 = prev;
             prev = _(pot->name);
           }
         } output_type_iterate_end;
         if (prev2 != NULL) {
-          astr_add(&outputs_or, prev2);
+          astr_add(&outputs_or, "%s", prev2);
           /* TRANS: List of possible output types has this between
            *        last two elements */
-          astr_add(&outputs_or,  Q_(" or "));
-          astr_add(&outputs_and, prev2);
+          astr_add(&outputs_or,  "%s", Q_(" or "));
+          astr_add(&outputs_and, "%s", prev2);
           /* TRANS: List of possible output types has this between
            *        last two elements */
-          astr_add(&outputs_and, Q_(" and "));
+          astr_add(&outputs_and, "%s", Q_(" and "));
         }
         if (prev != NULL) {
-          astr_add(&outputs_or, prev);
-          astr_add(&outputs_and, prev);
+          astr_add(&outputs_or,  "%s", prev);
+          astr_add(&outputs_and, "%s", prev);
         } else {
           /* TRANS: Empty output type list, should never happen. */
-          astr_add(&outputs_or,  Q_("?outputlist: Nothing "));
-          astr_add(&outputs_and, Q_("?outputlist: Nothing "));
+          astr_add(&outputs_or,  "%s", Q_("?outputlist: Nothing "));
+          astr_add(&outputs_and, "%s", Q_("?outputlist: Nothing "));
         }
       }
 
diff -Nurd -X.diff_ignore freeciv/client/mapview_common.c 
freeciv/client/mapview_common.c
--- freeciv/client/mapview_common.c     2008-05-26 04:05:28.000000000 +0300
+++ freeciv/client/mapview_common.c     2008-10-12 00:49:11.000000000 +0300
@@ -2196,7 +2196,7 @@
                                      size_t growth_buffer_len,
                                      enum color_std *growth_color)
 {
-  my_snprintf(name_buffer, name_buffer_len, city_name(pcity));
+  mystrlcpy(name_buffer, city_name(pcity), name_buffer_len);
 
   if (!game.player_ptr || city_owner(pcity) == game.player_ptr) {
     int turns = city_turns_to_grow(pcity);
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c   2008-09-22 04:23:55.000000000 +0300
+++ freeciv/client/packhand.c   2008-10-13 02:32:07.000000000 +0300
@@ -215,7 +215,7 @@
     aconnection.id = 0;
     if (auto_connect) {
       freelog(LOG_NORMAL, _("You were rejected from the game...."));
-      freelog(LOG_NORMAL, msg);
+      freelog(LOG_NORMAL, "%s", msg);
     }
     gui_server_connect();
     if (!with_ggz) {
diff -Nurd -X.diff_ignore freeciv/client/text.c freeciv/client/text.c
--- freeciv/client/text.c       2008-07-21 17:42:15.000000000 +0300
+++ freeciv/client/text.c       2008-10-13 02:32:55.000000000 +0300
@@ -712,7 +712,7 @@
 
     if (!goto_get_turns(&min, &max)) {
       /* TRANS: Impossible to reach goto target tile */
-      astr_add_line(&str, Q_("?goto:Unreachable"));
+      astr_add_line(&str, "%s", Q_("?goto:Unreachable"));
     } else if (min == max) {
       astr_add_line(&str, _("Turns to target: %d"), max);
     } else {
@@ -956,7 +956,7 @@
 
   astr_add_line(&str, _("Shows your current government:"));
   if (game.player_ptr) {
-    astr_add_line(&str, government_name_for_player(game.player_ptr));
+    astr_add_line(&str, "%s", government_name_for_player(game.player_ptr));
   }
   return str.str;
 }
@@ -1171,7 +1171,7 @@
   if (faces == 0) {
     astr_add(&str, _("None. "));
   } else {
-    astr_add(&str, Q_("?clistend:."));
+    astr_add(&str, "%s", Q_("?clistend:."));
   }
 
   return str.str;
@@ -1210,7 +1210,7 @@
   if (faces == 0) {
     astr_add(&str, _("None. "));
   } else {
-    astr_add(&str, Q_("?clistend:."));
+    astr_add(&str, "%s",  Q_("?clistend:."));
   }
 
   return str.str;
diff -Nurd -X.diff_ignore freeciv/server/cityhand.c freeciv/server/cityhand.c
--- freeciv/server/cityhand.c   2008-05-26 03:59:11.000000000 +0300
+++ freeciv/server/cityhand.c   2008-10-12 00:49:11.000000000 +0300
@@ -384,7 +384,7 @@
   }
 
   if (!is_allowed_city_name(pplayer, name, message, sizeof(message))) {
-    notify_player(pplayer, pcity->tile, E_BAD_COMMAND,
+    notify_player(pplayer, pcity->tile, E_BAD_COMMAND, "%s",
                  message);
     return;
   }
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2008-07-21 17:42:14.000000000 +0300
+++ freeciv/server/savegame.c   2008-10-12 00:49:11.000000000 +0300
@@ -3965,10 +3965,8 @@
     rstate.j = secfile_lookup_int(file,"random.index_J");
     rstate.k = secfile_lookup_int(file,"random.index_K");
     rstate.x = secfile_lookup_int(file,"random.index_X");
-    for(i=0;i<8;i++) {
-      char name[20];
-      my_snprintf(name, sizeof(name), "random.table%d",i);
-      string=secfile_lookup_str(file,name);
+    for(i = 0; i < 8; i++) {
+      string = secfile_lookup_str(file, "random.table%d",i);
       sscanf(string,"%8x %8x %8x %8x %8x %8x %8x", &rstate.v[7*i],
             &rstate.v[7*i+1], &rstate.v[7*i+2], &rstate.v[7*i+3],
             &rstate.v[7*i+4], &rstate.v[7*i+5], &rstate.v[7*i+6]);
@@ -4430,15 +4428,14 @@
     secfile_insert_int(file, rstate.x, "random.index_X");
 
     for (i = 0; i < 8; i++) {
-      char name[20], vec[100];
+      char vec[100];
 
-      my_snprintf(name, sizeof(name), "random.table%d", i);
       my_snprintf(vec, sizeof(vec),
                  "%8x %8x %8x %8x %8x %8x %8x", rstate.v[7 * i],
                  rstate.v[7 * i + 1], rstate.v[7 * i + 2],
                  rstate.v[7 * i + 3], rstate.v[7 * i + 4],
                  rstate.v[7 * i + 5], rstate.v[7 * i + 6]);
-      secfile_insert_str(file, vec, name);
+      secfile_insert_str(file, vec, "random.table%d", i);
     }
   } else {
     secfile_insert_int(file, 0, "game.save_random");
diff -Nurd -X.diff_ignore freeciv/server/scripting/script.c 
freeciv/server/scripting/script.c
--- freeciv/server/scripting/script.c   2008-05-26 03:59:06.000000000 +0300
+++ freeciv/server/scripting/script.c   2008-10-12 00:49:11.000000000 +0300
@@ -104,7 +104,7 @@
       }
     }
 
-    freelog(LOG_ERROR, str.str);
+    freelog(LOG_ERROR, "%s", str.str);
 
     astr_free(&str);
 
@@ -288,7 +288,7 @@
     const char *vars;
     const char *section = "script.vars";
 
-    vars = secfile_lookup_str_default(file, "", section);
+    vars = secfile_lookup_str_default(file, "", "%s", section);
     script_dostring(state, vars, section);
   }
 }
@@ -344,7 +344,7 @@
     const char *code;
     const char *section = "script.code";
 
-    code = secfile_lookup_str_default(file, "", section);
+    code = secfile_lookup_str_default(file, "", "%s", section);
     script_code = mystrdup(code);
     script_dostring(state, script_code, section);
   }
diff -Nurd -X.diff_ignore freeciv/server/sernet.c freeciv/server/sernet.c
--- freeciv/server/sernet.c     2008-10-12 00:33:09.000000000 +0300
+++ freeciv/server/sernet.c     2008-10-13 01:55:17.000000000 +0300
@@ -490,7 +490,7 @@
          if (time(NULL) > last_noplayers + srvarg.quitidle) {
            save_game_auto("Lost all connections");
            set_meta_message_string("restarting for lack of players");
-           freelog(LOG_NORMAL, get_meta_message_string());
+           freelog(LOG_NORMAL, "%s", get_meta_message_string());
            (void) send_server_info_to_metaserver(META_INFO);
 
             set_server_state(S_S_OVER);
@@ -516,7 +516,7 @@
                      "restarting in %d seconds for lack of players",
                      srvarg.quitidle);
           set_meta_message_string((const char *)buf);
-         freelog(LOG_NORMAL, get_meta_message_string());
+         freelog(LOG_NORMAL, "%s", get_meta_message_string());
          (void) send_server_info_to_metaserver(META_INFO);
        }
       } else {
diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c
--- freeciv/server/stdinhand.c  2008-09-22 04:23:55.000000000 +0300
+++ freeciv/server/stdinhand.c  2008-10-13 02:14:41.000000000 +0300
@@ -1605,13 +1605,14 @@
       if (may_view_option(caller, i)) {
        cat_snprintf(buf, sizeof(buf), "%-19s", settings[i].name);
        if ((++j % 4) == 0) {
-         cmd_reply(help_cmd, caller, C_COMMENT, buf);
+         cmd_reply(help_cmd, caller, C_COMMENT, "%s", buf);
          buf[0] = '\0';
        }
       }
     }
-    if (buf[0] != '\0')
-      cmd_reply(help_cmd, caller, C_COMMENT, buf);
+    if (buf[0] != '\0') {
+      cmd_reply(help_cmd, caller, C_COMMENT, "%s", buf);
+    }
   }
   cmd_reply(help_cmd, caller, C_COMMENT, horiz_line);
 }
@@ -1934,7 +1935,7 @@
    cmd = -1;  /* to indicate that no comannd was specified */
   }
 
-#define cmd_reply_show(string)  cmd_reply(CMD_SHOW, caller, C_COMMENT, string)
+#define cmd_reply_show(string)  cmd_reply(CMD_SHOW, caller, C_COMMENT, "%s", 
string)
 
 #define OPTION_NAME_SPACE 13
   /* under 16, so it fits into 80 cols more easily - rp */
@@ -1964,8 +1965,9 @@
   cmd_reply_show(horiz_line);
   len1 = my_snprintf(buf, sizeof(buf),
        _("%-*s value   (min,max)      "), OPTION_NAME_SPACE, _("Option"));
-  if (len1 == -1)
+  if (len1 == -1) {
     len1 = sizeof(buf) -1;
+  }
   sz_strlcat(buf, _("description"));
   cmd_reply_show(buf);
   cmd_reply_show(horiz_line);
@@ -2231,7 +2233,7 @@
     }
     check_vote(vote);
   } else {
-    cmd_reply(CMD_VOTE, caller, C_SYNTAX, usage);
+    cmd_reply(CMD_VOTE, caller, C_SYNTAX, "%s", usage);
     goto cleanup;
   }
 
@@ -2277,7 +2279,7 @@
     enum m_pre_result match_result;
 
     if (ntokens != 2) {
-      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, "%s", usage);
       goto cleanup;
     }
     pplayer = find_player_by_name_prefix(arg[1], &match_result);
@@ -2300,7 +2302,7 @@
     enum m_pre_result match_result;
 
     if (ntokens != 2) {
-      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, "%s", usage);
       goto cleanup;
     }
     pplayer = find_player_by_name_prefix(arg[1], &match_result);
@@ -2341,7 +2343,7 @@
     struct city *pcity;
 
     if (ntokens != 3) {
-      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, "%s", usage);
       goto cleanup;
     }
     if (sscanf(arg[1], "%d", &x) != 1 || sscanf(arg[2], "%d", &y) != 1) {
@@ -2371,7 +2373,7 @@
     struct tile *ptile;
 
     if (ntokens != 3) {
-      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, "%s", usage);
       goto cleanup;
     }
     if (sscanf(arg[1], "%d", &x) != 1 || sscanf(arg[2], "%d", &y) != 1) {
@@ -2402,7 +2404,7 @@
     struct unit *punit;
 
     if (ntokens != 2) {
-      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+      cmd_reply(CMD_DEBUG, caller, C_SYNTAX, "%s", usage);
       goto cleanup;
     }
     if (sscanf(arg[1], "%d", &id) != 1) {
@@ -2425,7 +2427,7 @@
                unit_name_translation(punit));
     }
   } else {
-    cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+    cmd_reply(CMD_DEBUG, caller, C_SYNTAX, "%s", usage);
   }
   cleanup:
   for (i = 0; i < ntokens; i++) {
@@ -2520,7 +2522,7 @@
 
       if (settings[cmd].bool_validate
          && !settings[cmd].bool_validate(b_val, &reject_message)) {
-       cmd_reply(CMD_SET, caller, C_SYNTAX, reject_message);
+       cmd_reply(CMD_SET, caller, C_SYNTAX, "%s", reject_message);
         return FALSE;
       } else if (!check) {
        *(op->bool_value) = b_val;
@@ -2560,7 +2562,7 @@
 
       if (settings[cmd].int_validate
          && !settings[cmd].int_validate(val, &reject_message)) {
-       cmd_reply(CMD_SET, caller, C_SYNTAX, reject_message);
+       cmd_reply(CMD_SET, caller, C_SYNTAX, "%s", reject_message);
         return FALSE;
       } else if (!check) {
        *(op->int_value) = val;
@@ -2582,7 +2584,7 @@
 
       if (settings[cmd].string_validate
          && !settings[cmd].string_validate(arg, &reject_message)) {
-       cmd_reply(CMD_SET, caller, C_SYNTAX, reject_message);
+       cmd_reply(CMD_SET, caller, C_SYNTAX, "%s", reject_message);
         return FALSE;
       } else if (!check) {
        strcpy(op->string_value, arg);
@@ -2791,7 +2793,7 @@
 
   /* check allowtake for permission */
   if (!is_allowed_to_take(pplayer, TRUE, msg)) {
-    cmd_reply(CMD_OBSERVE, caller, C_FAIL, msg);
+    cmd_reply(CMD_OBSERVE, caller, C_FAIL, "%s", msg);
     goto end;
   }
 
@@ -2958,7 +2960,7 @@
 
   /* check allowtake for permission */
   if (!is_allowed_to_take(pplayer, FALSE, msg)) {
-    cmd_reply(CMD_TAKE, caller, C_FAIL, msg);
+    cmd_reply(CMD_TAKE, caller, C_FAIL, "%s", msg);
     goto end;
   }
 
@@ -3782,10 +3784,10 @@
 **************************************************************************/
 static void start_cmd_reply(struct connection *caller, bool notify, char *msg)
 {
-    cmd_reply(CMD_START_GAME, caller, C_FAIL, msg);
-    if (notify) {
-      notify_conn(NULL, NULL, E_SETTING, msg);
-    }
+  cmd_reply(CMD_START_GAME, caller, C_FAIL, "%s", msg);
+  if (notify) {
+    notify_conn(NULL, NULL, E_SETTING, "%s", msg);
+  }
 }
 
 /**************************************************************************
@@ -3947,7 +3949,7 @@
   astr_minsize(&abuf, strlen(help)+1);
   strcpy(abuf.str, help);
   wordwrap_string(abuf.str, 78);
-  cmd_reply(help_cmd, caller, C_COMMENT, abuf.str);
+  cmd_reply(help_cmd, caller, C_COMMENT, "%s", abuf.str);
 }
 
 /**************************************************************************
@@ -4018,13 +4020,13 @@
       if (may_use(caller, i)) {
        cat_snprintf(buf, sizeof(buf), "%-19s", commands[i].name);
        if((++j % 4) == 0) {
-         cmd_reply(help_cmd, caller, C_COMMENT, buf);
+         cmd_reply(help_cmd, caller, C_COMMENT, "%s", buf);
          buf[0] = '\0';
        }
       }
     }
     if (buf[0] != '\0')
-      cmd_reply(help_cmd, caller, C_COMMENT, buf);
+      cmd_reply(help_cmd, caller, C_COMMENT, "%s", buf);
   }
   cmd_reply(help_cmd, caller, C_COMMENT, horiz_line);
 }
diff -Nurd -X.diff_ignore freeciv/utility/registry.c freeciv/utility/registry.c
--- freeciv/utility/registry.c  2008-05-26 03:58:59.000000000 +0300
+++ freeciv/utility/registry.c  2008-10-12 00:49:11.000000000 +0300
@@ -1552,7 +1552,7 @@
   my_vsnprintf(buf, sizeof(buf), path, ap);
   va_end(ap);
 
-  *dimen = secfile_lookup_vec_dimen(my_section_file, buf);
+  *dimen = secfile_lookup_vec_dimen(my_section_file, "%s", buf);
   if (*dimen == 0) {
     return NULL;
   }
@@ -1584,7 +1584,7 @@
   my_vsnprintf(buf, sizeof(buf), path, ap);
   va_end(ap);
 
-  *dimen = secfile_lookup_vec_dimen(my_section_file, buf);
+  *dimen = secfile_lookup_vec_dimen(my_section_file, "%s", buf);
   if (*dimen == 0) {
     return NULL;
   }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to