[PATCH] D20572: [profile] clean up file handling code

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 14:54:04 PDT 2016

MatzeB added a subscriber: MatzeB.

Comment at: lib/profile/InstrProfilingFile.c:129
@@ -112,1 +128,3 @@
+  if (NumHosts)
+    strncpy(lprofCurFilename.Hostname, HostStr, COMPILER_RT_MAX_HOSTLEN);
Note that `strncpy` is a really silly function: If you actually happen to write n or more characters you will not have a terminating '\0' character... My personal rule is to never use `strncpy()` but something like `snprintf(buf, bufsize, "%s%s", one, two);`


More information about the llvm-commits mailing list