allow relative pathnames as a dirname argument of bindtextdomain(3)

since some autoconf configure scripts depends on this behavior.
This commit is contained in:
yamt 2001-12-09 11:11:01 +00:00
parent 7bee75fe59
commit 0c36fb1498
2 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: gettext.c,v 1.10 2001/09/27 15:29:06 yamt Exp $ */
/* $NetBSD: gettext.c,v 1.11 2001/12/09 11:11:01 yamt Exp $ */
/*-
* Copyright (c) 2000, 2001 Citrus Project,
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: gettext.c,v 1.10 2001/09/27 15:29:06 yamt Exp $");
__RCSID("$NetBSD: gettext.c,v 1.11 2001/12/09 11:11:01 yamt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -587,6 +587,20 @@ dcngettext(domainname, msgid1, msgid2, n, category)
db = __bindings;
}
/* resolve relative path */
/* XXX not necessary? */
if (db->path[0] != '/') {
char buf[PATH_MAX];
if (getcwd(buf, sizeof(buf)) == 0)
goto fail;
if (strlcat(buf, "/", sizeof(buf)) >= sizeof(buf))
goto fail;
if (strlcat(buf, db->path, sizeof(buf)) >= sizeof(buf))
goto fail;
strcpy(db->path, buf);
}
/* don't bother looking it up if the values are the same */
if (odomainname && strcmp(domainname, odomainname) == 0 &&
ocname && strcmp(cname, ocname) == 0 && strcmp(lpath, olpath) == 0 &&

View File

@ -1,4 +1,4 @@
/* $NetBSD: textdomain.c,v 1.5 2001/02/16 07:20:35 minoura Exp $ */
/* $NetBSD: textdomain.c,v 1.6 2001/12/09 11:11:01 yamt Exp $ */
/*-
* Copyright (c) 2000, 2001 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: textdomain.c,v 1.5 2001/02/16 07:20:35 minoura Exp $");
__RCSID("$NetBSD: textdomain.c,v 1.6 2001/12/09 11:11:01 yamt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -83,9 +83,12 @@ bindtextdomain(domainname, dirname)
if (strlen(dirname) + 1 > sizeof(p->path))
return NULL;
#if 0
/* disallow relative path */
if (dirname[0] != '/')
return NULL;
#endif
if (strlen(domainname) + 1 > sizeof(p->domainname))
return NULL;