1 Star 1 Fork 28

wojibayang/attr

forked from src-openEuler/attr 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-getfattr-don-t-count-terminating-NULL-in-well_enough.patch 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
liuzhiqiang 提交于 2020-07-12 18:27 +08:00 . attr: backport upsteam bugfix patches
From e4c006f07f050e0af08602d0064c3420080b7313 Mon Sep 17 00:00:00 2001
From: Jeff Layton <jlayton@kernel.org>
Date: Thu, 13 Jun 2019 10:55:35 -0400
Subject: [PATCH 4/7] getfattr: don't count terminating NULL in
well_enough_printable
If the value is a string with the terminating NUL included in the
length, then don't count that terminating NUL when determining whether
the string is printable. This is consistent with the fact that getfattr
doesn't print the terminating NUL character in --encoding=text (commit
7fed4441e12d).
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
tools/getfattr.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/getfattr.c b/tools/getfattr.c
index 72a8852..0ba5781 100644
--- a/tools/getfattr.c
+++ b/tools/getfattr.c
@@ -110,6 +110,10 @@ int well_enough_printable(const char *value, size_t size)
{
size_t n, nonpr = 0;
+ /* Don't count the NULL terminator if there is one */
+ if (size && !value[size - 1])
+ size--;
+
for (n=0; n < size; n++)
if (!isprint(*value++))
nonpr++;
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wojibayang/attr.git
git@gitee.com:wojibayang/attr.git
wojibayang
attr
attr
master

搜索帮助

371d5123 14472233 46e8bd33 14472233