14 Star 0 Fork 12

src-openEuler/ypserv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ypserv-2.31-netgrprecur.patch 2.27 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 11:20 . Package init
Upstream didn't accepted this patch and only replied that user should fix
the configuration. Since we believe that even if configuration is wrong,
program (especially daemon) shouldn't crash with segfault, we rather fix
this on our own to print a nice error when level of recursion exceeds 128.
diff -up ypserv-2.31/revnetgroup/getnetgrent.c.recursive ypserv-2.31/revnetgroup/getnetgrent.c
--- ypserv-2.31/revnetgroup/getnetgrent.c.recursive 2013-05-17 12:37:08.143675080 +0200
+++ ypserv-2.31/revnetgroup/getnetgrent.c 2013-05-17 14:20:49.376566354 +0200
@@ -31,6 +31,8 @@
#include "hash.h"
+#define NETGROUPENTRY_RECURSION_LIMIT 128
+
extern hash_t *input;
void rev_setnetgrent (const char *);
@@ -53,7 +55,7 @@ struct netgrlist
};
-static void rev_expand_netgroupentry (const char *, struct netgrlist *);
+static void rev_expand_netgroupentry (const char *, struct netgrlist *, int level);
static void rev_parse_entry (char *, char *, struct netgrlist *);
static void rev_netgr_free (struct netgrlist *);
static struct netgrlist list = {0, 0, NULL};
@@ -83,7 +85,7 @@ rev_setnetgrent (const char *netgr)
{
rev_endnetgrent ();
netgroup = strdup (netgr);
- rev_expand_netgroupentry (netgr, &list);
+ rev_expand_netgroupentry (netgr, &list, 0);
}
first = 1;
}
@@ -141,7 +143,7 @@ rev_netgr_free (struct netgrlist *list)
}
static void
-rev_expand_netgroupentry (const char *netgr, struct netgrlist *list)
+rev_expand_netgroupentry (const char *netgr, struct netgrlist *list, int level)
{
char *outval = NULL;
char *outptr = NULL;
@@ -156,6 +158,14 @@ rev_expand_netgroupentry (const char *ne
if (outptr == NULL)
return;
+ /* check the recursion - return if we exceed the recursion limit */
+ if (level >= NETGROUPENTRY_RECURSION_LIMIT)
+ {
+ fprintf (stderr, "WARNING: level of recursion in netgroup %s reached"
+ "%d, entry ignored\n", netgr, NETGROUPENTRY_RECURSION_LIMIT);
+ return;
+ }
+
/* make a copy to work with */
outval = strdup (outptr);
if (outval == NULL)
@@ -198,7 +208,7 @@ rev_expand_netgroupentry (const char *ne
*end = '\0';
/* recursion */
- rev_expand_netgroupentry (start, list);
+ rev_expand_netgroupentry (start, list, level+1);
}
/* skip to the next entry */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/ypserv.git
[email protected]:src-openeuler/ypserv.git
src-openeuler
ypserv
ypserv
master

搜索帮助