1 Star 0 Fork 22

MerlinDust/coreutils_1

forked from src-anolis-os/coreutils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
coreutils-tac-handle-short-reads-on-input.patch 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
alpha_wang 提交于 2024-05-16 11:11 . tac: handle short reads on input
From 1ed5aa2254505fbf971c6db6810130227f552eec Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Thu, 16 May 2024 10:57:26 +0800
Subject: [PATCH] tac: handle short reads on input
This can be reproduced by getting the read() above 2G,
which induces a short read, thus triggering the erroneous failure.
$ truncate -s 5G 5G
$ cat 5G | TMPDIR=$PWD tac | wc -c
tac: /tmp/tacFt7txA: read error: Illegal seek
0
With the fix in place we now get:
$ cat 5G | TMPDIR=$PWD src/tac | wc -c
5368709120
---
NEWS | 5 +++++
src/tac.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 4a09ab4..39d1024 100644
--- a/NEWS
+++ b/NEWS
@@ -207,6 +207,11 @@ GNU coreutils NEWS -*- outline -*-
non regular files are specified, as inotify is ineffective with these.
[bug introduced with inotify support added in coreutils-7.5]
+ tac now handles short reads on its input. Previously it may have exited
+ erroneously, especially with large input files with no separators.
+ [This bug was present in "the beginning".]
+
+
uptime no longer outputs the AM/PM component of the current time,
as that's inconsistent with the 24 hour time format used.
[bug introduced in coreutils-7.0]
diff --git a/src/tac.c b/src/tac.c
index 753f8f1..1186d94 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -46,6 +46,7 @@ tac -r -s '.\|
#include "die.h"
#include "error.h"
#include "filenamecat.h"
+#include "full-read.h"
#include "safe-read.h"
#include "stdlib--.h"
#include "xbinary-io.h"
@@ -352,7 +353,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
else
match_start = past_end;
- if (safe_read (input_fd, G_buffer, read_size) != read_size)
+ if (full_read (input_fd, G_buffer, read_size) != read_size)
{
error (0, errno, _("%s: read error"), quotef (file));
return false;
--
2.39.3
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/DustMerlin/coreutils_1.git
git@gitee.com:DustMerlin/coreutils_1.git
DustMerlin
coreutils_1
coreutils_1
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385