Skip to content

Commit 359ee6b

Browse files
committed
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.
1 parent 4670b66 commit 359ee6b

File tree

2 files changed

+0
-53
lines changed

2 files changed

+0
-53
lines changed

bson/time64.c

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ gmtime64_r() is a 64-bit equivalent of gmtime_r().
5656
/* Spec says except for stftime() and the _r() functions, these
5757
all return static memory. Stabbings! */
5858
static struct TM Static_Return_Date;
59-
static char Static_Return_String[35];
6059

6160
static const int days_in_month[2][12] = {
6261
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
@@ -784,31 +783,6 @@ int valid_tm_mon( const struct TM* date ) {
784783
}
785784

786785

787-
char *asctime64_r( const struct TM* date, char *result ) {
788-
/* I figure everything else can be displayed, even hour 25, but if
789-
these are out of range we walk off the name arrays */
790-
if( !valid_tm_wday(date) || !valid_tm_mon(date) )
791-
return NULL;
792-
793-
sprintf(result, TM64_ASCTIME_FORMAT,
794-
wday_name[date->tm_wday],
795-
mon_name[date->tm_mon],
796-
date->tm_mday, date->tm_hour,
797-
date->tm_min, date->tm_sec,
798-
1900 + date->tm_year);
799-
800-
return result;
801-
}
802-
803-
804-
char *ctime64_r( const Time64_T* time, char* result ) {
805-
struct TM date;
806-
807-
localtime64_r( time, &date );
808-
return asctime64_r( &date, result );
809-
}
810-
811-
812786
/* Non-thread safe versions of the above */
813787
struct TM *localtime64(const Time64_T *time) {
814788
#ifdef _MSC_VER
@@ -822,16 +796,3 @@ struct TM *localtime64(const Time64_T *time) {
822796
struct TM *gmtime64(const Time64_T *time) {
823797
return gmtime64_r(time, &Static_Return_Date);
824798
}
825-
826-
char *asctime64( const struct TM* date ) {
827-
return asctime64_r( date, Static_Return_String );
828-
}
829-
830-
char *ctime64( const Time64_T* time ) {
831-
#ifdef _MSC_VER
832-
_tzset();
833-
#else
834-
tzset();
835-
#endif
836-
return asctime64(localtime64(time));
837-
}

bson/time64.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ struct TM *localtime64_r (const Time64_T *, struct TM *);
4646
struct TM *gmtime64 (const Time64_T *);
4747
struct TM *localtime64 (const Time64_T *);
4848

49-
char *asctime64 (const struct TM *);
50-
char *asctime64_r (const struct TM *, char *);
51-
52-
char *ctime64 (const Time64_T*);
53-
char *ctime64_r (const Time64_T*, char*);
54-
5549
Time64_T timegm64 (const struct TM *);
5650
Time64_T mktime64 (const struct TM *);
5751
Time64_T timelocal64 (const struct TM *);
@@ -70,12 +64,4 @@ Time64_T timelocal64 (const struct TM *);
7064
#endif
7165

7266

73-
/* Use a different asctime format depending on how big the year is */
74-
#ifdef USE_TM64
75-
#define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %lld\n"
76-
#else
77-
#define TM64_ASCTIME_FORMAT "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"
78-
#endif
79-
80-
8167
#endif

0 commit comments

Comments
 (0)