]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Handle catopen() errors
authorMichał Kępień <michal@isc.org>
Mon, 13 Jan 2020 13:03:11 +0000 (14:03 +0100)
committerMichał Kępień <michal@isc.org>
Mon, 13 Jan 2020 13:03:11 +0000 (14:03 +0100)
musl libc's implementation of catgets() crashes when its first argument
is -1 instead of a proper message catalog descriptor.  Prevent that from
happening by making isc_msgcat_get() return the default text if the
prior call to catopen() returns an error.

lib/isc/nls/msgcat.c

index ab09b9457942ff359af6cdc5babbac53d13e53a0..dd3d177fb3968c2f16e18ac8dca226f5ed8667a4 100644 (file)
@@ -62,9 +62,8 @@ isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp) {
 
 #ifdef HAVE_CATGETS
        /*
-        * We don't check if catopen() fails because we don't care.
-        * If it does fail, then when we call catgets(), it will use
-        * the default string.
+        * We don't check if catopen() fails because isc_msgcat_get() takes
+        * care of that before calling catgets().
         */
        msgcat->catalog = catopen(name, 0);
 #endif
@@ -112,8 +111,9 @@ isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message,
        REQUIRE(default_text != NULL);
 
 #ifdef HAVE_CATGETS
-       if (msgcat == NULL)
+       if (msgcat == NULL || msgcat->catalog == (nl_catd)(-1)) {
                return (default_text);
+       }
        return (catgets(msgcat->catalog, set, message, default_text));
 #else
        return (default_text);