1
0
mirror of https://github.com/deadw00d/AROS.git synced 2025-12-06 05:00:25 +00:00

use snprintf, constrain the date/month to quieten compilers, and allow for someone to build AROS stuff in some far off future date with more than 4 year digits.

This commit is contained in:
Kalamatee
2025-06-05 22:57:39 +01:00
committed by deadwood
parent eebfaabac8
commit 0583195ec7

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 1995-2015, The AROS Development Team. All rights reserved. Copyright (C) 1995-2025, The AROS Development Team. All rights reserved.
*/ */
#include <stdio.h> #include <stdio.h>
@ -530,8 +530,12 @@ int i;
} }
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
date = malloc( 11 * sizeof(char) ); date = malloc( 18 * sizeof(char) );
sprintf( date, "%02d.%02d.%4d", tm->tm_mday, tm->tm_mon+1, tm->tm_year+1900 ); snprintf( date, 18 * sizeof(char),
"%02d.%02d.%4d",
tm->tm_mday & 0x1F,
(tm->tm_mon + 1) & 0xF,
(int)tm->tm_year+1900 );
fd = fopen(filename,"w"); fd = fopen(filename,"w");
if(!fd) if(!fd)
{ {