瀏覽代碼

dtmail: fix NULL char embedded in format string

Jon Trulson 4 年之前
父節點
當前提交
a38f72c0c8
共有 1 個文件被更改,包括 2 次插入7 次删除
  1. 2 7
      cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C

+ 2 - 7
cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C

@@ -3669,14 +3669,9 @@ char *
 RFCMailBox::generateUniqueLockId(void)
 {
   char theId[128];
-  char hwserialbuf[64];
 
-#if !defined(__aix) && !defined(__hpux) && !defined(__linux__) && !defined(CSRG_BASED)
-  if (sysinfo(SI_HW_SERIAL, (char *)hwserialbuf, sizeof(hwserialbuf)-1) == -1)
-#endif
-    strcpy(hwserialbuf, "dtmail");
-  (void) sprintf(theId, "%08ld%08ld%s\0", (long)getpid(), (long)time(NULL), hwserialbuf);
-  assert(strlen(theId)<sizeof(theId));
+  snprintf(theId, sizeof(theId), "%08ld%08ld%s", (long)getpid(),
+           (long)time(NULL), "dtmail");
   return(strdup(theId));
 }