From 9bd48db652c48f30e845e9242fc827200ff72560 Mon Sep 17 00:00:00 2001 From: mogami Date: Mon, 16 Dec 2002 09:26:19 +0000 Subject: [PATCH] =?utf8?q?=EF=BD=BE=EE=82=89=EE=8A=98=EF=BD=B3=EF=BD=A5?= =?utf8?q?=EF=BE=9E=EF=BD=A5=EE=8A=98=EF=BE=89=EF=BD=A4=EF=BE=8E(a)?= =?utf8?q?=EF=BD=A4=EF=BE=87=EF=BD=A1=EF=BD=A2roff=5Fto=5Fbuf()=EF=BD=A4?= =?utf8?q?=EF=BE=8B=EF=BE=85=EF=BE=8F=EF=BD=A4=EF=BD=B9temp[]=EF=BD=A4?= =?utf8?q?=EF=BE=8E=EF=BD=A5=EF=BD=B5=EF=BD=A5=EF=BD=A4=EF=BD=A5=EF=BD=BA?= =?utf8?q?=EF=BD=A4=EF=BD=AC=EF=BE=82=EF=BD=AD=EF=BD=A4=E7=86=99=EF=BD=BA?= =?utf8?q?=EF=BD=A4=EF=BE=8B=20=EF=BD=A5=EF=BD=AF=EF=BD=A5=E9=AC=A3?= =?utf8?q?=EF=BE=83=EF=BD=A5=EF=BD=B7=EF=BD=A5=E8=9E=9F=EF=BD=B7=EF=BD=A4?= =?utf8?q?=EF=BE=86=EF=BD=A4=EF=BD=A4=EF=BD=A4=EF=BD=BF=EF=BD=A5=EF=BE=90?= =?utf8?q?=EF=BD=A5=EF=BD=B0=EF=BD=BD=EF=BD=A4=EF=BE=80=EF=BD=B5=EF=BD=A1?= =?utf8?q?=EF=BD=A3=EF=BD=A4=EF=BD=B5=EF=BD=A4=E9=AC=A2=EF=BE=8B=EF=BD=A5?= =?utf8?q?=EF=BD=B5=EF=BD=A5=EF=BD=A4=EF=BD=A5=EF=BD=BA=EF=BD=A4=EE=87=A7?= =?utf8?q?=E6=83=9E=EE=8D=93=EF=BE=87=EF=BE=85=EF=BE=8F=EF=BD=A4=EF=BD=B9?= =?utf8?q?=EF=BD=A4=E9=9A=8D=EF=BD=A6=EF=BD=A4=EF=BE=8B=EF=BD=A4=EF=BD=B7?= =?utf8?q?=EF=BD=A4=EF=BD=BF=EF=BD=A1=EF=BD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/autopick.c | 2 +- src/birth.c | 28 ++++++++++++++-------------- src/bldg.c | 2 +- src/cmd5.c | 2 +- src/cmd6.c | 2 +- src/externs.h | 2 +- src/files.c | 2 +- src/mind.c | 2 +- src/object1.c | 2 +- src/object2.c | 2 +- src/util.c | 6 +++++- 11 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/autopick.c b/src/autopick.c index 040244fd0..348975b8e 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -2940,7 +2940,7 @@ void do_cmd_edit_autopick(void) describe_autopick(buf, entry); - roff_to_buf(buf, 81, temp); + roff_to_buf(buf, 81, temp, sizeof(temp)); t = temp; for (i = 0; i< 2; i++) { diff --git a/src/birth.c b/src/birth.c index f74908fc0..8cbfd85c7 100644 --- a/src/birth.c +++ b/src/birth.c @@ -2355,7 +2355,7 @@ static bool get_player_realms(void) put_str(" ", 4, 40); put_str(" ", 5, 40); - roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm1)-1], 74, temp); + roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm1)-1], 74, temp, sizeof(temp)); t = temp; for (i = 0; i< 6; i++) { @@ -2418,7 +2418,7 @@ else put_str(" ", 4, 40); put_str(" ", 5, 40); - roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm2)-1], 74, temp); + roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm2)-1], 74, temp, sizeof(temp)); t = temp; for (i = 0; i< 6; i++) { @@ -3062,7 +3062,7 @@ static void get_history(void) { char temp[64*4]; - roff_to_buf(s, 60, temp); + roff_to_buf(s, 60, temp, sizeof(temp)); t = temp; for(i=0 ; i<4 ; i++){ if(t[0]==0)break; @@ -5620,7 +5620,7 @@ static bool player_birth_aux(void) clear_from(10); - roff_to_buf(race_jouhou[p_ptr->prace], 74, temp); + roff_to_buf(race_jouhou[p_ptr->prace], 74, temp, sizeof(temp)); t = temp; for (i = 0; i< 10; i++) @@ -5655,7 +5655,7 @@ static bool player_birth_aux(void) if (!get_player_class()) return FALSE; clear_from(10); - roff_to_buf(class_jouhou[p_ptr->pclass], 74, temp); + roff_to_buf(class_jouhou[p_ptr->pclass], 74, temp, sizeof(temp)); t = temp; for (i = 0; i< 9; i++) @@ -5690,7 +5690,7 @@ static bool player_birth_aux(void) if (!get_player_seikaku()) return FALSE; clear_from(10); - roff_to_buf(seikaku_jouhou[p_ptr->pseikaku], 74, temp); + roff_to_buf(seikaku_jouhou[p_ptr->pseikaku], 74, temp, sizeof(temp)); t = temp; for (i = 0; i< 6; i++) @@ -6415,13 +6415,13 @@ void player_birth(void) void dump_yourself(FILE *fff) { - char temp[80*8]; + char temp[80*10]; int i; cptr t; if (!fff) return; - roff_to_buf(race_jouhou[p_ptr->prace], 78, temp); + roff_to_buf(race_jouhou[p_ptr->prace], 78, temp, sizeof(temp)); fprintf(fff, "\n\n"); #ifdef JP fprintf(fff, "¼ï²: %s\n", race_info[p_ptr->prace].title); @@ -6429,14 +6429,14 @@ void dump_yourself(FILE *fff) fprintf(fff, "Race: %s\n", race_info[p_ptr->prace].title); #endif t = temp; - for (i = 0; i < 8; i++) + for (i = 0; i < 10; i++) { if(t[0] == 0) break; fprintf(fff, "%s\n",t); t += strlen(t) + 1; } - roff_to_buf(class_jouhou[p_ptr->pclass], 78, temp); + roff_to_buf(class_jouhou[p_ptr->pclass], 78, temp, sizeof(temp)); fprintf(fff, "\n"); #ifdef JP fprintf(fff, "¿¦¶È: %s\n", class_info[p_ptr->pclass].title); @@ -6444,14 +6444,14 @@ void dump_yourself(FILE *fff) fprintf(fff, "Class: %s\n", class_info[p_ptr->pclass].title); #endif t = temp; - for (i = 0; i < 8; i++) + for (i = 0; i < 10; i++) { if(t[0] == 0) break; fprintf(fff, "%s\n",t); t += strlen(t) + 1; } - roff_to_buf(seikaku_jouhou[p_ptr->pseikaku], 78, temp); + roff_to_buf(seikaku_jouhou[p_ptr->pseikaku], 78, temp, sizeof(temp)); fprintf(fff, "\n"); #ifdef JP fprintf(fff, "À­³Ê: %s\n", seikaku_info[p_ptr->pseikaku].title); @@ -6469,7 +6469,7 @@ void dump_yourself(FILE *fff) fprintf(fff, "\n"); if (p_ptr->realm1) { - roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm1)-1], 78, temp); + roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm1)-1], 78, temp, sizeof(temp)); #ifdef JP fprintf(fff, "ËâË¡: %s\n", realm_names[p_ptr->realm1]); #else @@ -6487,7 +6487,7 @@ void dump_yourself(FILE *fff) fprintf(fff, "\n"); if (p_ptr->realm2) { - roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm2)-1], 78, temp); + roff_to_buf(realm_jouhou[technic2magic(p_ptr->realm2)-1], 78, temp, sizeof(temp)); #ifdef JP fprintf(fff, "ËâË¡: %s\n", realm_names[p_ptr->realm2]); #else diff --git a/src/bldg.c b/src/bldg.c index 6a6711acb..d3ff394c1 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -3471,7 +3471,7 @@ static bool eval_ac(int iAC) } /* Display note */ - roff_to_buf(memo, 70, buf); + roff_to_buf(memo, 70, buf, sizeof(buf)); for (t = buf; t[0]; t += strlen(t) + 1) put_str(t, (row++) + 4, 4); diff --git a/src/cmd5.c b/src/cmd5.c index d482f4015..845857df7 100644 --- a/src/cmd5.c +++ b/src/cmd5.c @@ -549,7 +549,7 @@ s = " s_ptr = &mp_ptr->info[use_realm - 1][spell]; } - roff_to_buf( spell_tips[technic2magic(use_realm)-1][spell] ,62,temp); + roff_to_buf(spell_tips[technic2magic(use_realm)-1][spell] ,62, temp, sizeof(temp)); for(j=0, line = 11;temp[j];j+=(1+strlen(&temp[j]))) { prt(&temp[j], line, 15); diff --git a/src/cmd6.c b/src/cmd6.c index 434eb343d..91a493a7f 100644 --- a/src/cmd6.c +++ b/src/cmd6.c @@ -7139,7 +7139,7 @@ static bool select_magic_eater(bool only_browse) Term_erase(7, 21, 255); Term_erase(7, 20, 255); - roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp); + roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp)); for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j])) { prt(&temp[j], line, 10); diff --git a/src/externs.h b/src/externs.h index 196f89876..a1a920e79 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1190,7 +1190,7 @@ extern void pause_line(int row); extern void request_command(int shopping); extern bool is_a_vowel(int ch); extern int get_keymap_dir(char ch); -extern void roff_to_buf(cptr str, int wlen, char *tbuf); +extern void roff_to_buf(cptr str, int wlen, char *tbuf, size_t bufsize); #ifdef SORT_R_INFO extern void tag_sort(tag_type elements[], int number); diff --git a/src/files.c b/src/files.c index 35b6f962f..d14b8e9ec 100644 --- a/src/files.c +++ b/src/files.c @@ -3907,7 +3907,7 @@ void display_player(int mode) if (*statmsg) { char temp[64*2], *t; - roff_to_buf(statmsg, 60, temp); + roff_to_buf(statmsg, 60, temp, sizeof(temp)); t = temp; for(i=0 ; i<2 ; i++) { diff --git a/src/mind.c b/src/mind.c index 021077454..6323c6614 100644 --- a/src/mind.c +++ b/src/mind.c @@ -2282,7 +2282,7 @@ void do_cmd_mind_browse(void) Term_erase(12, 17, 255); Term_erase(12, 16, 255); - roff_to_buf( mind_tips[use_mind][n],62,temp); + roff_to_buf(mind_tips[use_mind][n], 62, temp, sizeof(temp)); for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j]))) { prt(&temp[j], line, 15); diff --git a/src/object1.c b/src/object1.c index 9a7af53f0..3f51d02eb 100644 --- a/src/object1.c +++ b/src/object1.c @@ -2393,7 +2393,7 @@ bool screen_object(object_type *o_ptr, bool real) roff_to_buf(o_ptr->name1 ? (a_text + a_info[o_ptr->name1].text) : (k_text + k_info[lookup_kind(o_ptr->tval, o_ptr->sval)].text), - 77 - 15, temp); + 77 - 15, temp, sizeof(temp)); for (j = 0; temp[j]; j += 1 + strlen(&temp[j])) { info[i] = &temp[j]; i++;} } diff --git a/src/object2.c b/src/object2.c index 361da4707..1e2ff3698 100644 --- a/src/object2.c +++ b/src/object2.c @@ -8204,7 +8204,7 @@ void do_cmd_kaji(bool only_browse) Term_erase(14, 17, 255); Term_erase(14, 16, 255); - roff_to_buf( kaji_tips[mode-1],62,temp); + roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp)); for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j]))) { prt(&temp[j], line, 15); diff --git a/src/util.c b/src/util.c index 66b3a53a0..053c55ca1 100644 --- a/src/util.c +++ b/src/util.c @@ -4818,7 +4818,7 @@ void build_gamma_table(int gamma) #endif /* SUPPORT_GAMMA */ -void roff_to_buf(cptr str, int maxlen, char *tbuf) +void roff_to_buf(cptr str, int maxlen, char *tbuf, size_t bufsize) { int read_pt = 0; int write_pt = 0; @@ -4891,6 +4891,10 @@ void roff_to_buf(cptr str, int maxlen, char *tbuf) #ifdef JP if (!kinsoku) word_punct = read_pt; #endif + + /* Not enough buffer size */ + if (write_pt + 3 >= bufsize) break; + tbuf[write_pt++] = ch[0]; line_len++; read_pt++; -- 2.11.0