1 Star 0 Fork 26

严莹/cpio

forked from src-openEuler/cpio 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
cpio-2.10-patternnamesigsegv.patch 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
Linux_zhang 提交于 2023-07-17 11:57 . update to 2.14
From: =?UTF-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <ovasik@redhat.com>
Date: Mon, 14 Sep 2015 09:47:05 +0200
Subject: [PATCH 5/7] fix segfault with nonexisting file with patternnames
(#567022)
diff --git a/src/copyin.c b/src/copyin.c
index 5d88a23..f2babb7 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -948,21 +948,24 @@ read_pattern_file (void)
pattern_fp = fopen (pattern_file_name, "r");
if (pattern_fp == NULL)
- open_fatal (pattern_file_name);
- while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
+ open_error (pattern_file_name);
+ else
+ {
+ while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
{
if (new_num_patterns == max_new_patterns)
- new_save_patterns = x2nrealloc (new_save_patterns,
+ new_save_patterns = x2nrealloc (new_save_patterns,
&max_new_patterns,
sizeof (new_save_patterns[0]));
new_save_patterns[new_num_patterns] = xstrdup (pattern_name.ds_string);
++new_num_patterns;
}
- ds_free (&pattern_name);
+ ds_free (&pattern_name);
- if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
- close_error (pattern_file_name);
+ if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
+ close_error (pattern_file_name);
+ }
for (i = 0; i < num_patterns; ++i)
new_save_patterns[i] = save_patterns[i];
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yanyir/cpio.git
git@gitee.com:yanyir/cpio.git
yanyir
cpio
cpio
master

搜索帮助