Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libintl -in bindtextdomain(), don't crash if a NULL dirn...
details: https://anonhg.NetBSD.org/src/rev/8f6f1b100a71
branches: trunk
changeset: 545464:8f6f1b100a71
user: drochner <drochner%NetBSD.org@localhost>
date: Wed Apr 09 14:11:33 2003 +0000
description:
-in bindtextdomain(), don't crash if a NULL dirname is passed - return the
current path setting in this case (or default)
-fix return value
-don't copy a string to itself
diffstat:
lib/libintl/textdomain.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diffs (59 lines):
diff -r a696177a9090 -r 8f6f1b100a71 lib/libintl/textdomain.c
--- a/lib/libintl/textdomain.c Wed Apr 09 12:57:13 2003 +0000
+++ b/lib/libintl/textdomain.c Wed Apr 09 14:11:33 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: textdomain.c,v 1.7 2003/03/09 01:02:35 lukem Exp $ */
+/* $NetBSD: textdomain.c,v 1.8 2003/04/09 14:11:33 drochner Exp $ */
/*-
* Copyright (c) 2000, 2001 Citrus Project,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: textdomain.c,v 1.7 2003/03/09 01:02:35 lukem Exp $");
+__RCSID("$NetBSD: textdomain.c,v 1.8 2003/04/09 14:11:33 drochner Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -79,7 +79,7 @@
if (!domainname || !*domainname)
return NULL;
- if (strlen(dirname) + 1 > sizeof(p->path))
+ if (dirname && (strlen(dirname) + 1 > sizeof(p->path)))
return NULL;
#if 0
@@ -95,21 +95,28 @@
for (p = __bindings; p; p = p->next)
if (strcmp(p->domainname, domainname) == 0)
break;
+
+ if (!dirname) {
+ if (p)
+ return (p->path);
+ else
+ return _PATH_TEXTDOMAIN;
+ }
+
if (!p) {
p = (struct domainbinding *)malloc(sizeof(*p));
if (!p)
return NULL;
memset(p, 0, sizeof(*p));
p->next = __bindings;
+ strlcpy(p->domainname, domainname, sizeof(p->domainname));
__bindings = p;
}
strlcpy(p->path, dirname, sizeof(p->path));
- strlcpy(p->domainname, domainname, sizeof(p->domainname));
p->mohandle.mo.mo_magic = 0; /* invalidate current mapping */
- /* LINTED const cast */
- return (char *)domainname;
+ return (p->path);
}
/* ARGSUSED */
Home |
Main Index |
Thread Index |
Old Index