Microsoft compilers version 1500 and above provide secure
versions of ctime and strncpy. Use them in afs_ctime.
Reviewed-on: http://gerrit.openafs.org/408
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Asanka Herath <asanka@secure-endpoints.com>
Reviewed-by: Asanka Herath <asanka@secure-endpoints.com>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
#else /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
static_inline char *
afs_ctime(const time_t *C, char *B, size_t S) {
+#if !defined(AFS_NT40_ENV) || (_MSC_VER < 1500)
strncpy(B, ctime(C), (S-1));
B[S-1] = '\0';
+#else
+ char buf[32];
+ if (ctime_s(buf, sizeof(buf), C) ||
+ strncpy_s(B, S, buf, _TRUNCATE)
+ B[0] = '\0';
+#endif
return B;
}
#endif /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */