diff options
| author | mrg <mrg@NetBSD.org> | 2019-02-04 08:21:11 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2019-02-04 08:21:11 +0000 |
| commit | 6807932becefcc6f55970d7fef7616cd1f043029 (patch) | |
| tree | e70ebaea4ed30cbe6153e1a7a1879a1052ea744c /lib/libintl | |
| parent | 971ff4b359d7f6028c366fc40e6cc49ab09eb423 (diff) | |
check for snprintf() truncation and fail sanely if so, rather than
attempting to use a file that won't exist or isn't secure.
Diffstat (limited to 'lib/libintl')
| -rw-r--r-- | lib/libintl/gettext.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libintl/gettext.c b/lib/libintl/gettext.c index 71331fa2b28..868036ce90d 100644 --- a/lib/libintl/gettext.c +++ b/lib/libintl/gettext.c @@ -1,4 +1,4 @@ -/* $NetBSD: gettext.c,v 1.29 2015/05/29 12:26:28 christos Exp $ */ +/* $NetBSD: gettext.c,v 1.30 2019/02/04 08:21:11 mrg Exp $ */ /*- * Copyright (c) 2000, 2001 Citrus Project, @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: gettext.c,v 1.29 2015/05/29 12:26:28 christos Exp $"); +__RCSID("$NetBSD: gettext.c,v 1.30 2019/02/04 08:21:11 mrg Exp $"); #include <sys/param.h> #include <sys/stat.h> @@ -329,8 +329,10 @@ lookup_mofile(char *buf, size_t len, const char *dir, const char *lpath, continue; #endif - snprintf(buf, len, "%s/%s/%s/%s.mo", dir, p, + int rv = snprintf(buf, len, "%s/%s/%s/%s.mo", dir, p, category, domainname); + if (rv > (int)len) + return NULL; if (stat(buf, &st) < 0) continue; if ((st.st_mode & S_IFMT) != S_IFREG) @@ -942,7 +944,7 @@ dcngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n, int category) { const char *msgid; - char path[PATH_MAX]; + char path[PATH_MAX+1]; const char *lpath; static char olpath[PATH_MAX]; const char *cname = NULL; |
