* resolv/res_mkquery.c (res_nmkquery): Set hp->id to statp->id after

randomization rather than before.
	* resolv/res_init.c (res_randomid): Don't call gettimeofday here.
This commit is contained in:
Ulrich Drepper 2006-09-04 18:00:58 +00:00
parent b80770b23f
commit 03eeff8389
3 changed files with 11 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2006-09-04 Jakub Jelinek <jakub@redhat.com>
* resolv/res_mkquery.c (res_nmkquery): Set hp->id to statp->id after
randomization rather than before.
* resolv/res_init.c (res_randomid): Don't call gettimeofday here.
2006-08-31 Jakub Jelinek <jakub@redhat.com> 2006-08-31 Jakub Jelinek <jakub@redhat.com>
* dlfcn/Makefile (LDLIBS-bug-atexit3-lib.so): Add * dlfcn/Makefile (LDLIBS-bug-atexit3-lib.so): Add

View File

@ -537,10 +537,7 @@ net_mask(in) /* XXX - should really use system's version of this */
u_int u_int
res_randomid(void) { res_randomid(void) {
struct timeval now; return 0xffff & __getpid();
__gettimeofday(&now, NULL);
return (0xffff & (now.tv_sec ^ now.tv_usec ^ __getpid()));
} }
#ifdef _LIBC #ifdef _LIBC
libc_hidden_def (__res_randomid) libc_hidden_def (__res_randomid)

View File

@ -124,24 +124,20 @@ res_nmkquery(res_state statp,
incremented by one after the initial randomization which incremented by one after the initial randomization which
still predictable if the application does multiple still predictable if the application does multiple
requests. */ requests. */
#if 0
hp->id = htons(++statp->id);
#else
hp->id = htons(statp->id);
int randombits; int randombits;
do do
{ {
# ifdef RANDOM_BITS #ifdef RANDOM_BITS
RANDOM_BITS (randombits); RANDOM_BITS (randombits);
# else #else
struct timeval tv; struct timeval tv;
__gettimeofday (&tv, NULL); __gettimeofday (&tv, NULL);
randombits = (tv.tv_sec << 8) ^ tv.tv_usec; randombits = (tv.tv_sec << 8) ^ tv.tv_usec;
# endif #endif
} }
while ((randombits & 0xffff) == 0); while ((randombits & 0xffff) == 0);
statp->id = (statp->id + randombits) & 0xffff; statp->id = (statp->id + randombits) & 0xffff;
#endif hp->id = statp->id;
hp->opcode = op; hp->opcode = op;
hp->rd = (statp->options & RES_RECURSE) != 0; hp->rd = (statp->options & RES_RECURSE) != 0;
hp->rcode = NOERROR; hp->rcode = NOERROR;