Correctly handle failure in getting build or install dates

Message ID 20220721095151.490686-1-allan@archlinux.org
State Accepted, archived
Headers show
Series Correctly handle failure in getting build or install dates | expand

Commit Message

Allan McRae July 21, 2022, 9:51 a.m. UTC
alpm_pkg_get_builddate() and alpm_pkg_get_installdate() both return -1 on
error. Correctly handle the error condition in pacman.

Signed-off-by: Allan McRae <allan@archlinux.org>
---
 src/pacman/package.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/src/pacman/package.c b/src/pacman/package.c
index f2b6fa19..4fcc11f2 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -210,11 +210,11 @@  void dump_pkg_full(alpm_pkg_t *pkg, int extra)
 
 	/* set variables here, do all output below */
 	bdate = (time_t)alpm_pkg_get_builddate(pkg);
-	if(bdate) {
+	if(bdate != -1) {
 		strftime(bdatestr, 50, "%c", localtime(&bdate));
 	}
 	idate = (time_t)alpm_pkg_get_installdate(pkg);
-	if(idate) {
+	if(idate != -1) {
 		strftime(idatestr, 50, "%c", localtime(&idate));
 	}