From be8f8a9f4caa883e3de98b276cdad55d4fc65c0d Mon Sep 17 00:00:00 2001 From: Thorsten Töpper Date: Mon, 16 Jun 2025 20:20:20 +0200 Subject: CMakeLists: hardening flags --- src/output.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/output.c') diff --git a/src/output.c b/src/output.c index 9dd274b..be0afb1 100644 --- a/src/output.c +++ b/src/output.c @@ -63,7 +63,7 @@ void print_list(struct list_head *list) { ptr = lh->first; while (ptr != NULL) { - printf(" %8lu %2s ", ((ptr->fsize>=1024) ? (ptr->fsize/1024) : ptr->fsize), + printf(" %8ld %2s ", ((ptr->fsize>=1024) ? (ptr->fsize/1024) : ptr->fsize), ((ptr->fsize >= 1024) ? "kB" : "")); tm = localtime(&ptr->ftime); @@ -75,7 +75,9 @@ void print_list(struct list_head *list) { printf(" %8s ", timestamp); } printf(" %s\n", ptr->fname); - total_size += ptr->fsize; + /* Linux: Neither man stat(2) nor stat(3type) declare when struct stat field st_size + * get's a negative value. */ + total_size += (ptr->fsize>0) ? (unsigned long int)ptr->fsize : 0; ptr = ptr->next; } fputc_all_cols('=', stdout); -- cgit v1.2.3-70-g09d2