fix: SAT 临时文件唯一化,修 DGJM.sat 读取越界

1. AcDbX3dSolid::CreateFromSat 的 temp\temp.sat 改为
   temp_<pid>_<原子序号>.sat,用完 DeleteFile。原来固定名且从不删除,
   两个 CAD 实例同时从 SAT 重建时会互相覆盖。

2. DGJM.sat 的读取统一改成「分配时补终止符 + 按实际读到的长度赋值」:
   new char[n] 之后直接赋给 CString 会把未初始化内存当字符串读到终止符,
   现在 new char[n+1] + memset,再用 CString(pszTxt, nRead) 明确长度。
   涉及 AcDbX3dSolid、AecDbEarthWormFitting、DGJMDlg、GJYXJMDlg、
   JMDBDlg、JMSJDlg 共 6 处。

DGJM.sat 本身仍是固定文件名,写读双方靠它隐式传递,本次不改名。
This commit is contained in:
company-desktop-computer committed 2026-10-21 23:39:47 +08:00
1 parent 54f24a93e4
commit e3fff2ad66
6 files changed
+49 -19

No files matched your search

+7 -3
View File
@@ -186,11 +186,15 @@ void CJMDBDlg::OnBnClickedButton2()
if (file.Open(sFullPath, CFile::modeRead))
{
ULONGLONG dwFileLength = file.GetLength();
char* pszTxt = new char[dwFileLength];
int nLen = (int)dwFileLength;
file.Read(pszTxt, dwFileLength);
// 补终止符并按实际读到的长度赋值,避免把未初始化内存当字符串读
char* pszTxt = new char[nLen + 1];
::memset(pszTxt, 0, nLen + 1);
m_sRegScr = pszTxt;
UINT nRead = file.Read(pszTxt, nLen);
m_sRegScr = CString(pszTxt, (int)nRead);
DELETE_ARR_(pszTxt);
file.Close();