From: Jeffrey Altman Date: Tue, 8 Sep 2009 20:36:32 +0000 (-0400) Subject: Windows: Use secure ctime and strncpy in afs_ctime X-Git-Tag: openafs-devel-1_5_63~28 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=01fae602425b91647b54888c82450091d4c89714;p=packages%2Fo%2Fopenafs.git Windows: Use secure ctime and strncpy in afs_ctime Microsoft compilers version 1400 and above provide secure versions of ctime and strncpy. Use them in afs_ctime. Correction to sha1:359c64bb674ea0606e64b91fd8252297310a9862 Thanks to Andrew Deason for identifing the mistake. Reviewed-on: http://gerrit.openafs.org/429 Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- diff --git a/src/util/afsutil.h b/src/util/afsutil.h index 177a3f2b6..5b73ad4bc 100644 --- a/src/util/afsutil.h +++ b/src/util/afsutil.h @@ -91,13 +91,13 @@ extern char *vctime(const time_t * atime); #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) +#if !defined(AFS_NT40_ENV) || (_MSC_VER < 1400) 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) + strncpy_s(B, S, buf, _TRUNCATE)) B[0] = '\0'; #endif return B;