#! /bin/sh /usr/share/dpatch/dpatch-run ## wget-no-path_max.dpatch by ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Not all OSes define PATH_MAX. Allocate memory dynamically @DPATCH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' wget-1.12~/src/init.c wget-1.12/src/init.c --- wget-1.12~/src/init.c 2009-09-22 04:02:41.000000000 +0100 +++ wget-1.12/src/init.c 2010-09-04 23:08:48.790703947 +0100 @@ -351,8 +351,9 @@ char * home_dir (void) { - static char buf[PATH_MAX]; - static char *home; + static char *buf = NULL; + static char *home, *ret; + int len; if (!home) { @@ -365,12 +366,21 @@ const char *_w32_get_argv0 (void); /* in libwatt.a/pcconfig.c */ char *p; - strcpy (buf, _w32_get_argv0 ()); + buff = _w32_get_argv0 (); + p = strrchr (buf, '/'); /* djgpp */ if (!p) p = strrchr (buf, '\\'); /* others */ assert (p); - *p = '\0'; + + len = p - buff + 1; + buff = malloc (len + 1); + if (buff == NULL) + return NULL; + + strncpy (buff, _w32_get_argv0 (), len); + buff[len] = '\0'; + home = buf; #elif !defined(WINDOWS) /* If HOME is not defined, try getting it from the password @@ -378,8 +388,7 @@ struct passwd *pwd = getpwuid (getuid ()); if (!pwd || !pwd->pw_dir) return NULL; - strcpy (buf, pwd->pw_dir); - home = buf; + home = pwd->pw_dir; #else /* !WINDOWS */ /* Under Windows, if $HOME isn't defined, use the directory where `wget.exe' resides. */ @@ -388,7 +397,11 @@ } } - return home ? xstrdup (home) : NULL; + ret = home ? xstrdup (home) : NULL; + if (buf) + free (buf); + + return ret; } /* Check the 'WGETRC' environment variable and return the file name