[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Wget-dev] wget2 | WIP: Add c-ares support for quickly fill DNS cach

From: Tim Rühsen
Subject: Re: [Wget-dev] wget2 | WIP: Add c-ares support for quickly fill DNS cache in background (!444)
Date: Mon, 26 Aug 2019 09:28:10 +0000

Tim Rühsen started a new discussion on async_dns/async_dns.c: 

> +static int MAXWAITING; // Max. number of parallel DNS queries
> +static int MAXTRIES; // Max. number of tries per domain
> +static int TIMEOUT; // Max. number of ms for first try
> +
> +static int nwaiting;
> +
> +static int resolved;
> +static int failed;
> +
> +// create fname & set first row (needed for further processing with R)
> +static void prepare_file(const char *fname)
> +{
> +     struct stat st;
> +     FILE *fp;
> +
> +     if ((stat(fname, &st) || !st.st_size) && (fp = fopen(fname, "a"))) {

This is a typical TOCTOU issue (see 

Try to avoid, e.g. first `fopen(fname, "a")` and then check with ftell(fp) if 
you are a position 0 (=empty file) or not.

Reply to this email directly or view it on GitLab: 
You're receiving this email because of your account on gitlab.com.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]