2000-09-25  Ulrich Drepper  <drepper@redhat.com>

	* iconv/gconv_conf.c (__gconv_get_path): Fix problem with relative
	GCONV_PATH.
This commit is contained in:
Ulrich Drepper 2000-09-25 07:05:31 +00:00
parent 655de5fdf2
commit 40739d9f8c
2 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2000-09-25 Ulrich Drepper <drepper@redhat.com>
* iconv/gconv_conf.c (__gconv_get_path): Fix problem with relative
GCONV_PATH.
2000-09-24 Ulrich Drepper <drepper@redhat.com> 2000-09-24 Ulrich Drepper <drepper@redhat.com>
* libio/genops.c (_IO_doallocbuf): Don't use single byte buffer if * libio/genops.c (_IO_doallocbuf): Don't use single byte buffer if

View File

@ -417,6 +417,8 @@ __gconv_get_path (void)
char *oldp; char *oldp;
char *cp; char *cp;
int nelems; int nelems;
char *cwd;
size_t cwdlen;
user_path = __secure_getenv ("GCONV_PATH"); user_path = __secure_getenv ("GCONV_PATH");
if (user_path == NULL) if (user_path == NULL)
@ -425,6 +427,8 @@ __gconv_get_path (void)
default path. */ default path. */
gconv_path = strdupa (default_gconv_path); gconv_path = strdupa (default_gconv_path);
gconv_path_len = sizeof (default_gconv_path); gconv_path_len = sizeof (default_gconv_path);
cwd = NULL;
cwdlen = 0;
} }
else else
{ {
@ -436,6 +440,8 @@ __gconv_get_path (void)
__mempcpy (__mempcpy (__mempcpy (gconv_path, user_path, user_len), __mempcpy (__mempcpy (__mempcpy (gconv_path, user_path, user_len),
":", 1), ":", 1),
default_gconv_path, sizeof (default_gconv_path)); default_gconv_path, sizeof (default_gconv_path));
cwd = __getcwd (NULL, 0);
cwdlen = strlen (cwd);
} }
/* In a first pass we calculate the number of elements. */ /* In a first pass we calculate the number of elements. */
@ -453,7 +459,8 @@ __gconv_get_path (void)
/* Allocate the memory for the result. */ /* Allocate the memory for the result. */
result = (struct path_elem *) malloc ((nelems + 1) result = (struct path_elem *) malloc ((nelems + 1)
* sizeof (struct path_elem) * sizeof (struct path_elem)
+ gconv_path_len + nelems); + gconv_path_len + nelems
+ (nelems - 1) * (cwdlen + 1));
if (result != NULL) if (result != NULL)
{ {
char *strspace = (char *) &result[nelems + 1]; char *strspace = (char *) &result[nelems + 1];
@ -466,6 +473,12 @@ __gconv_get_path (void)
do do
{ {
result[n].name = strspace; result[n].name = strspace;
if (elem[0] != '/')
{
assert (cwd != NULL);
strspace = __mempcpy (strspace, cwd, cwdlen);
*strspace++ = '/';
}
strspace = __stpcpy (strspace, elem); strspace = __stpcpy (strspace, elem);
if (strspace[-1] != '/') if (strspace[-1] != '/')
*strspace++ = '/'; *strspace++ = '/';
@ -484,6 +497,9 @@ __gconv_get_path (void)
} }
__gconv_path_elem = result ?: &empty_path_elem; __gconv_path_elem = result ?: &empty_path_elem;
if (cwd != NULL)
free (cwd);
} }
__libc_lock_unlock (lock); __libc_lock_unlock (lock);