]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: avoid out of bounds array access
authorbiubiuzy <294772273@qq.com>
Fri, 23 Feb 2024 09:44:12 +0000 (17:44 +0800)
committerKarel Zak <kzak@redhat.com>
Wed, 20 Mar 2024 13:04:44 +0000 (14:04 +0100)
login-utils/last.c

index bbbe817f8a99f1f543832d22e7fef168007d1f4a..f5a9fec0804c8b9bc435dd097f17d45688e6f379 100644 (file)
@@ -351,7 +351,10 @@ static int time_formatter(int fmt, char *dst, size_t dlen, time_t *when)
        {
                char buf[CTIME_BUFSIZ];
 
-               ctime_r(when, buf);
+               if (!ctime_r(when, buf)) {
+                       ret = -1;
+                       break;
+               }
                snprintf(dst, dlen, "%s", buf);
                ret = rtrim_whitespace((unsigned char *) dst);
                break;