OSDN Git Service

fix buffer overrun at do_cmd_pet_dismiss
authordis- <dis-@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 3 Jun 2013 12:14:57 +0000 (12:14 +0000)
committerdis- <dis-@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 3 Jun 2013 12:14:57 +0000 (12:14 +0000)
src/cmd5.c

index 47bcd30..69138ac 100644 (file)
@@ -1777,7 +1777,6 @@ void do_cmd_pet_dismiss(void)
        {
                bool delete_this;
                char friend_name[80];
-               char buf[80];
                bool kakunin;
 
                /* Access the monster */
@@ -1795,14 +1794,9 @@ void do_cmd_pet_dismiss(void)
 
                        /* Hack -- handle stuff */
                        handle_stuff();
-
-#ifdef JP
-                       sprintf(buf, "%s¤òÊü¤·¤Þ¤¹¤«¡© [Yes/No/Unnamed (%dÂÎ)]", friend_name, max_pet - i);
-#else
-                       sprintf(buf, "Dismiss %s? [Yes/No/Unnamed (%d remain)]", friend_name, max_pet - i);
-#endif
-                       prt(buf, 0, 0);
-
+                       
+                       msg_format(_("%s¤òÊü¤·¤Þ¤¹¤«¡© [Yes/No/Unnamed (%dÂÎ)]","Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
+                       
                        if (m_ptr->ml)
                                move_cursor_relative(m_ptr->fy, m_ptr->fx);
 
@@ -1816,12 +1810,9 @@ void do_cmd_pet_dismiss(void)
 
                                        if (kakunin)
                                        {
-#ifdef JP
-                                               sprintf(buf, "ËÜÅö¤Ë¤è¤í¤·¤¤¤Ç¤¹¤«¡© (%s) ", friend_name);
-#else
-                                               sprintf(buf, "Are you sure? (%s) ", friend_name);
-#endif
-                                               if (!get_check(buf))
+                                               msg_format(_("ËÜÅö¤Ë¤è¤í¤·¤¤¤Ç¤¹¤«¡© (%s) ","Are you sure? (%s) "), friend_name);
+                                               ch = inkey();
+                                               if (ch != 'Y' && ch != 'y')
                                                        delete_this = FALSE;
                                        }
                                        break;
@@ -1852,11 +1843,7 @@ void do_cmd_pet_dismiss(void)
 
                        if (pet_ctr == p_ptr->riding)
                        {
-#ifdef JP
-                               msg_format("%s¤«¤é¹ß¤ê¤¿¡£", friend_name);
-#else
-                               msg_format("You have got off %s. ", friend_name);
-#endif
+                               msg_format(_("%s¤«¤é¹ß¤ê¤¿¡£","You have got off %s. "), friend_name);
 
                                p_ptr->riding = 0;
 
@@ -1866,12 +1853,7 @@ void do_cmd_pet_dismiss(void)
                        }
 
                        /* HACK : Add the line to message buffer */
-#ifdef JP
-                       sprintf(buf, "%s ¤òÊü¤·¤¿¡£", friend_name);
-#else
-                       sprintf(buf, "Dismissed %s.", friend_name);
-#endif
-                       message_add(buf);
+                       msg_format(_("%s ¤òÊü¤·¤¿¡£","Dismissed %s."), friend_name);
                        p_ptr->window |= (PW_MESSAGE);
                        window_stuff();