瀏覽代碼

Fixed overflow problem.

Berk Geveci 24 年之前
父節點
當前提交
0a33722a85
共有 1 個文件被更改,包括 2 次插入8 次删除
  1. 2 8
      Source/CursesDialog/cmCursesMainForm.cxx

+ 2 - 8
Source/CursesDialog/cmCursesMainForm.cxx

@@ -357,14 +357,8 @@ void cmCursesMainForm::UpdateStatusBar()
   if (entry)
     {
     helpString = entry->m_HelpString.c_str();
-    if (strlen(helpString) > 127)
-      {
-      sprintf(help,"%127s", helpString);
-      }
-    else
-      {
-      sprintf(help,"%s", helpString);
-      }
+    strncpy(help, helpString, 127);
+    help[127] = '\0';
     }
   else
     {