From: Habu Date: Sat, 23 Jan 2021 02:01:26 +0000 (+0900) Subject: [fix] #41312 spoil_out 関数におけるバッファオーバーラン X-Git-Tag: vmacos3.0.0-alpha52~486^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f7ada15a296cdeb0b23a7692a3865b2b99175ed3;p=hengbandforosx%2Fhengbandosx.git [fix] #41312 spoil_out 関数におけるバッファオーバーラン 参照するフラグを誤っているため、2バイト文字の2バイト目を1バイト目として処理してしまっている。 文字列の最後('\0'の前)が2バイト文字だった場合、バッファの範囲外にアクセスする可能性がある。 正しいフラグを参照するように修正する。 --- diff --git a/src/wizard/spoiler-util.c b/src/wizard/spoiler-util.c index 73e52e4e8..ffaf75c10 100644 --- a/src/wizard/spoiler-util.c +++ b/src/wizard/spoiler-util.c @@ -114,9 +114,9 @@ void spoil_out(concptr str) if (!wrap) { #ifdef JP - if (roff_p >= roff_buf + (k_flag ? 74 : 75)) + if (roff_p >= roff_buf + (iskanji_flag ? 74 : 75)) wrap = TRUE; - else if ((ch == ' ') && (roff_p >= roff_buf + (k_flag ? 72 : 73))) + else if ((ch == ' ') && (roff_p >= roff_buf + (iskanji_flag ? 72 : 73))) wrap = TRUE; #else if (roff_p >= roff_buf + 75) @@ -129,7 +129,7 @@ void spoil_out(concptr str) #ifdef JP bool k_flag_local; bool iskanji_flag_local = FALSE; - concptr tail = str + (k_flag ? 2 : 1); + concptr tail = str + (iskanji_flag ? 2 : 1); #else concptr tail = str + 1; #endif