Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34606778
D397.id1225.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1 KB
Subscribers
None
D397.id1225.diff
View Options
Index: b/dirmngr/ks-engine-hkp.c
===================================================================
--- b/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -209,25 +209,24 @@
static int
select_random_host (int *table)
{
- int *tbl;
- size_t tblsize;
+ int *tbl = NULL;
+ size_t tblsize = 0;
int pidx, idx;
/* We create a new table so that we randomly select only from
currently alive hosts. */
- for (idx=0, tblsize=0; (pidx = table[idx]) != -1; idx++)
+ for (idx=0; (pidx = table[idx]) != -1; idx++)
if (hosttable[pidx] && !hosttable[pidx]->dead)
- tblsize++;
+ {
+ tblsize++;
+ tbl = xtryrealloc(tbl, tblsize * sizeof *tbl);
+ if (!tbl)
+ return -1; /* memory allocation failed! */
+ tbl[tblsize-1] = pidx;
+ }
if (!tblsize)
return -1; /* No hosts. */
- tbl = xtrymalloc (tblsize * sizeof *tbl);
- if (!tbl)
- return -1;
- for (idx=0, tblsize=0; (pidx = table[idx]) != -1; idx++)
- if (hosttable[pidx] && !hosttable[pidx]->dead)
- tbl[tblsize++] = pidx;
-
if (tblsize == 1) /* Save a get_uint_nonce. */
pidx = tbl[0];
else
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 17, 11:10 PM (13 h, 13 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
65/af/c39ee35a6e62148b8a8dc8cfab37
Attached To
D397: 909_0142-dirmngr-hkp-Avoid-potential-race-condition-when-some.patch
Event Timeline
Log In to Comment