tPotential buffer overflow fixed; %tde notation should now work for Location[x].Name. - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c5c96846e3ee5943f8c32560bf30e047f876b86d
 (DIR) parent 237e49d2c39b0a3fbb641caa49c8bc2f10a79399
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Tue, 30 Jul 2002 17:21:41 +0000
       
       Potential buffer overflow fixed; %tde notation should now work for
       Location[x].Name.
       
       
       Diffstat:
         M src/curses_client/curses_client.c   |      33 +++++++++++++++++++++----------
         M src/gui_client/gtk_client.c         |      10 +++++++---
         M src/message.c                       |       4 ++--
       
       3 files changed, 32 insertions(+), 15 deletions(-)
       ---
 (DIR) diff --git a/src/curses_client/curses_client.c b/src/curses_client/curses_client.c
       t@@ -667,13 +667,15 @@ static gboolean ConnectToServer(Player *Play)
        static gboolean jet(Player *Play, gboolean AllowReturn)
        {
          int i, c;
       -  char text[80];
       +  GString *text;
        
       +  text = g_string_new("");
          attrset(TextAttr);
          clear_bottom();
          for (i = 0; i < NumLocation; i++) {
       -    sprintf(text, "%d. %s", i + 1, Location[i].Name);
       -    mvaddstr(17 + i / 3, (i % 3) * 20 + 12, text);
       +    /* Display of shortcut keys and locations to jet to */
       +    dpg_string_sprintf(text, _("%d. %tde"), i + 1, Location[i].Name);
       +    mvaddstr(17 + i / 3, (i % 3) * 20 + 12, text->str);
          }
          attrset(PromptAttr);
        
       t@@ -684,18 +686,24 @@ static gboolean jet(Player *Play, gboolean AllowReturn)
          do {
            c = bgetch();
            if (c >= '1' && c < '1' + NumLocation) {
       -      addstr(Location[c - '1'].Name);
       +      dpg_string_sprintf(text, _("%/Location display/%tde"),
       +                         Location[c - '1'].Name);
       +      addstr(text->str);
              if (Play->IsAt != c - '1') {
       -        sprintf(text, "%d", c - '1');
       +        g_string_sprintf(text, "%d", c - '1');
                DisplayMode = DM_NONE;
       -        SendClientMessage(Play, C_NONE, C_REQUESTJET, NULL, text);
       -      } else
       +        SendClientMessage(Play, C_NONE, C_REQUESTJET, NULL, text->str);
       +      } else {
                c = 0;
       -    } else
       +      }
       +    } else {
              c = 0;
       +    }
          } while (c == 0 && !AllowReturn);
        
          curs_set(0);
       +  g_string_free(text, TRUE);
       +
          return (c != 0);
        }
        
       t@@ -1068,7 +1076,10 @@ void HandleClientMessage(char *Message, Player *Play)
              refresh();
              MicroSleep(100000);
            }
       -    print_location(Location[(int)Play->IsAt].Name);
       +    text = dpg_strdup_printf(_("%/Current location/%tde"),
       +                             Location[Play->IsAt].Name);
       +    print_location(text);
       +    g_free(text);
            break;
          case C_QUESTION:
            pt = Data;
       t@@ -1775,7 +1786,9 @@ void print_status(Player *Play, gboolean DispDrug)
                               Play->Bitches.Carried, Play->CoatSize);
          }
          mvaddstr(0, Width - 2 - strlen(text->str), text->str);
       -  print_location(Location[(int)Play->IsAt].Name);
       +  dpg_string_sprintf(text, _("%/Current location/%tde"),
       +                     Location[Play->IsAt].Name);
       +  print_location(text->str);
          attrset(StatsAttr);
        
          c = 0;
 (DIR) diff --git a/src/gui_client/gtk_client.c b/src/gui_client/gtk_client.c
       t@@ -1180,8 +1180,9 @@ void DisplayStats(Player *Play, struct StatusWidgets *Status)
        
          text = g_string_new(NULL);
        
       -  gtk_label_set_text(GTK_LABEL(Status->Location),
       -                     Location[(int)Play->IsAt].Name);
       +  dpg_string_sprintf(text, _("%/Current location/%tde"),
       +                     Location[Play->IsAt].Name);
       +  gtk_label_set_text(GTK_LABEL(Status->Location), text->str);
        
          g_string_sprintf(text, "%s%02d%s", Names.Month, Play->Turn, Names.Year);
          gtk_label_set_text(GTK_LABEL(Status->Date), text->str);
       t@@ -1441,7 +1442,10 @@ void Jet(GtkWidget *parent)
            row = i / boxsize;
            col = i % boxsize;
            if (AccelChar == '\0') {
       -      button = gtk_button_new_with_label(Location[i].Name);
       +      name = dpg_strdup_printf(_("%/Location to jet to/%tde"),
       +                               Location[i].Name);
       +      button = gtk_button_new_with_label(name);
       +      g_free(name);
            } else {
              button = gtk_button_new_with_label("");
        
 (DIR) diff --git a/src/message.c b/src/message.c
       t@@ -1330,8 +1330,8 @@ void FormatFightMessage(Player *To, GString *text, Player *Attacker,
              if (AttackName[0]) {
                if (!IsCop(Attacker) && brandom(0, 100) < 70
                    && Attacker->IsAt >= 0) {
       -          g_string_sprintfa(text, _("%s has got away to %s!"), AttackName,
       -                            Location[Attacker->IsAt].Name);
       +          dpg_string_sprintfa(text, _("%s has got away to %tde!"), AttackName,
       +                              Location[Attacker->IsAt].Name);
                } else {
                  g_string_sprintfa(text, _("%s has got away!"), AttackName);
                }