]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/glibc/glibc-rh788959.patch
lcdproc: Update to 0.5.7
[ipfire-2.x.git] / src / patches / glibc / glibc-rh788959.patch
1 diff -pruN glibc-2.12-2-gc4ccff1/nis/nss_compat/compat-initgroups.c glibc-2.12-2-gc4ccff1.patched/nis/nss_compat/compat-initgroups.c
2 --- glibc-2.12-2-gc4ccff1/nis/nss_compat/compat-initgroups.c 2010-05-04 16:57:23.000000000 +0530
3 +++ glibc-2.12-2-gc4ccff1.patched/nis/nss_compat/compat-initgroups.c 2012-02-21 11:11:19.877008465 +0530
4 @@ -297,6 +297,8 @@ getgrent_next_nss (ent_t *ent, char *buf
5 if (nss_initgroups_dyn (user, group, &mystart, &mysize, &mygroups,
6 limit, errnop) == NSS_STATUS_SUCCESS)
7 {
8 + status = NSS_STATUS_NOTFOUND;
9 +
10 /* If there is no blacklist we can trust the underlying
11 initgroups implementation. */
12 if (ent->blacklist.current <= 1)
13 @@ -309,6 +311,7 @@ getgrent_next_nss (ent_t *ent, char *buf
14 overwrite the pointer with one to a bigger buffer. */
15 char *tmpbuf = buffer;
16 size_t tmplen = buflen;
17 + bool use_malloc = false;
18
19 for (int i = 0; i < mystart; i++)
20 {
21 @@ -316,21 +319,36 @@ getgrent_next_nss (ent_t *ent, char *buf
22 tmpbuf, tmplen, errnop))
23 == NSS_STATUS_TRYAGAIN
24 && *errnop == ERANGE)
25 - if (tmpbuf == buffer)
26 - {
27 - tmplen *= 2;
28 - tmpbuf = __alloca (tmplen);
29 - }
30 - else
31 - tmpbuf = extend_alloca (tmpbuf, tmplen, 2 * tmplen);
32 + {
33 + if (__libc_use_alloca (tmplen * 2))
34 + {
35 + if (tmpbuf == buffer)
36 + {
37 + tmplen *= 2;
38 + tmpbuf = __alloca (tmplen);
39 + }
40 + else
41 + tmpbuf = extend_alloca (tmpbuf, tmplen, tmplen * 2);
42 + }
43 + else
44 + {
45 + tmplen *= 2;
46 + char *newbuf = realloc (use_malloc ? tmpbuf : NULL, tmplen);
47 +
48 + if (newbuf == NULL)
49 + {
50 + status = NSS_STATUS_TRYAGAIN;
51 + goto done;
52 + }
53 + use_malloc = true;
54 + tmpbuf = newbuf;
55 + }
56 + }
57
58 if (__builtin_expect (status != NSS_STATUS_NOTFOUND, 1))
59 {
60 if (__builtin_expect (status != NSS_STATUS_SUCCESS, 0))
61 - {
62 - free (mygroups);
63 - return status;
64 - }
65 + goto done;
66
67 if (!in_blacklist (grpbuf.gr_name,
68 strlen (grpbuf.gr_name), ent)
69 @@ -348,11 +366,17 @@ getgrent_next_nss (ent_t *ent, char *buf
70 }
71 }
72 }
73 +
74 + status = NSS_STATUS_NOTFOUND;
75 +
76 + done:
77 + if (use_malloc)
78 + free (tmpbuf);
79 }
80
81 free (mygroups);
82
83 - return NSS_STATUS_NOTFOUND;
84 + return status;
85 }
86
87 free (mygroups);
88 @@ -506,6 +530,7 @@ _nss_compat_initgroups_dyn (const char *
89 char *tmpbuf;
90 enum nss_status status;
91 ent_t intern = { true, false, false, NULL, {NULL, 0, 0} };
92 + bool use_malloc = false;
93
94 status = internal_setgrent (&intern);
95 if (status != NSS_STATUS_SUCCESS)
96 @@ -519,13 +544,32 @@ _nss_compat_initgroups_dyn (const char *
97 user, group, start, size,
98 groupsp, limit, errnop))
99 == NSS_STATUS_TRYAGAIN && *errnop == ERANGE)
100 - tmpbuf = extend_alloca (tmpbuf, buflen, 2 * buflen);
101 + if (__libc_use_alloca (buflen * 2))
102 + tmpbuf = extend_alloca (tmpbuf, buflen, 2 * buflen);
103 + else
104 + {
105 + buflen *= 2;
106 + char *newbuf = realloc (use_malloc ? tmpbuf : NULL, buflen);
107 + if (newbuf == NULL)
108 + {
109 + status = NSS_STATUS_TRYAGAIN;
110 + goto done;
111 + }
112 + use_malloc = true;
113 + tmpbuf = newbuf;
114 + }
115 }
116 while (status == NSS_STATUS_SUCCESS);
117
118 + status = NSS_STATUS_SUCCESS;
119 +
120 + done:
121 + if (use_malloc)
122 + free (tmpbuf);
123 +
124 internal_endgrent (&intern);
125
126 - return NSS_STATUS_SUCCESS;
127 + return status;
128 }
129
130