/[packages]/cauldron/ypserv/pristine/SOURCES/ypserv-2.31-netgrprecur.patch
ViewVC logotype

Contents of /cauldron/ypserv/pristine/SOURCES/ypserv-2.31-netgrprecur.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1649366 - (show annotations) (download)
Wed Nov 25 21:58:07 2020 UTC (3 years, 4 months ago) by tv
Original Path: cauldron/ypserv/current/SOURCES/ypserv-2.31-netgrprecur.patch
File size: 2320 byte(s)
4.1 which builds with tirpc/glibc-2.32
1 Upstream didn't accepted this patch and only replied that user should fix
2 the configuration. Since we believe that even if configuration is wrong,
3 program (especially daemon) shouldn't crash with segfault, we rather fix
4 this on our own to print a nice error when level of recursion exceeds 128.
5
6 diff -up ypserv-2.31/revnetgroup/getnetgrent.c.recursive ypserv-2.31/revnetgroup/getnetgrent.c
7 --- ypserv-2.31/revnetgroup/getnetgrent.c.recursive 2013-05-17 12:37:08.143675080 +0200
8 +++ ypserv-2.31/revnetgroup/getnetgrent.c 2013-05-17 14:20:49.376566354 +0200
9 @@ -31,6 +31,8 @@
10
11 #include "hash.h"
12
13 +#define NETGROUPENTRY_RECURSION_LIMIT 128
14 +
15 extern hash_t *input;
16
17 void rev_setnetgrent (const char *);
18 @@ -53,7 +55,7 @@ struct netgrlist
19 };
20
21
22 -static void rev_expand_netgroupentry (const char *, struct netgrlist *);
23 +static void rev_expand_netgroupentry (const char *, struct netgrlist *, int level);
24 static void rev_parse_entry (char *, char *, struct netgrlist *);
25 static void rev_netgr_free (struct netgrlist *);
26 static struct netgrlist list = {0, 0, NULL};
27 @@ -83,7 +85,7 @@ rev_setnetgrent (const char *netgr)
28 {
29 rev_endnetgrent ();
30 netgroup = strdup (netgr);
31 - rev_expand_netgroupentry (netgr, &list);
32 + rev_expand_netgroupentry (netgr, &list, 0);
33 }
34 first = 1;
35 }
36 @@ -141,7 +143,7 @@ rev_netgr_free (struct netgrlist *list)
37 }
38
39 static void
40 -rev_expand_netgroupentry (const char *netgr, struct netgrlist *list)
41 +rev_expand_netgroupentry (const char *netgr, struct netgrlist *list, int level)
42 {
43 char *outval = NULL;
44 char *outptr = NULL;
45 @@ -156,6 +158,14 @@ rev_expand_netgroupentry (const char *ne
46 if (outptr == NULL)
47 return;
48
49 + /* check the recursion - return if we exceed the recursion limit */
50 + if (level >= NETGROUPENTRY_RECURSION_LIMIT)
51 + {
52 + fprintf (stderr, "WARNING: level of recursion in netgroup %s reached"
53 + "%d, entry ignored\n", netgr, NETGROUPENTRY_RECURSION_LIMIT);
54 + return;
55 + }
56 +
57 /* make a copy to work with */
58 outval = strdup (outptr);
59 if (outval == NULL)
60 @@ -198,7 +208,7 @@ rev_expand_netgroupentry (const char *ne
61 *end = '\0';
62
63 /* recursion */
64 - rev_expand_netgroupentry (start, list);
65 + rev_expand_netgroupentry (start, list, level+1);
66 }
67
68 /* skip to the next entry */

  ViewVC Help
Powered by ViewVC 1.1.30