]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh788959-2.patch
Merge remote-tracking branch 'erik/sendEmail' into core67-merge
[people/teissler/ipfire-2.x.git] / src / patches / glibc / glibc-rh788959-2.patch
1 diff -rcp a/nscd/grpcache.c b/nscd/grpcache.c
2 *** a/nscd/grpcache.c Wed Apr 11 12:50:07 2012
3 --- b/nscd/grpcache.c Wed Apr 11 21:45:58 2012
4 *************** cache_addgr (struct database_dyn *db, in
5 *** 178,184 ****
6 char *cp;
7 const size_t key_len = strlen (key);
8 const size_t buf_len = 3 * sizeof (grp->gr_gid) + key_len + 1;
9 ! char *buf = alloca (buf_len);
10 ssize_t n;
11 size_t cnt;
12
13 --- 178,185 ----
14 char *cp;
15 const size_t key_len = strlen (key);
16 const size_t buf_len = 3 * sizeof (grp->gr_gid) + key_len + 1;
17 ! size_t alloca_used = 0;
18 ! char *buf = alloca_account (buf_len, alloca_used);
19 ssize_t n;
20 size_t cnt;
21
22 *************** cache_addgr (struct database_dyn *db, in
23 *** 190,196 ****
24 /* Determine the length of all members. */
25 while (grp->gr_mem[gr_mem_cnt])
26 ++gr_mem_cnt;
27 ! gr_mem_len = (uint32_t *) alloca (gr_mem_cnt * sizeof (uint32_t));
28 for (gr_mem_cnt = 0; grp->gr_mem[gr_mem_cnt]; ++gr_mem_cnt)
29 {
30 gr_mem_len[gr_mem_cnt] = strlen (grp->gr_mem[gr_mem_cnt]) + 1;
31 --- 191,198 ----
32 /* Determine the length of all members. */
33 while (grp->gr_mem[gr_mem_cnt])
34 ++gr_mem_cnt;
35 ! gr_mem_len = (uint32_t *) alloca_account (gr_mem_cnt * sizeof (uint32_t),
36 ! alloca_used);
37 for (gr_mem_cnt = 0; grp->gr_mem[gr_mem_cnt]; ++gr_mem_cnt)
38 {
39 gr_mem_len[gr_mem_cnt] = strlen (grp->gr_mem[gr_mem_cnt]) + 1;
40 *************** cache_addgr (struct database_dyn *db, in
41 *** 205,214 ****
42 change. Allocate memory on the cache since it is likely
43 discarded anyway. If it turns out to be necessary to have a
44 new record we can still allocate real memory. */
45 ! bool alloca_used = false;
46 dataset = NULL;
47
48 ! if (he == NULL)
49 dataset = (struct dataset *) mempool_alloc (db, total + n, 1);
50
51 if (dataset == NULL)
52 --- 207,216 ----
53 change. Allocate memory on the cache since it is likely
54 discarded anyway. If it turns out to be necessary to have a
55 new record we can still allocate real memory. */
56 ! bool dataset_in_stack_or_freed = false;
57 dataset = NULL;
58
59 ! if (he == NULL || ! __libc_use_alloca (alloca_used + total + n))
60 dataset = (struct dataset *) mempool_alloc (db, total + n, 1);
61
62 if (dataset == NULL)
63 *************** cache_addgr (struct database_dyn *db, in
64 *** 216,225 ****
65 /* We cannot permanently add the result in the moment. But
66 we can provide the result as is. Store the data in some
67 temporary memory. */
68 ! dataset = (struct dataset *) alloca (total + n);
69
70 /* We cannot add this record to the permanent database. */
71 ! alloca_used = true;
72 }
73
74 dataset->head.allocsize = total + n;
75 --- 218,227 ----
76 /* We cannot permanently add the result in the moment. But
77 we can provide the result as is. Store the data in some
78 temporary memory. */
79 ! dataset = (struct dataset *) alloca_account (total + n, alloca_used);
80
81 /* We cannot add this record to the permanent database. */
82 ! dataset_in_stack_or_freed = true;
83 }
84
85 dataset->head.allocsize = total + n;
86 *************** cache_addgr (struct database_dyn *db, in
87 *** 273,278 ****
88 --- 275,288 ----
89 allocated on the stack and need not be freed. */
90 dh->timeout = dataset->head.timeout;
91 ++dh->nreloads;
92 +
93 + /* If the new record was not allocated on the stack, then it must
94 + be freed. Note that it can no longer be used. */
95 + if (! dataset_in_stack_or_freed)
96 + {
97 + free (dataset);
98 + dataset_in_stack_or_freed = true;
99 + }
100 }
101 else
102 {
103 *************** cache_addgr (struct database_dyn *db, in
104 *** 288,294 ****
105 key_copy = (char *) newp + (key_copy - (char *) dataset);
106
107 dataset = memcpy (newp, dataset, total + n);
108 ! alloca_used = false;
109 }
110
111 /* Mark the old record as obsolete. */
112 --- 298,304 ----
113 key_copy = (char *) newp + (key_copy - (char *) dataset);
114
115 dataset = memcpy (newp, dataset, total + n);
116 ! dataset_in_stack_or_freed = false;
117 }
118
119 /* Mark the old record as obsolete. */
120 *************** cache_addgr (struct database_dyn *db, in
121 *** 303,309 ****
122 assert (fd != -1);
123
124 #ifdef HAVE_SENDFILE
125 ! if (__builtin_expect (db->mmap_used, 1) && !alloca_used)
126 {
127 assert (db->wr_fd != -1);
128 assert ((char *) &dataset->resp > (char *) db->data);
129 --- 313,319 ----
130 assert (fd != -1);
131
132 #ifdef HAVE_SENDFILE
133 ! if (__builtin_expect (db->mmap_used, 1) && !dataset_in_stack_or_freed)
134 {
135 assert (db->wr_fd != -1);
136 assert ((char *) &dataset->resp > (char *) db->data);
137 *************** cache_addgr (struct database_dyn *db, in
138 *** 330,336 ****
139
140 /* Add the record to the database. But only if it has not been
141 stored on the stack. */
142 ! if (! alloca_used)
143 {
144 /* If necessary, we also propagate the data to disk. */
145 if (db->persistent)
146 --- 340,346 ----
147
148 /* Add the record to the database. But only if it has not been
149 stored on the stack. */
150 ! if (! dataset_in_stack_or_freed)
151 {
152 /* If necessary, we also propagate the data to disk. */
153 if (db->persistent)