Merge "Use snprintf instead of sprintf."
This commit is contained in:
commit
eeb9aa02b7
@ -748,10 +748,24 @@ static 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) )
|
||||
if (!valid_tm_wday(date) || !valid_tm_mon(date)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
|
||||
/* Docs state this function does not support years beyond 9999. */
|
||||
if (1900 + date->tm_year > 9999) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The IBM docs for this function state that the result buffer can be
|
||||
* assumed to be at least 26 bytes wide. The docs also state that this is
|
||||
* only valid for years <= 9999, so we know this format string will not
|
||||
* print more than that many characters.
|
||||
*
|
||||
* http://www-01.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/asctimer.htm
|
||||
*/
|
||||
snprintf(result, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
|
||||
wday_name[date->tm_wday],
|
||||
mon_name[date->tm_mon],
|
||||
date->tm_mday, date->tm_hour,
|
||||
|
Loading…
x
Reference in New Issue
Block a user