In wget 1.7 and 1.6, if the WGETRC environment variable is set but the file
specified is inaccessible, the message:

wget: (null): No such file or directory.

is displayed and the program exits with status 1.

Debugging traces the problem to the following function in init.c (ca. line
261)

/* Return the path to the user's .wgetrc.  This is either the value of
   `WGETRC' environment variable, or `$HOME/.wgetrc'.

   If the `WGETRC' variable exists but the file does not exist, the
   function will exit().  */
static char *
wgetrc_file_name (void)
{
  char *env, *home;
  char *file = NULL;

  /* Try the environment.  */
  env = getenv ("WGETRC");
  if (env && *env)
    {
      if (!file_exists_p (env))
        {
          fprintf (stderr, "%s: %s: %s.\n", exec_name, file, strerror
(errno));
          exit (1);
        }
      return xstrdup (env);
    }
....

where the error message is printed

Firstly, file is a null pointer at the time that this error message is
printed; env is the correct pointer to use here.  Secondly, there is no
explanation of why the program is looking for this file.

A possible fix is as follows:

278c278
<         fprintf (stderr, "%s: Unable to access WGETRC specified in
environment: %s: %s.\n", exec_name, env, strerror (errno));
---
>         fprintf (stderr, "%s: %s: %s.\n", exec_name, file, strerror
(errno));

the resultant output is now (when WGETRC is set to c:\.wgetrc, and this file
doesn't exist):

wget: Unable to access WGETRC specified in environment: c:\.wgetrc: No such
file
 or directory.

Note:  debugging and patching was done with version 1.6 source.  I have
upgraded my executable to 1.7 and the bug still exists, but I haven't
obtained the source code to see if there are any changes in this function
between ver 1.6 and 1.7.

Warm Regards,
Chris

Reply via email to