diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-08-09 23:02:12 -0700 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:28 +0200 |
commit | bde3d8b141ff42c1f6828e5ed1467b691e54b253 (patch) | |
tree | 888ea4b977950dd12aa143132e52b3c055e188d9 /nx-X11/lib | |
parent | 7bca34528c6e693ce086cd8ddc92ede467448767 (diff) | |
download | nx-libs-bde3d8b141ff42c1f6828e5ed1467b691e54b253.tar.gz nx-libs-bde3d8b141ff42c1f6828e5ed1467b691e54b253.tar.bz2 nx-libs-bde3d8b141ff42c1f6828e5ed1467b691e54b253.zip |
lcfile: skip over any null entries in args list
Previous code seemed to assume that printf("%s", NULL) would result
in a 0-length string, not "(null)" or similar, but since there's no
point looking for files in "(null)/filepath...", instead we just
skip over NULL entries in search paths when generating file names.
In the *DirName() functions, this effectively just moves the "bail on
NULL in arg[i]" check up from the later code that assigned it to targetdir
and then bailed if that was NULL.
Not sure how there ever could be a NULL in arg[i], given the current
implementation of XlcParsePath, but it's easy enough to check once and
reject up front instead of on every reference.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib')
-rw-r--r-- | nx-X11/lib/X11/lcFile.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/nx-X11/lib/X11/lcFile.c b/nx-X11/lib/X11/lcFile.c index aeaae245d..3b239ff2f 100644 --- a/nx-X11/lib/X11/lcFile.c +++ b/nx-X11/lib/X11/lcFile.c @@ -486,8 +486,11 @@ _XlcFileName( for (i = 0; i < n; ++i) { char buf[PATH_MAX], *name; + if (args[i] == NULL) + continue; + name = NULL; - if ((5 + (args[i] ? strlen (args[i]) : 0) + strlen(cat)) < PATH_MAX) { + if ((5 + strlen(args[i]) + strlen(cat)) < PATH_MAX) { sprintf(buf, "%s/%s.dir", args[i], cat); name = resolve_name(siname, buf, RtoL); } @@ -498,7 +501,7 @@ _XlcFileName( /* supposed to be absolute path name */ file_name = name; } else { - file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) + + file_name = Xmalloc(2 + strlen(args[i]) + (name ? strlen (name) : 0)); if (file_name != NULL) sprintf(file_name, "%s/%s", args[i], name); @@ -535,8 +538,10 @@ _XlcResolveLocaleName( xlocaledir (dir, PATH_MAX); n = _XlcParsePath(dir, args, NUM_LOCALEDIR); for (i = 0; i < n; ++i) { - if ((2 + (args[i] ? strlen (args[i]) : 0) + - strlen (locale_alias)) < PATH_MAX) { + if (args[i] == NULL) + continue; + + if ((2 + strlen (args[i]) + strlen (locale_alias)) < PATH_MAX) { sprintf (buf, "%s/%s", args[i], locale_alias); name = resolve_name (lc_name, buf, LtoR); if (!name) { @@ -633,9 +638,10 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name) xlocaledir (dir, PATH_MAX); n = _XlcParsePath(dir, args, 256); for (i = 0; i < n; ++i) { + if (args[i] == NULL) + continue; - if ((2 + (args[i] ? strlen(args[i]) : 0) + - strlen(locale_alias)) < PATH_MAX) { + if ((2 + strlen(args[i]) + strlen(locale_alias)) < PATH_MAX) { sprintf (buf, "%s/%s", args[i], locale_alias); name = resolve_name(lc_name, buf, LtoR); if (!name) { @@ -653,12 +659,6 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name) /* look at locale.dir */ target_dir = args[i]; - if (!target_dir) { - /* something wrong */ - if (name != lc_name) - Xfree(name); - continue; - } if ((1 + strlen (target_dir) + strlen("locale.dir")) < PATH_MAX) { sprintf(buf, "%s/locale.dir", target_dir); target_name = resolve_name(name, buf, RtoL); @@ -731,9 +731,10 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name) xlocalelibdir (dir, PATH_MAX); n = _XlcParsePath(dir, args, 256); for (i = 0; i < n; ++i) { + if (args[i] == NULL) + continue; - if ((2 + (args[i] ? strlen(args[i]) : 0) + - strlen(locale_alias)) < PATH_MAX) { + if ((2 + strlen(args[i]) + strlen(locale_alias)) < PATH_MAX) { sprintf (buf, "%s/%s", args[i], locale_alias); name = resolve_name(lc_name, buf, LtoR); if (!name) { @@ -751,12 +752,6 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name) /* look at locale.dir */ target_dir = args[i]; - if (!target_dir) { - /* something wrong */ - if (name != lc_name) - Xfree(name); - continue; - } if ((1 + strlen (target_dir) + strlen("locale.dir")) < PATH_MAX) { sprintf(buf, "%s/locale.dir", target_dir); target_name = resolve_name(name, buf, RtoL); |