logo

utils-std

Collection of commonly available Unix tools
commit: e7c1d18807f1d4385096b7d81968928860263a2c
parent 205067e912f1257ab0694176d20f64888a3acfd8
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 26 Jul 2024 10:26:39 +0200

cmd/touch: Handle mktime errors

Diffstat:

Mcmd/touch.c5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/cmd/touch.c b/cmd/touch.c @@ -174,6 +174,11 @@ main(int argc, char *argv[]) target.tv_sec = mktime_tz(&iso_res); target.tv_nsec = nsec; + if(target.tv_sec == (time_t)-1) + { + fprintf(stderr, "date: mktime: %s\n", strerror(errno)); + exit(EXIT_FAILURE); + } errno = 0; break; }