]> granicus.if.org Git - sudo/commitdiff
Add some debugging printfs when malloc fails and we don't have an
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 14 Jul 2015 21:28:01 +0000 (15:28 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 14 Jul 2015 21:28:01 +0000 (15:28 -0600)
explicit call to sudo_warnx().

lib/util/lbuf.c
plugins/sudoers/env.c
plugins/sudoers/gram.c
plugins/sudoers/gram.y
plugins/sudoers/interfaces.c
plugins/sudoers/match.c
plugins/sudoers/pwutil_impl.c
plugins/sudoers/redblack.c
src/hooks.c
src/net_ifs.c
src/sudo.c

index 0e56ba36f1200686c988189c5450d0a88499f9f6..55ea422dc64e5e47e329dbac1413453f3620d3eb 100644 (file)
@@ -66,6 +66,8 @@ sudo_lbuf_destroy_v1(struct sudo_lbuf *lbuf)
 static bool
 sudo_lbuf_expand(struct sudo_lbuf *lbuf, int extra)
 {
+    debug_decl(sudo_lbuf_expand, SUDO_DEBUG_UTIL)
+
     if (lbuf->len + extra + 1 >= lbuf->size) {
        char *new_buf;
        int new_size = lbuf->size;
@@ -74,13 +76,15 @@ sudo_lbuf_expand(struct sudo_lbuf *lbuf, int extra)
            new_size += 256;
        } while (lbuf->len + extra + 1 >= new_size);
        if ((new_buf = realloc(lbuf->buf, new_size)) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            lbuf->error = 1;
-           return false;
+           debug_return_bool(false);
        }
        lbuf->buf = new_buf;
        lbuf->size = new_size;
     }
-    return true;
+    debug_return_bool(true);
 }
 
 /*
index 848a7e6bf3f2846f0965337dafe7a49e861980f3..4a91ac850d545c25c98ed7b82b0fe19be9946491 100644 (file)
@@ -393,8 +393,11 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite)
     debug_decl(sudo_setenv2, SUDOERS_DEBUG_ENV)
 
     esize = strlen(var) + 1 + strlen(val) + 1;
-    if ((estring = malloc(esize)) == NULL)
+    if ((estring = malloc(esize)) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_int(-1);
+    }
 
     /* Build environment string and insert it. */
     if (strlcpy(estring, var, esize) >= esize ||
@@ -851,6 +854,8 @@ rebuild_env(void)
     env.old_envp = env.envp;
     env.envp = reallocarray(NULL, env.env_size, sizeof(char *));
     if (env.envp == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        env.env_size = 0;
        goto bad;
     }
@@ -1178,6 +1183,8 @@ read_env_file(const char *path, int overwrite)
        }
 
        if ((cp = malloc(var_len + 1 + val_len + 1)) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            /* XXX - no undo on failure */
            rval = false;
            break;
@@ -1208,6 +1215,8 @@ init_envtables(void)
     for (p = initial_badenv_table; *p; p++) {
        cur = calloc(1, sizeof(struct list_member));
        if (cur == NULL || (cur->value = strdup(*p)) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            free(cur);
            debug_return_bool(false);
        }
@@ -1218,6 +1227,8 @@ init_envtables(void)
     for (p = initial_checkenv_table; *p; p++) {
        cur = calloc(1, sizeof(struct list_member));
        if (cur == NULL || (cur->value = strdup(*p)) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            free(cur);
            debug_return_bool(false);
        }
@@ -1228,6 +1239,8 @@ init_envtables(void)
     for (p = initial_keepenv_table; *p; p++) {
        cur = calloc(1, sizeof(struct list_member));
        if (cur == NULL || (cur->value = strdup(*p)) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            free(cur);
            debug_return_bool(false);
        }
index 632fbea4f6a7a4d6b31854ce4cdfabe0e2a45e4f..35bdfe1607129e679111ec141bdc8d850f0396a3 100644 (file)
@@ -740,16 +740,19 @@ new_default(char *var, char *val, int op)
     struct defaults *d;
     debug_decl(new_default, SUDOERS_DEBUG_PARSER)
 
-    d = calloc(1, sizeof(struct defaults));
-    if (d != NULL) {
-       d->var = var;
-       d->val = val;
-       /* d->type = 0; */
-       d->op = op;
-       /* d->binding = NULL */
-       HLTQ_INIT(d, entries);
+    if ((d = calloc(1, sizeof(struct defaults))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
     }
 
+    d->var = var;
+    d->val = val;
+    /* d->type = 0; */
+    d->op = op;
+    /* d->binding = NULL */
+    HLTQ_INIT(d, entries);
+
     debug_return_ptr(d);
 }
 
@@ -759,13 +762,16 @@ new_member(char *name, int type)
     struct member *m;
     debug_decl(new_member, SUDOERS_DEBUG_PARSER)
 
-    m = calloc(1, sizeof(struct member));
-    if (m != NULL) {
-       m->name = name;
-       m->type = type;
-       HLTQ_INIT(m, entries);
+    if ((m = calloc(1, sizeof(struct member))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
     }
 
+    m->name = name;
+    m->type = type;
+    HLTQ_INIT(m, entries);
+
     debug_return_ptr(m);
 }
 
@@ -775,14 +781,19 @@ new_digest(int digest_type, const char *digest_str)
     struct sudo_digest *dig;
     debug_decl(new_digest, SUDOERS_DEBUG_PARSER)
 
-    dig = malloc(sizeof(*dig));
-    if (dig != NULL) {
-       dig->digest_type = digest_type;
-       dig->digest_str = strdup(digest_str);
-       if (dig->digest_str == NULL) {
-           free(dig);
-           dig = NULL;
-       }
+    if ((dig = malloc(sizeof(*dig))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
+    }
+
+    dig->digest_type = digest_type;
+    dig->digest_str = strdup(digest_str);
+    if (dig->digest_str == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       free(dig);
+       dig = NULL;
     }
 
     debug_return_ptr(dig);
@@ -804,8 +815,11 @@ add_defaults(int type, struct member *bmem, struct defaults *defs)
        /*
         * We use a single binding for each entry in defs.
         */
-       if ((binding = malloc(sizeof(*binding))) == NULL)
+       if ((binding = malloc(sizeof(*binding))) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            debug_return_bool(false);
+       }
        if (bmem != NULL)
            HLTQ_TO_TAILQ(binding, bmem, entries);
        else
@@ -835,8 +849,11 @@ add_userspec(struct member *members, struct privilege *privs)
     struct userspec *u;
     debug_decl(add_userspec, SUDOERS_DEBUG_PARSER)
 
-    if ((u = calloc(1, sizeof(*u))) == NULL)
+    if ((u = calloc(1, sizeof(*u))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_bool(false);
+    }
     HLTQ_TO_TAILQ(&u->users, members, entries);
     HLTQ_TO_TAILQ(&u->privileges, privs, entries);
     TAILQ_INSERT_TAIL(&userspecs, u, entries);
@@ -983,7 +1000,7 @@ init_parser(const char *path, bool quiet)
 
     debug_return_bool(rval);
 }
-#line 934 "gram.c"
+#line 951 "gram.c"
 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
 #if defined(__cplusplus) || defined(__STDC__)
 static int yygrowstack(void)
@@ -2063,7 +2080,7 @@ case 113:
                            }
                        }
 break;
-#line 2014 "gram.c"
+#line 2031 "gram.c"
     }
     yyssp -= yym;
     yystate = *yyssp;
index 0b9a249f03f0c93600d07dba1703da2939b1f6ed..82604ba82a80caf98ca136725ccee546508810c1 100644 (file)
@@ -885,16 +885,19 @@ new_default(char *var, char *val, int op)
     struct defaults *d;
     debug_decl(new_default, SUDOERS_DEBUG_PARSER)
 
-    d = calloc(1, sizeof(struct defaults));
-    if (d != NULL) {
-       d->var = var;
-       d->val = val;
-       /* d->type = 0; */
-       d->op = op;
-       /* d->binding = NULL */
-       HLTQ_INIT(d, entries);
+    if ((d = calloc(1, sizeof(struct defaults))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
     }
 
+    d->var = var;
+    d->val = val;
+    /* d->type = 0; */
+    d->op = op;
+    /* d->binding = NULL */
+    HLTQ_INIT(d, entries);
+
     debug_return_ptr(d);
 }
 
@@ -904,13 +907,16 @@ new_member(char *name, int type)
     struct member *m;
     debug_decl(new_member, SUDOERS_DEBUG_PARSER)
 
-    m = calloc(1, sizeof(struct member));
-    if (m != NULL) {
-       m->name = name;
-       m->type = type;
-       HLTQ_INIT(m, entries);
+    if ((m = calloc(1, sizeof(struct member))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
     }
 
+    m->name = name;
+    m->type = type;
+    HLTQ_INIT(m, entries);
+
     debug_return_ptr(m);
 }
 
@@ -920,14 +926,19 @@ new_digest(int digest_type, const char *digest_str)
     struct sudo_digest *dig;
     debug_decl(new_digest, SUDOERS_DEBUG_PARSER)
 
-    dig = malloc(sizeof(*dig));
-    if (dig != NULL) {
-       dig->digest_type = digest_type;
-       dig->digest_str = strdup(digest_str);
-       if (dig->digest_str == NULL) {
-           free(dig);
-           dig = NULL;
-       }
+    if ((dig = malloc(sizeof(*dig))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
+    }
+
+    dig->digest_type = digest_type;
+    dig->digest_str = strdup(digest_str);
+    if (dig->digest_str == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       free(dig);
+       dig = NULL;
     }
 
     debug_return_ptr(dig);
@@ -949,8 +960,11 @@ add_defaults(int type, struct member *bmem, struct defaults *defs)
        /*
         * We use a single binding for each entry in defs.
         */
-       if ((binding = malloc(sizeof(*binding))) == NULL)
+       if ((binding = malloc(sizeof(*binding))) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            debug_return_bool(false);
+       }
        if (bmem != NULL)
            HLTQ_TO_TAILQ(binding, bmem, entries);
        else
@@ -980,8 +994,11 @@ add_userspec(struct member *members, struct privilege *privs)
     struct userspec *u;
     debug_decl(add_userspec, SUDOERS_DEBUG_PARSER)
 
-    if ((u = calloc(1, sizeof(*u))) == NULL)
+    if ((u = calloc(1, sizeof(*u))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_bool(false);
+    }
     HLTQ_TO_TAILQ(&u->users, members, entries);
     HLTQ_TO_TAILQ(&u->privileges, privs, entries);
     TAILQ_INSERT_TAIL(&userspecs, u, entries);
index 8643e3146a191a848dd657b8dfbcf8129475c661..fda41669f32e7865bc1788941ce1cdd15add9a65 100644 (file)
@@ -66,8 +66,11 @@ set_interfaces(const char *ai)
        *mask++ = '\0';
 
        /* Parse addr and store in list. */
-       if ((ifp = calloc(1, sizeof(*ifp))) == NULL)
+       if ((ifp = calloc(1, sizeof(*ifp))) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            goto done;
+       }
        if (strchr(addr, ':')) {
            /* IPv6 */
 #ifdef HAVE_STRUCT_IN6_ADDR
index 5411e38541c3a6a32faa0dddda21bc1b65c79d8c..524ab5bd172b35d334f99a931875978dde75645f 100644 (file)
@@ -932,6 +932,10 @@ sudo_getdomainname(void)
                    }
                }
            }
+       } else {
+           /* XXX - want to pass error back to caller */
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
        }
        initialized = true;
     }
index 03e61df4876416ab8d8d13f16f3ebc383e088605..f081ef5abcabc0b0dc4a0335c1b7b3465fedf41b 100644 (file)
@@ -109,8 +109,11 @@ sudo_make_pwitem(uid_t uid, const char *name)
        total += strlen(name) + 1;
 
     /* Allocate space for struct item, struct passwd and the strings. */
-    if ((pwitem = calloc(1, total)) == NULL)
+    if ((pwitem = calloc(1, total)) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_ptr(NULL);
+    }
     newpw = &pwitem->pw;
 
     /*
@@ -181,8 +184,11 @@ sudo_make_gritem(gid_t gid, const char *name)
     if (name != NULL)
        total += strlen(name) + 1;
 
-    if ((gritem = calloc(1, total)) == NULL)
+    if ((gritem = calloc(1, total)) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_ptr(NULL);
+    }
 
     /*
      * Copy in group contents and make strings relative to space
@@ -245,21 +251,30 @@ sudo_make_grlist_item(const struct passwd *pw, char * const *unused1,
        if (sudo_user.max_groups > 0) {
            ngids = sudo_user.max_groups;
            gids = reallocarray(NULL, ngids, sizeof(GETGROUPS_T));
-           if (gids == NULL)
+           if (gids == NULL) {
+               sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+                   "unable to allocate memory");
                debug_return_ptr(NULL);
+           }
            (void)getgrouplist(pw->pw_name, pw->pw_gid, gids, &ngids);
        } else {
            ngids = (int)sysconf(_SC_NGROUPS_MAX) * 2;
            if (ngids < 0)
                ngids = NGROUPS_MAX * 2;
            gids = reallocarray(NULL, ngids, sizeof(GETGROUPS_T));
-           if (gids == NULL)
+           if (gids == NULL) {
+               sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+                   "unable to allocate memory");
                debug_return_ptr(NULL);
+           }
            if (getgrouplist(pw->pw_name, pw->pw_gid, gids, &ngids) == -1) {
                free(gids);
                gids = reallocarray(NULL, ngids, sizeof(GETGROUPS_T));
-               if (gids == NULL)
+               if (gids == NULL) {
+                   sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+                       "unable to allocate memory");
                    debug_return_ptr(NULL);
+               }
                if (getgrouplist(pw->pw_name, pw->pw_gid, gids, &ngids) == -1)
                    ngids = -1;
            }
@@ -286,6 +301,8 @@ sudo_make_grlist_item(const struct passwd *pw, char * const *unused1,
 
 again:
     if ((grlitem = calloc(1, total)) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        free(gids);
        debug_return_ptr(NULL);
     }
index a12085701c220e859c17b3b6972998862769eff5..793f980fe3276e490bf2d7896c67eab6b8408456 100644 (file)
@@ -84,26 +84,30 @@ rbcreate(int (*compar)(const void *, const void*))
     struct rbtree *tree;
     debug_decl(rbcreate, SUDOERS_DEBUG_RBTREE)
 
-    if ((tree = malloc(sizeof(*tree))) != NULL) {
-       tree->compar = compar;
-
-       /*
-        * We use a self-referencing sentinel node called nil to simplify the
-        * code by avoiding the need to check for NULL pointers.
-        */
-       tree->nil.left = tree->nil.right = tree->nil.parent = &tree->nil;
-       tree->nil.color = black;
-       tree->nil.data = NULL;
-
-       /*
-        * Similarly, the fake root node keeps us from having to worry
-        * about splitting the root.
-        */
-       tree->root.left = tree->root.right = tree->root.parent = &tree->nil;
-       tree->root.color = black;
-       tree->root.data = NULL;
+    if ((tree = malloc(sizeof(*tree))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
+       debug_return_ptr(NULL);
     }
 
+    tree->compar = compar;
+
+    /*
+     * We use a self-referencing sentinel node called nil to simplify the
+     * code by avoiding the need to check for NULL pointers.
+     */
+    tree->nil.left = tree->nil.right = tree->nil.parent = &tree->nil;
+    tree->nil.color = black;
+    tree->nil.data = NULL;
+
+    /*
+     * Similarly, the fake root node keeps us from having to worry
+     * about splitting the root.
+     */
+    tree->root.left = tree->root.right = tree->root.parent = &tree->nil;
+    tree->root.color = black;
+    tree->root.data = NULL;
+
     debug_return_ptr(tree);
 }
 
@@ -184,8 +188,11 @@ rbinsert(struct rbtree *tree, void *data, struct rbnode **existing)
     }
 
     node = malloc(sizeof(*node));
-    if (node == NULL)
+    if (node == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_int(-1);
+    }
     node->data = data;
     node->left = node->right = rbnil(tree);
     node->parent = parent;
index ae918b3140cf3d4af2d076f50f4f53e3baaeb9aa..6c867094cc0ef8a0b875237cb8f0ba24c2a207fc 100644 (file)
@@ -131,8 +131,11 @@ register_hook_internal(struct sudo_hook_list *head,
     struct sudo_hook_entry *hook;
     debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS)
 
-    if ((hook = calloc(1, sizeof(*hook))) == NULL)
+    if ((hook = calloc(1, sizeof(*hook))) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_int(-1);
+    }
     hook->u.generic_fn = hook_fn;
     hook->closure = closure;
     SLIST_INSERT_HEAD(head, hook, entries);
index 3f9fe6db2b26c8d9228ea624a1142acc14f6604f..f186d41aff4dc95410bc9711c7bd6d9d518cf74e 100644 (file)
@@ -144,8 +144,11 @@ get_net_ifs(char **addrinfo)
     if (num_interfaces == 0)
        debug_return_int(0);
     ailen = num_interfaces * 2 * INET6_ADDRSTRLEN;
-    if ((cp = malloc(ailen)) == NULL)
+    if ((cp = malloc(ailen)) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        debug_return_int(-1);
+    }
     *addrinfo = cp;
 
     /* Store the IP addr/netmask pairs. */
@@ -236,6 +239,8 @@ get_net_ifs(char **addrinfo)
      */
     for (;;) {
        if ((ifconf_buf = malloc(buflen)) == NULL) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+               "unable to allocate memory");
            num_interfaces = -1;
            goto done;
        }
@@ -264,6 +269,8 @@ get_net_ifs(char **addrinfo)
        goto done;
     ailen = n * 2 * INET6_ADDRSTRLEN;
     if ((cp = malloc(ailen)) == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        num_interfaces = -1;
        goto done;
     }
index 9a80c2df2b6607192104a88dcb2c7519b7837742..0c695df04c81ad56b4c25b009231de8be8b40c8a 100644 (file)
@@ -458,8 +458,11 @@ get_user_info(struct user_details *ud)
 
     /* XXX - bound check number of entries */
     user_info = reallocarray(NULL, 32, sizeof(char *));
-    if (user_info == NULL)
+    if (user_info == NULL) {
+       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+           "unable to allocate memory");
        goto bad;
+    }
 
     ud->pid = getpid();
     ud->ppid = getppid();
@@ -753,7 +756,7 @@ command_info_to_details(char * const info[], struct command_details *details)
 #endif
     details->pw = getpwuid(details->euid);
     if (details->pw != NULL && (details->pw = pw_dup(details->pw)) == NULL)
-       sudo_fatal(NULL);
+       sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
 #ifdef HAVE_SETAUTHDB
     aix_restoreauthdb();
 #endif
@@ -1135,15 +1138,15 @@ format_plugin_settings(struct plugin_container *plugin,
     plugin_settings = ps =
        reallocarray(NULL, plugin_settings_size, sizeof(char *));
     if (plugin_settings == NULL)
-       sudo_fatal(NULL);
+       sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
     if ((*ps++ = sudo_new_key_val("plugin_path", plugin->path)) == NULL)
-       sudo_fatal(NULL);
+       sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
     for (setting = sudo_settings; setting->name != NULL; setting++) {
         if (setting->value != NULL) {
             sudo_debug_printf(SUDO_DEBUG_INFO, "settings: %s=%s",
                 setting->name, setting->value);
            if ((*ps++ = sudo_new_key_val(setting->name, setting->value)) == NULL)
-                sudo_fatal(NULL);
+               sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
         }
     }
     if (plugin->debug_files != NULL) {
@@ -1151,7 +1154,7 @@ format_plugin_settings(struct plugin_container *plugin,
            /* XXX - quote filename? */
            if (asprintf(ps++, "debug_flags=%s %s", debug_file->debug_file,
                debug_file->debug_flags) == -1)
-               sudo_fatal(NULL);
+               sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
        }
     }
     *ps = NULL;