aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dns-stuff.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-10-28 09:14:07 +0000
committerWerner Koch <[email protected]>2015-10-28 09:14:30 +0000
commit949a5cfdabcafab93c1ac092c0459b59318805b9 (patch)
treec8d254844a6392b527fba9e2a94f2cbef754d727 /dirmngr/dns-stuff.c
parentdirmngr: Add a getaddrinfo wrapper backend using ADNS. (diff)
downloadgnupg-949a5cfdabcafab93c1ac092c0459b59318805b9.tar.gz
gnupg-949a5cfdabcafab93c1ac092c0459b59318805b9.zip
dirmngr: Minor cleanup of the SRV RR code.
* dirmngr/dns-stuff.c: Include unistd.h. (getsrv): Run srand only once. * dirmngr/t-dns-stuff.c (main): Allow passing another name for --srv and change output format.
Diffstat (limited to 'dirmngr/dns-stuff.c')
-rw-r--r--dirmngr/dns-stuff.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index 3689d8fdd..3220d7659 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -42,6 +42,7 @@
# include <netdb.h>
#endif
#include <string.h>
+#include <unistd.h>
#ifdef USE_ADNS
# include <adns.h>
#endif
@@ -1103,9 +1104,16 @@ getsrv (const char *name,struct srventry **list)
/* Run the RFC-2782 weighting algorithm. We don't need very high
quality randomness for this, so regular libc srand/rand is
- sufficient. Fixme: It is a bit questionaly to reinitalize srand
- - better use a gnupg fucntion for this. */
- srand(time(NULL)*getpid());
+ sufficient. */
+
+ {
+ static int done;
+ if (!done)
+ {
+ done = 1;
+ srand (time (NULL)*getpid());
+ }
+ }
for (i=0; i < srvcount; i++)
{