From: j8takagi Date: Tue, 4 Aug 2026 06:53:03 +0000 (+0900) Subject: エラー出力時のヒープバッファオーバーフローの問題を修正 X-Git-Tag: v0.6p20~2 X-Git-Url: https://j8takagi.net/gitweb?a=commitdiff_plain;h=a9382448139ac9339ba4b8c8ed6675487572be07;p=yacasl2.git エラー出力時のヒープバッファオーバーフローの問題を修正 https://claude.ai/share/a6dfc5f4-f845-4a2e-8a7c-eb929e393d7d --- diff --git a/include/cerr.h b/include/cerr.h index c361c6b..e778cee 100644 --- a/include/cerr.h +++ b/include/cerr.h @@ -36,7 +36,7 @@ extern CERRLIST *cerrlist; enum { CERRSTRSIZE = 10, /**<エラーメッセージ中に挿入できる文字列のサイズ */ - CERRMSGSIZE = 70, /**<エラーメッセージのサイズ */ + CERRMSGSIZE = 140, /**<エラーメッセージのサイズ */ }; /** diff --git a/src/cerr.c b/src/cerr.c index 9e9d219..2aed616 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -52,7 +52,7 @@ void setcerr(int num, const char *str) } /* 現在のエラーメッセージを設定 */ cerr->msg = malloc_chk(CERRMSGSIZE + 1, "cerr.msg"); - if(0 < strlen(str) && strlen(str) <= CERRSTRSIZE) { + if(0 < strlen(str) && strlen(str) + 2 + strlen(getcerrmsg(num)) <= CERRMSGSIZE) { sprintf(cerr->msg, "%s: %s", str, getcerrmsg(cerr->num)); } else { strcpy(cerr->msg, getcerrmsg(cerr->num));