From 0583195ec79f6221495af66143754b6cca1b1249 Mon Sep 17 00:00:00 2001 From: Kalamatee Date: Thu, 5 Jun 2025 22:57:39 +0100 Subject: [PATCH] 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. --- tools/archtools/archtool.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/archtools/archtool.c b/tools/archtools/archtool.c index f172c3119a..d47f563fba 100644 --- a/tools/archtools/archtool.c +++ b/tools/archtools/archtool.c @@ -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 @@ -530,8 +530,12 @@ int i; } time(&t); tm = localtime(&t); - date = malloc( 11 * sizeof(char) ); - sprintf( date, "%02d.%02d.%4d", tm->tm_mday, tm->tm_mon+1, tm->tm_year+1900 ); + date = malloc( 18 * sizeof(char) ); + 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"); if(!fd) {