mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-07 19:31:01 -04:00
Make a couple of newer evdns functions more bulletproof.
svn:r1112
This commit is contained in:
parent
da49d6a3b0
commit
f04b90e5b3
15
evdns.c
15
evdns.c
@ -1127,14 +1127,11 @@ static void
|
||||
default_random_bytes_fn(char *buf, size_t n)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < n-1; i += 2) {
|
||||
for (i = 0; i < n; i += 2) {
|
||||
u16 tid = trans_id_function();
|
||||
buf[i] = (tid >> 8) & 0xff;
|
||||
buf[i+1] = tid & 0xff;
|
||||
}
|
||||
if (i < n) {
|
||||
u16 tid = trans_id_function();
|
||||
buf[i] = tid & 0xff;
|
||||
if (i+1<n)
|
||||
buf[i+1] = tid & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2380,6 +2377,12 @@ request_new(struct evdns_base *base, int type, const char *name, int flags,
|
||||
(void) flags;
|
||||
|
||||
if (!req) return NULL;
|
||||
|
||||
if (name_len >= sizeof(namebuf)) {
|
||||
free(req);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(req, 0, sizeof(struct evdns_request));
|
||||
req->base = base;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user