]> j8takagi.net git repositories - yacasl2.git/commitdiff
エラー出力時のヒープバッファオーバーフローの問題を修正
authorj8takagi <j8takagi@nifty.com>
Tue, 4 Aug 2026 06:53:03 +0000 (15:53 +0900)
committerj8takagi <j8takagi@nifty.com>
Tue, 4 Aug 2026 06:53:03 +0000 (15:53 +0900)
https://claude.ai/share/a6dfc5f4-f845-4a2e-8a7c-eb929e393d7d

include/cerr.h
src/cerr.c

index c361c6b908ecf1849ee78034d4bc61f5d0596f9d..e778ceed6cc31686c726669f848a970d0a6735f9 100644 (file)
@@ -36,7 +36,7 @@ extern CERRLIST *cerrlist;
 
 enum {
     CERRSTRSIZE = 10,    /**<エラーメッセージ中に挿入できる文字列のサイズ */
-    CERRMSGSIZE = 70,    /**<エラーメッセージのサイズ */
+    CERRMSGSIZE = 140,    /**<エラーメッセージのサイズ */
 };
 
 /**
index 9e9d2195945857dcdb9923116938bf56c7834fc5..2aed61618fa8a7d9a00554e855e39d30f8af8d26 100644 (file)
@@ -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));