mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-18 00:36:49 -04:00
Fix the code that allowed DNS options to not end with :
We tried to fix this in 0.2.0.3-alpha, but our fix was buggy.
This commit is contained in:
parent
d0939d2b97
commit
ee4953f89e
12
evdns.c
12
evdns.c
@ -3130,8 +3130,11 @@ strtotimeval(const char *const str, struct timeval *out)
|
||||
char *endptr;
|
||||
d = strtod(str, &endptr);
|
||||
if (*endptr) return -1;
|
||||
if (d < 0) return -1;
|
||||
out->tv_sec = (int) d;
|
||||
out->tv_usec = (int) ((d - (int) d)*1000000);
|
||||
if (out->tv_sec == 0 && out->tv_usec < 1000) /* less than 1 msec */
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3200,10 +3203,13 @@ str_matches_option(const char *s1, const char *optionname)
|
||||
* s1, or 'option:randomjunk'. The latter form is to implement the
|
||||
* resolv.conf parser. */
|
||||
size_t optlen = strlen(optionname);
|
||||
if (strlen(s1) == optlen)
|
||||
return !strncmp(s1, optionname, optlen-1);
|
||||
else
|
||||
size_t slen = strlen(s1);
|
||||
if (slen == optlen || slen == optlen - 1)
|
||||
return !strncmp(s1, optionname, slen);
|
||||
else if (slen > optlen)
|
||||
return !strncmp(s1, optionname, optlen);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user