Permalink
Browse files

Remove asctime64_r (and related) PYTHON-327

It's use of sprintf sets off security scanners.
We could have used snprintf instead following
glibc's implementation of asctime_r but we don't
actually use any of these functions in PyMongo so
seems easier and less contentious to just remove
them.
  • Loading branch information...
behackett committed Feb 10, 2012
1 parent 4670b66 commit 359ee6b3f1210ff082978c64fd952550e282a093
Showing with 0 additions and 53 deletions.
  1. +0 −39 bson/time64.c
  2. +0 −14 bson/time64.h
View
@@ -56,7 +56,6 @@ gmtime64_r() is a 64-bit equivalent of gmtime_r().
/* Spec says except for stftime() and the _r() functions, these
all return static memory. Stabbings! */
static struct TM Static_Return_Date;
-static char Static_Return_String[35];
static const int days_in_month[2][12] = {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
@@ -784,31 +783,6 @@ int valid_tm_mon( const struct TM* date ) {
}
-char *asctime64_r( const struct TM* date, char *result ) {
- /* I figure everything else can be displayed, even hour 25, but if
- these are out of range we walk off the name arrays */
- if( !valid_tm_wday(date) || !valid_tm_mon(date) )
- return NULL;
-
- sprintf(result, TM64_ASCTIME_FORMAT,
- wday_name[date->tm_wday],
- mon_name[date->tm_mon],
- date->tm_mday, date->tm_hour,
- date->tm_min, date->tm_sec,
- 1900 + date->tm_year);
-
- return result;
-}
-
-
-char *ctime64_r( const Time64_T* time, char* result ) {
- struct TM date;
-
- localtime64_r( time, &date );
- return asctime64_r( &date, result );
-}
-
-
/* Non-thread safe versions of the above */
struct TM *localtime64(const Time64_T *time) {
#ifdef _MSC_VER
@@ -822,16 +796,3 @@ struct TM *localtime64(const Time64_T *time) {
struct TM *gmtime64(const Time64_T *time) {
return gmtime64_r(time, &Static_Return_Date);
}
-
-char *asctime64( const struct TM* date ) {
- return asctime64_r( date, Static_Return_String );
-}
-
-char *ctime64( const Time64_T* time ) {
-#ifdef _MSC_VER
- _tzset();
-#else
- tzset();
-#endif
- return asctime64(localtime64(time));
-}
View
@@ -46,12 +46,6 @@ struct TM *localtime64_r (const Time64_T *, struct TM *);
struct TM *gmtime64 (const Time64_T *);
struct TM *localtime64 (const Time64_T *);
-char *asctime64 (const struct TM *);
-char *asctime64_r (const struct TM *, char *);
-
-char *ctime64 (const Time64_T*);
-char *ctime64_r (const Time64_T*, char*);
-
Time64_T timegm64 (const struct TM *);
Time64_T mktime64 (const struct TM *);
Time64_T timelocal64 (const struct TM *);
@@ -70,12 +64,4 @@ Time64_T timelocal64 (const struct TM *);
#endif
-/* Use a different asctime format depending on how big the year is */
-#ifdef USE_TM64
- #define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %lld\n"
-#else
- #define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
-#endif
-
-
#endif

0 comments on commit 359ee6b

Please sign in to comment.