mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
resolv: Introduce struct resolv_conf with extended resolver state
This change provides additional resolver configuration state which is not exposed through the _res ABI. It reuses the existing initstamp field in the supposedly-private part of _res. Some effort is undertaken to avoid memory safety issues introduced by applications which directly patch the _res object. With this commit, only the initstamp field is moved into struct resolv_conf. Additional members will be added later, eventually migrating the entire resolver configuration.
This commit is contained in:
@ -102,6 +102,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <inet/net-internal.h>
|
||||
#include <errno.h>
|
||||
#include <resolv_conf.h>
|
||||
|
||||
static void res_setoptions (res_state, const char *);
|
||||
static uint32_t net_mask (struct in_addr);
|
||||
@ -137,7 +138,6 @@ res_vinit_1 (res_state statp, bool preinit, FILE *fp, char **buffer)
|
||||
bool havesearch = false;
|
||||
int nsort = 0;
|
||||
char *net;
|
||||
statp->_u._ext.initstamp = __res_initstamp;
|
||||
|
||||
if (!preinit)
|
||||
{
|
||||
@ -457,6 +457,19 @@ __res_vinit (res_state statp, int preinit)
|
||||
bool ok = res_vinit_1 (statp, preinit, fp, &buffer);
|
||||
free (buffer);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
struct resolv_conf init = { 0 }; /* No data yet. */
|
||||
struct resolv_conf *conf = __resolv_conf_allocate (&init);
|
||||
if (conf == NULL)
|
||||
ok = false;
|
||||
else
|
||||
{
|
||||
ok = __resolv_conf_attach (statp, conf);
|
||||
__resolv_conf_put (conf);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
/* Deallocate the name server addresses which have been
|
||||
|
Reference in New Issue
Block a user