15 Star 2 Fork 68

src-openEuler/util-linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-last-avoid-out-of-bounds-array-access.patch 737 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangyao2022 提交于 1年前 . sync community patches
From 75822efb8e948b538d9e9ccc329a5430fdabb7ea Mon Sep 17 00:00:00 2001
From: biubiuzy <294772273@qq.com>
Date: Fri, 23 Feb 2024 17:44:12 +0800
Subject: [PATCH] last: avoid out of bounds array access
---
login-utils/last.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/login-utils/last.c b/login-utils/last.c
index bbbe817f8..f5a9fec08 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -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;
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/util-linux.git
git@gitee.com:src-openeuler/util-linux.git
src-openeuler
util-linux
util-linux
openEuler-22.03-LTS

搜索帮助