mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 18:08:23 +00:00
Add function name to "unable to allocate memory" warnings.
This commit is contained in:
parent
dc883f2454
commit
c36415417f
@ -202,7 +202,7 @@ aix_prep_user_v1(char *user, const char *tty)
|
||||
len = asprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",
|
||||
user, '\0', user, '\0', user, '\0', tty ? tty : "", '\0');
|
||||
if (len == -1) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
(void)usrinfo(SETUINFO, info, len);
|
||||
|
@ -62,7 +62,7 @@ sudo_parse_gids_v1(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp
|
||||
if (ngids != 0) {
|
||||
gids = reallocarray(NULL, ngids, sizeof(GETGROUPS_T));
|
||||
if (gids == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
ngids = 0;
|
||||
|
@ -185,7 +185,7 @@ parse_path(const char *entry, const char *conf_file, unsigned int lineno)
|
||||
if (namelen == cur->pnamelen &&
|
||||
strncasecmp(name, cur->pname, cur->pnamelen) == 0) {
|
||||
if ((cur->pval = strdup(path)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
break;
|
||||
}
|
||||
@ -265,7 +265,7 @@ parse_debug(const char *entry, const char *conf_file, unsigned int lineno)
|
||||
|
||||
debug_return_int(true);
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
if (debug_file != NULL) {
|
||||
free(debug_file->debug_file);
|
||||
free(debug_file->debug_flags);
|
||||
@ -342,7 +342,7 @@ parse_plugin(const char *entry, const char *conf_file, unsigned int lineno)
|
||||
|
||||
debug_return_int(true);
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
if (options != NULL) {
|
||||
while (nopts--)
|
||||
free(options[nopts]);
|
||||
@ -541,7 +541,7 @@ sudo_conf_read_v1(const char *conf_file, int conf_types)
|
||||
|
||||
prev_locale = strdup(setlocale(LC_ALL, NULL));
|
||||
if (prev_locale == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ converse(int num_msg, PAM_CONST struct pam_message **msg,
|
||||
goto done;
|
||||
}
|
||||
if ((pr->resp = strdup(pass)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
ret = PAM_BUF_ERR;
|
||||
goto done;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ sudo_rfc1938_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
|
||||
if (np_size < op_len + challenge_len + 7) {
|
||||
char *p = realloc(new_prompt, op_len + challenge_len + 7);
|
||||
if (p == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(AUTH_FATAL);
|
||||
}
|
||||
np_size = op_len + challenge_len + 7;
|
||||
|
@ -516,7 +516,7 @@ init_defaults(void)
|
||||
|
||||
debug_return_bool(true);
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
|
||||
@ -720,7 +720,7 @@ store_str(char *val, struct sudo_defs_types *def, int op)
|
||||
def->sd_un.str = NULL;
|
||||
} else {
|
||||
if ((def->sd_un.str = strdup(val)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
}
|
||||
@ -880,7 +880,7 @@ list_op(char *val, size_t len, struct sudo_defs_types *def, enum list_ops op)
|
||||
if (op == add) {
|
||||
cur = calloc(1, sizeof(struct list_member));
|
||||
if (cur == NULL || (cur->value = strndup(val, len)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
free(cur);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files,
|
||||
debug_return_str(NULL);
|
||||
editor = strndup(cp, (size_t)(ep - cp));
|
||||
if (editor == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_str(NULL);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files,
|
||||
nargc += nfiles + 1;
|
||||
nargv = reallocarray(NULL, nargc + 1, sizeof(char *));
|
||||
if (nargv == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
free(editor);
|
||||
debug_return_str(NULL);
|
||||
}
|
||||
@ -92,7 +92,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files,
|
||||
for (nargc = 1; (cp = sudo_strsplit(NULL, edend, " \t", &ep)) != NULL; nargc++) {
|
||||
nargv[nargc] = strndup(cp, (size_t)(ep - cp));
|
||||
if (nargv[nargc] == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
while (nargc--)
|
||||
free(nargv[nargc]);
|
||||
debug_return_str(NULL);
|
||||
|
@ -233,7 +233,7 @@ env_init(char * const envp[])
|
||||
if (env.envp == NULL) {
|
||||
env.env_size = 0;
|
||||
env.env_len = 0;
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
#ifdef ENV_DEBUG
|
||||
|
@ -964,14 +964,14 @@ init_parser(const char *path, bool quiet)
|
||||
init_lexer();
|
||||
|
||||
if (!init_aliases()) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = false;
|
||||
}
|
||||
|
||||
free(sudoers);
|
||||
if (path != NULL) {
|
||||
if ((sudoers = strdup(path)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = false;
|
||||
}
|
||||
} else {
|
||||
|
@ -1109,14 +1109,14 @@ init_parser(const char *path, bool quiet)
|
||||
init_lexer();
|
||||
|
||||
if (!init_aliases()) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = false;
|
||||
}
|
||||
|
||||
free(sudoers);
|
||||
if (path != NULL) {
|
||||
if ((sudoers = strdup(path)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = false;
|
||||
}
|
||||
} else {
|
||||
|
@ -131,7 +131,7 @@ group_plugin_load(char *plugin_info)
|
||||
if (ac != 0) {
|
||||
argv = reallocarray(NULL, ac, sizeof(char *));
|
||||
if (argv == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
ac = 0;
|
||||
|
@ -582,7 +582,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
|
||||
bindtextdomain("sudoers", LOCALEDIR);
|
||||
|
||||
if (sudo_setpwent() == -1 || sudo_setgrent() == -1) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
|
||||
/* Get next session ID and convert it into a path. */
|
||||
tofree = malloc(sizeof(_PATH_SUDO_IO_LOGDIR) + sizeof(sessid) + 2);
|
||||
if (tofree == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
memcpy(tofree, _PATH_SUDO_IO_LOGDIR, sizeof(_PATH_SUDO_IO_LOGDIR));
|
||||
|
@ -165,7 +165,7 @@ expand_iolog_path(const char *prefix, const char *dir, const char *file,
|
||||
prelen = strlen(prefix);
|
||||
dst = path = malloc(prelen + PATH_MAX);
|
||||
if (path == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto bad;
|
||||
}
|
||||
*path = '\0';
|
||||
|
@ -445,7 +445,7 @@ sudo_ldap_conf_add_ports(void)
|
||||
|
||||
free(ldap_conf.host);
|
||||
if ((ldap_conf.host = strdup(hostbuf)) == NULL)
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(ldap_conf.host != NULL);
|
||||
|
||||
overflow:
|
||||
@ -476,7 +476,7 @@ sudo_ldap_parse_uri(const struct ldap_config_str_list *uri_list)
|
||||
|
||||
buf = strdup(entry->val);
|
||||
if (buf == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
for ((uri = strtok_r(buf, " \t", &last)); uri != NULL; (uri = strtok_r(NULL, " \t", &last))) {
|
||||
@ -528,7 +528,7 @@ sudo_ldap_parse_uri(const struct ldap_config_str_list *uri_list)
|
||||
/* Store parsed URI(s) in host for ldap_create() or ldap_init(). */
|
||||
free(ldap_conf.host);
|
||||
if ((ldap_conf.host = strdup(hostbuf)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -561,7 +561,7 @@ sudo_ldap_join_uri(struct ldap_config_str_list *uri_list)
|
||||
len += strlen(uri->val) + 1;
|
||||
}
|
||||
if (len == 0 || (buf = malloc(len)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
} else {
|
||||
char *cp = buf;
|
||||
|
||||
@ -913,7 +913,7 @@ sudo_ldap_extract_digest(char **cmnd, struct sudo_digest *digest)
|
||||
digest->digest_type = digest_type;
|
||||
digest->digest_str = strndup(cp, (size_t)(ep - cp));
|
||||
if (digest->digest_str == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
cp = ep + 1;
|
||||
@ -1059,7 +1059,7 @@ sudo_ldap_parse_options(LDAP *ld, LDAPMessage *entry)
|
||||
/* walk through options */
|
||||
for (p = bv; *p != NULL; p++) {
|
||||
if ((var = strdup((*p)->bv_val)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
DPRINTF2("ldap sudoOption: '%s'", var);
|
||||
@ -1338,7 +1338,7 @@ sudo_netgroup_lookup_nested(LDAP *ld, char *base, struct timeval *timeout,
|
||||
|
||||
debug_return_bool(true);
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
if (result)
|
||||
ldap_msgfree(result);
|
||||
debug_return_bool(false);
|
||||
@ -1511,7 +1511,7 @@ sudo_netgroup_lookup(LDAP *ld, struct passwd *pw,
|
||||
}
|
||||
debug_return_bool(true);
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
ldap_msgfree(result);
|
||||
debug_return_bool(false);
|
||||
overflow:
|
||||
@ -1587,7 +1587,7 @@ sudo_ldap_build_pass1(LDAP *ld, struct passwd *pw)
|
||||
if (ldap_conf.timed)
|
||||
sz += TIMEFILTER_LENGTH;
|
||||
if ((buf = malloc(sz)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_str(NULL);
|
||||
}
|
||||
*buf = '\0';
|
||||
@ -1723,7 +1723,7 @@ sudo_ldap_build_pass2(void)
|
||||
(ldap_conf.timed || ldap_conf.search_filter) ? ")" : "");
|
||||
}
|
||||
if (len == -1)
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
debug_return_str(filt);
|
||||
}
|
||||
@ -1747,7 +1747,7 @@ sudo_ldap_decode_secret(const char *secret)
|
||||
reslen = ((strlen(secret) + 3) / 4 * 3);
|
||||
result = malloc(reslen + 1);
|
||||
if (result == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
} else {
|
||||
len = base64_decode(secret, result, reslen);
|
||||
if (len == (size_t)-1) {
|
||||
@ -1777,7 +1777,7 @@ sudo_ldap_read_secret(const char *path)
|
||||
ldap_conf.bindpw = sudo_ldap_decode_secret(buf);
|
||||
if (ldap_conf.bindpw == NULL) {
|
||||
if ((ldap_conf.bindpw = strdup(buf)) == NULL)
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
free(ldap_conf.binddn);
|
||||
ldap_conf.binddn = ldap_conf.rootbinddn;
|
||||
@ -1830,7 +1830,7 @@ sudo_ldap_parse_keyword(const char *keyword, const char *value,
|
||||
|
||||
free(*(char **)(cur->valp));
|
||||
if (*value && (cp = strdup(value)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
*(char **)(cur->valp) = cp;
|
||||
@ -1845,7 +1845,7 @@ sudo_ldap_parse_keyword(const char *keyword, const char *value,
|
||||
if (len > 0) {
|
||||
head = (struct ldap_config_str_list *)cur->valp;
|
||||
if ((str = malloc(sizeof(*str) + len)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
memcpy(str->val, value, len + 1);
|
||||
@ -1941,7 +1941,7 @@ sudo_ldap_read_config(void)
|
||||
STAILQ_INIT(&ldap_conf.netgroup_base);
|
||||
|
||||
if (ldap_conf.search_filter == NULL || ldap_conf.netgroup_search_filter == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
|
||||
@ -1974,7 +1974,7 @@ sudo_ldap_read_config(void)
|
||||
if (!ldap_conf.host) {
|
||||
ldap_conf.host = strdup("localhost");
|
||||
if (ldap_conf.host == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
@ -2127,7 +2127,7 @@ sudo_ldap_read_config(void)
|
||||
cp = ldap_conf.search_filter;
|
||||
ldap_conf.search_filter = malloc(len + 3);
|
||||
if (ldap_conf.search_filter == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
ldap_conf.search_filter[0] = '(';
|
||||
@ -2224,7 +2224,7 @@ sudo_ldap_display_defaults(struct sudo_nss *nss, struct passwd *pw,
|
||||
|
||||
filt = sudo_ldap_build_default_filter();
|
||||
if (filt == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
STAILQ_FOREACH(base, &ldap_conf.base, entries) {
|
||||
@ -3021,7 +3021,7 @@ sudo_ldap_open(struct sudo_nss *nss)
|
||||
/* Create a handle container. */
|
||||
handle = calloc(1, sizeof(struct sudo_ldap_handle));
|
||||
if (handle == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rc = -1;
|
||||
goto done;
|
||||
}
|
||||
@ -3054,7 +3054,7 @@ sudo_ldap_setdefs(struct sudo_nss *nss)
|
||||
|
||||
filt = sudo_ldap_build_default_filter();
|
||||
if (filt == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
DPRINTF1("Looking for cn=defaults: %s", filt);
|
||||
@ -3367,7 +3367,7 @@ sudo_ldap_result_get(struct sudo_nss *nss, struct passwd *pw)
|
||||
*/
|
||||
lres = sudo_ldap_result_alloc();
|
||||
if (lres == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
@ -3395,7 +3395,7 @@ sudo_ldap_result_get(struct sudo_nss *nss, struct passwd *pw)
|
||||
/* Add the seach result to list of search results. */
|
||||
DPRINTF1("adding search result");
|
||||
if (sudo_ldap_result_add_search(lres, ld, result) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
free(filt);
|
||||
sudo_ldap_result_free(lres);
|
||||
debug_return_ptr(NULL);
|
||||
@ -3406,7 +3406,7 @@ sudo_ldap_result_get(struct sudo_nss *nss, struct passwd *pw)
|
||||
sudo_ldap_check_host(ld, entry)) {
|
||||
lres->host_matches = true;
|
||||
if (sudo_ldap_result_add_entry(lres, entry) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
free(filt);
|
||||
sudo_ldap_result_free(lres);
|
||||
debug_return_ptr(NULL);
|
||||
@ -3494,7 +3494,7 @@ sudo_ldap_result_from_search(LDAP *ldap, LDAPMessage *searchresult)
|
||||
*/
|
||||
result = sudo_ldap_result_alloc();
|
||||
if (result == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
|
||||
@ -3510,7 +3510,7 @@ sudo_ldap_result_from_search(LDAP *ldap, LDAPMessage *searchresult)
|
||||
*/
|
||||
LDAP_FOREACH(entry, last->ldap, last->searchresult) {
|
||||
if (sudo_ldap_result_add_entry(result, entry) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sudo_ldap_result_free(result);
|
||||
result = NULL;
|
||||
break;
|
||||
|
@ -74,7 +74,7 @@ linux_audit_command(char *argv[], int result)
|
||||
size += strlen(*av) + 1;
|
||||
command = cp = malloc(size);
|
||||
if (command == NULL) {
|
||||
sudo_warn(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
for (av = argv; *av != NULL; av++) {
|
||||
|
@ -188,7 +188,7 @@ do_logfile(const char *msg)
|
||||
if (!ferror(fp))
|
||||
rval = true;
|
||||
} else {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
(void) fclose(fp);
|
||||
}
|
||||
@ -912,7 +912,7 @@ new_logline(const char *message, int serrno)
|
||||
debug_return_str(line);
|
||||
oom:
|
||||
free(evstr);
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_str(NULL);
|
||||
toobig:
|
||||
free(evstr);
|
||||
|
@ -516,7 +516,7 @@ command_matches_glob(const char *sudoers_cmnd, const char *sudoers_args)
|
||||
user_stat->st_ino == sudoers_stat.st_ino)) {
|
||||
free(safe_cmnd);
|
||||
if ((safe_cmnd = strdup(cp)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
cp = NULL; /* fail closed */
|
||||
}
|
||||
break;
|
||||
@ -552,7 +552,7 @@ command_matches_normal(const char *sudoers_cmnd, const char *sudoers_args, const
|
||||
free(safe_cmnd);
|
||||
if ((safe_cmnd = strdup(sudoers_cmnd)) != NULL)
|
||||
debug_return_bool(true);
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
}
|
||||
debug_return_bool(false);
|
||||
@ -710,7 +710,7 @@ command_matches_normal(const char *sudoers_cmnd, const char *sudoers_args, const
|
||||
}
|
||||
free(safe_cmnd);
|
||||
if ((safe_cmnd = strdup(sudoers_cmnd)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
debug_return_bool(true);
|
||||
@ -767,7 +767,7 @@ command_matches_dir(const char *sudoers_dir, size_t dlen)
|
||||
user_stat->st_ino == sudoers_stat.st_ino)) {
|
||||
free(safe_cmnd);
|
||||
if ((safe_cmnd = strdup(buf)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
dent = NULL;
|
||||
}
|
||||
break;
|
||||
|
@ -235,7 +235,7 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
|
||||
if (cs->role != NULL) {
|
||||
user_role = strdup(cs->role);
|
||||
if (user_role == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
SET(validated, VALIDATE_ERROR);
|
||||
goto done;
|
||||
}
|
||||
@ -247,7 +247,7 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
|
||||
if (cs->type != NULL) {
|
||||
user_type = strdup(cs->type);
|
||||
if (user_type == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
SET(validated, VALIDATE_ERROR);
|
||||
goto done;
|
||||
}
|
||||
@ -262,7 +262,7 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
|
||||
if (cs->privs != NULL) {
|
||||
runas_privs = strdup(cs->privs);
|
||||
if (runas_privs == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
SET(validated, VALIDATE_ERROR);
|
||||
goto done;
|
||||
}
|
||||
@ -274,7 +274,7 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
|
||||
if (cs->limitprivs != NULL) {
|
||||
runas_limitprivs = strdup(cs->limitprivs);
|
||||
if (runas_limitprivs == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
SET(validated, VALIDATE_ERROR);
|
||||
goto done;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
||||
debug_return_int(flags);
|
||||
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
bad:
|
||||
debug_return_int(MODE_ERROR);
|
||||
}
|
||||
@ -575,7 +575,7 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask,
|
||||
debug_return_int(true);
|
||||
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
bad:
|
||||
while (info_len--)
|
||||
free(command_info[info_len]);
|
||||
|
@ -91,7 +91,7 @@ expand_prompt(const char *old_prompt, const char *auth_user)
|
||||
}
|
||||
|
||||
if ((new_prompt = malloc(++len)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_str(NULL);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ sudo_sss_attrcpy(struct sss_sudo_attr *dst, const struct sss_sudo_attr *src)
|
||||
|
||||
debug_return_bool(true);
|
||||
oom:
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sudo_sss_attrfree(dst);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
@ -192,13 +192,13 @@ sudo_sss_rulecpy(struct sss_sudo_rule *dst, const struct sss_sudo_rule *src)
|
||||
dst->num_attrs = 0;
|
||||
dst->attrs = reallocarray(NULL, src->num_attrs, sizeof(struct sss_sudo_attr));
|
||||
if (dst->attrs == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
|
||||
for (i = 0; i < src->num_attrs; ++i) {
|
||||
if (!sudo_sss_attrcpy(dst->attrs + i, src->attrs + i)) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
dst->num_attrs = i;
|
||||
sudo_sss_rulefree(dst);
|
||||
debug_return_bool(false);
|
||||
@ -236,14 +236,14 @@ sudo_sss_filter_result(struct sudo_sss_handle *handle,
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG, "malloc: cnt=%d", in_res->num_rules);
|
||||
|
||||
if ((out_res = calloc(1, sizeof(struct sss_sudo_result))) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
if (in_res->num_rules > 0) {
|
||||
out_res->rules =
|
||||
reallocarray(NULL, in_res->num_rules, sizeof(struct sss_sudo_rule));
|
||||
if (out_res->rules == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
free(out_res);
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
@ -279,7 +279,7 @@ sudo_sss_filter_result(struct sudo_sss_handle *handle,
|
||||
struct sss_sudo_rule *rules =
|
||||
reallocarray(out_res->rules, l, sizeof(struct sss_sudo_rule));
|
||||
if (out_res->rules == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
while (l--) {
|
||||
sudo_sss_rulefree(out_res->rules + l);
|
||||
}
|
||||
@ -324,7 +324,7 @@ sudo_sss_open(struct sudo_nss *nss)
|
||||
/* Create a handle container. */
|
||||
handle = malloc(sizeof(struct sudo_sss_handle));
|
||||
if (handle == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(ENOMEM);
|
||||
}
|
||||
|
||||
@ -916,7 +916,7 @@ sudo_sss_extract_digest(char **cmnd, struct sudo_digest *digest)
|
||||
digest->digest_type = digest_type;
|
||||
digest->digest_str = strndup(cp, (size_t)(ep - cp));
|
||||
if (digest->digest_str == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
cp = ep + 1;
|
||||
@ -1049,7 +1049,7 @@ sudo_sss_parse_options(struct sudo_sss_handle *handle, struct sss_sudo_rule *rul
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO, "sssd/ldap sudoOption: '%s'",
|
||||
val_array[i]);
|
||||
if ((v = strdup(val_array[i])) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ sudoers_policy_init(void *info, char * const envp[])
|
||||
bindtextdomain("sudoers", LOCALEDIR);
|
||||
|
||||
if (sudo_setpwent() == -1 || sudo_setgrent() == -1) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
NewArgc = 1;
|
||||
NewArgv = reallocarray(NULL, NewArgc + 1, sizeof(char *));
|
||||
if (NewArgv == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = -1;
|
||||
goto done;
|
||||
}
|
||||
@ -305,7 +305,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
NewArgc = argc;
|
||||
NewArgv = reallocarray(NULL, NewArgc + 2, sizeof(char *));
|
||||
if (NewArgv == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = -1;
|
||||
goto done;
|
||||
}
|
||||
@ -314,7 +314,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
if (ISSET(sudo_mode, MODE_LOGIN_SHELL) && runas_pw != NULL) {
|
||||
NewArgv[0] = strdup(runas_pw->pw_shell);
|
||||
if (NewArgv[0] == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
free(NewArgv);
|
||||
rval = -1;
|
||||
goto done;
|
||||
@ -371,7 +371,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
|
||||
if (safe_cmnd == NULL) {
|
||||
if ((safe_cmnd = strdup(user_cmnd)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rval = -1;
|
||||
goto done;
|
||||
}
|
||||
@ -645,7 +645,7 @@ init_vars(char * const envp[])
|
||||
debug_decl(init_vars, SUDOERS_DEBUG_PLUGIN)
|
||||
|
||||
if (!sudoers_initlocale(setlocale(LC_ALL, NULL), def_sudoers_locale)) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
|
||||
@ -731,7 +731,7 @@ set_cmnd(void)
|
||||
/* Allocate user_stat for find_path() and match functions. */
|
||||
user_stat = calloc(1, sizeof(struct stat));
|
||||
if (user_stat == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(NOT_FOUND_ERROR);
|
||||
}
|
||||
|
||||
@ -775,7 +775,7 @@ set_cmnd(void)
|
||||
for (size = 0, av = NewArgv + 1; *av; av++)
|
||||
size += strlen(*av) + 1;
|
||||
if (size == 0 || (user_args = malloc(size)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
if (ISSET(sudo_mode, MODE_SHELL|MODE_LOGIN_SHELL)) {
|
||||
|
@ -106,7 +106,8 @@ oom:
|
||||
free(debug_file->debug_flags);
|
||||
free(debug_file);
|
||||
}
|
||||
sudo_warnx_nodebug(U_("unable to allocate memory"));
|
||||
sudo_warnx_nodebug(U_("%s: %s"), "sudoers_debug_parse_flags",
|
||||
U_("unable to allocate memory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ replay_session(const double max_wait, const char *decimal)
|
||||
reallocarray(iov, iovmax <<= 1, sizeof(*iov)) :
|
||||
reallocarray(NULL, iovmax = 32, sizeof(*iov));
|
||||
if (iov == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
linelen = (size_t)(nl - line) + 1;
|
||||
iov[iovcnt].iov_base = line;
|
||||
@ -682,7 +682,7 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
|
||||
|
||||
/* Allocate new search node */
|
||||
if ((sn = calloc(1, sizeof(*sn))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sn->type = type;
|
||||
sn->or = or;
|
||||
sn->negated = not;
|
||||
@ -794,7 +794,7 @@ parse_logfile(char *logfile)
|
||||
* 3) command with args
|
||||
*/
|
||||
if ((li = calloc(1, sizeof(*li))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
if (getline(&buf, &bufsize, fp) == -1 ||
|
||||
getline(&li->cwd, &cwdsize, fp) == -1 ||
|
||||
getline(&li->cmd, &cmdsize, fp) == -1) {
|
||||
@ -834,7 +834,7 @@ parse_logfile(char *logfile)
|
||||
goto bad;
|
||||
}
|
||||
if ((li->user = strndup(cp, (size_t)(ep - cp))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
/* runas user */
|
||||
cp = ep + 1;
|
||||
@ -843,7 +843,7 @@ parse_logfile(char *logfile)
|
||||
goto bad;
|
||||
}
|
||||
if ((li->runas_user = strndup(cp, (size_t)(ep - cp))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
/* runas group */
|
||||
cp = ep + 1;
|
||||
@ -853,7 +853,7 @@ parse_logfile(char *logfile)
|
||||
}
|
||||
if (cp != ep) {
|
||||
if ((li->runas_group = strndup(cp, (size_t)(ep - cp))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
|
||||
/* tty, followed by optional rows + columns */
|
||||
@ -861,11 +861,11 @@ parse_logfile(char *logfile)
|
||||
if ((ep = strchr(cp, ':')) == NULL) {
|
||||
/* just the tty */
|
||||
if ((li->tty = strdup(cp)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
} else {
|
||||
/* tty followed by rows + columns */
|
||||
if ((li->tty = strndup(cp, (size_t)(ep - cp))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
cp = ep + 1;
|
||||
/* need to NULL out separator to use strtonum() */
|
||||
if ((ep = strchr(cp, ':')) != NULL) {
|
||||
@ -1021,11 +1021,11 @@ find_sessions(const char *dir, regex_t *re, const char *user, const char *tty)
|
||||
sessions_size = 36 * 36 / 2;
|
||||
sessions = reallocarray(sessions, sessions_size, 2 * sizeof(char *));
|
||||
if (sessions == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sessions_size *= 2;
|
||||
}
|
||||
if ((sessions[sessions_len] = strdup(dp->d_name)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sessions_len++;
|
||||
}
|
||||
closedir(d);
|
||||
|
@ -130,7 +130,7 @@ main(int argc, char *argv[])
|
||||
initprogname(argc > 0 ? argv[0] : "testsudoers");
|
||||
|
||||
if (!sudoers_initlocale(setlocale(LC_ALL, ""), def_sudoers_locale))
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have own domain */
|
||||
textdomain("sudoers");
|
||||
|
||||
@ -187,7 +187,7 @@ main(int argc, char *argv[])
|
||||
if (pwfile)
|
||||
setpwfile(pwfile);
|
||||
if (sudo_setpwent() == -1 || sudo_setgrent() == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
if (argc < 2) {
|
||||
if (!dflag)
|
||||
@ -214,7 +214,7 @@ main(int argc, char *argv[])
|
||||
if ((p = strchr(user_host, '.'))) {
|
||||
*p = '\0';
|
||||
if ((user_shost = strdup(user_host)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
*p = '.';
|
||||
} else {
|
||||
user_shost = user_host;
|
||||
@ -231,7 +231,7 @@ main(int argc, char *argv[])
|
||||
size += strlen(*from) + 1;
|
||||
|
||||
if ((user_args = malloc(size)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
for (to = user_args, from = argv; *from; from++) {
|
||||
n = strlcpy(to, *from, size - (to - user_args));
|
||||
if (n >= size - (to - user_args))
|
||||
|
@ -155,7 +155,7 @@ main(int argc, char *argv[])
|
||||
|
||||
initprogname(argc > 0 ? argv[0] : "visudo");
|
||||
if (!sudoers_initlocale(setlocale(LC_ALL, ""), def_sudoers_locale))
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */
|
||||
textdomain("sudoers");
|
||||
|
||||
@ -215,7 +215,7 @@ main(int argc, char *argv[])
|
||||
usage(1);
|
||||
|
||||
if (sudo_setpwent() == -1 || sudo_setgrent() == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
/* Mock up a fake sudo_user struct. */
|
||||
user_cmnd = user_base = "";
|
||||
@ -299,13 +299,13 @@ get_editor(int *editor_argc, char ***editor_argv)
|
||||
}
|
||||
whitelist = reallocarray(NULL, whitelist_len + 1, sizeof(char *));
|
||||
if (whitelist == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
whitelist_len = 0;
|
||||
for (cp = sudo_strsplit(def_editor, def_editor_end, ":", &ep);
|
||||
cp != NULL; cp = sudo_strsplit(NULL, def_editor_end, ":", &ep)) {
|
||||
whitelist[whitelist_len] = strndup(cp, (size_t)(ep - cp));
|
||||
if (whitelist[whitelist_len] == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
whitelist_len++;
|
||||
}
|
||||
whitelist[whitelist_len] = NULL;
|
||||
@ -435,7 +435,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, int editor_argc,
|
||||
/* Create the temp file if needed and set timestamp. */
|
||||
if (sp->tpath == NULL) {
|
||||
if (asprintf(&sp->tpath, "%s.tmp", sp->path) == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
tfd = open(sp->tpath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
if (tfd < 0)
|
||||
sudo_fatal("%s", sp->tpath);
|
||||
@ -971,7 +971,7 @@ open_sudoers(const char *path, bool doedit, bool *keepopen)
|
||||
if (entry == NULL) {
|
||||
entry = calloc(1, sizeof(*entry));
|
||||
if (entry == NULL || (entry->path = strdup(path)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
/* entry->modified = 0; */
|
||||
entry->fd = open(entry->path, open_flags, sudoers_mode);
|
||||
/* entry->tpath = NULL; */
|
||||
@ -1015,7 +1015,7 @@ get_hostname(void)
|
||||
if ((p = strchr(user_host, '.'))) {
|
||||
*p = '\0';
|
||||
if ((user_shost = strdup(user_host)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
*p = '.';
|
||||
} else {
|
||||
user_shost = user_host;
|
||||
@ -1111,7 +1111,7 @@ check_aliases(bool strict, bool quiet)
|
||||
|
||||
alias_freelist = rbcreate(alias_compare);
|
||||
if (alias_freelist == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,10 @@ sudo_conversation(int num_msgs, const struct sudo_conv_message msgs[],
|
||||
pass = tgetpass(msg->msg, msg->timeout, flags);
|
||||
if (pass == NULL)
|
||||
goto err;
|
||||
if ((repl->reply = strdup(pass)) == NULL)
|
||||
sudo_fatalx_nodebug(U_("unable to allocate memory"));
|
||||
if ((repl->reply = strdup(pass)) == NULL) {
|
||||
sudo_fatalx_nodebug(U_("%s: %s"), "sudo_conversation",
|
||||
U_("unable to allocate memory"));
|
||||
}
|
||||
memset_s(pass, SUDO_CONV_REPL_MAX, 0, strlen(pass));
|
||||
break;
|
||||
case SUDO_CONV_INFO_MSG:
|
||||
|
@ -864,7 +864,7 @@ schedule_signal(struct sudo_event_base *evbase, int signo)
|
||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "scheduled SIG%s for child", signame);
|
||||
|
||||
if ((sigfwd = calloc(1, sizeof(*sigfwd))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sigfwd->signo = signo;
|
||||
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
|
||||
|
||||
|
@ -96,7 +96,7 @@ disable_execute(char *const envp[])
|
||||
#endif
|
||||
nenvp = reallocarray(NULL, env_size, sizeof(*envp));
|
||||
if (nenvp == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
memcpy(nenvp, envp, env_len * sizeof(*envp));
|
||||
nenvp[env_len] = NULL;
|
||||
|
||||
@ -108,14 +108,14 @@ disable_execute(char *const envp[])
|
||||
preload = sudo_new_key_val(RTLD_PRELOAD_VAR, sudo_conf_noexec_path());
|
||||
# endif
|
||||
if (preload == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
nenvp[env_len++] = preload;
|
||||
nenvp[env_len] = NULL;
|
||||
} else {
|
||||
int len = asprintf(&preload, "%s=%s%s%s", RTLD_PRELOAD_VAR,
|
||||
sudo_conf_noexec_path(), RTLD_PRELOAD_DELIM, nenvp[preload_idx]);
|
||||
if (len == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
nenvp[preload_idx] = preload;
|
||||
}
|
||||
# ifdef RTLD_PRELOAD_ENABLE_VAR
|
||||
|
@ -687,7 +687,7 @@ io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct i
|
||||
|
||||
/* Allocate and add to head of list. */
|
||||
if ((iob = malloc(sizeof(*iob))) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
iob->revent = sudo_ev_alloc(rfd, SUDO_EV_READ, io_callback, iob);
|
||||
iob->wevent = sudo_ev_alloc(wfd, SUDO_EV_WRITE, io_callback, iob);
|
||||
iob->len = 0;
|
||||
@ -695,7 +695,7 @@ io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct i
|
||||
iob->action = action;
|
||||
iob->buf[0] = '\0';
|
||||
if (iob->revent == NULL || iob->wevent == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
SLIST_INSERT_HEAD(head, iob, entries);
|
||||
|
||||
debug_return;
|
||||
|
@ -206,7 +206,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
||||
policy_plugin->handle = handle;
|
||||
policy_plugin->path = strdup(path);
|
||||
if (policy_plugin->path == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto bad;
|
||||
}
|
||||
policy_plugin->name = info->symbol_name;
|
||||
@ -229,7 +229,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
||||
if (handle != NULL) {
|
||||
container = calloc(1, sizeof(*container));
|
||||
if (container == NULL || (container->path = strdup(path)) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto bad;
|
||||
}
|
||||
container->handle = handle;
|
||||
@ -294,7 +294,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
|
||||
/* Default policy plugin */
|
||||
info = calloc(1, sizeof(*info));
|
||||
if (info == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
info->symbol_name = "sudoers_policy";
|
||||
@ -309,7 +309,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
|
||||
if (TAILQ_EMPTY(io_plugins)) {
|
||||
info = calloc(1, sizeof(*info));
|
||||
if (info == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
info->symbol_name = "sudoers_io";
|
||||
|
@ -180,7 +180,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
|
||||
env_add = reallocarray(NULL, env_size, sizeof(char *));
|
||||
if (env_add == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
/* Pass progname to plugin so it can call initprogname() */
|
||||
progname = getprogname();
|
||||
@ -202,7 +202,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
i = sudo_conf_max_groups();
|
||||
if (i != -1) {
|
||||
if (asprintf(&cp, "%d", i) == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
sudo_settings[ARG_MAX_GROUPS].value = cp;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
|
||||
tmp = reallocarray(env_add, env_size, 2 * sizeof(char *));
|
||||
if (tmp == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
env_add = tmp;
|
||||
env_size *= 2;
|
||||
}
|
||||
@ -466,7 +466,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
|
||||
cmnd = dst = reallocarray(NULL, cmnd_size, 2);
|
||||
if (cmnd == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
for (av = argv; *av != NULL; av++) {
|
||||
for (src = *av; *src != '\0'; src++) {
|
||||
/* quote potential meta characters */
|
||||
@ -485,7 +485,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
|
||||
av = reallocarray(NULL, ac + 1, sizeof(char *));
|
||||
if (av == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
av[0] = (char *)user_details.shell; /* plugin may override shell */
|
||||
if (cmnd != NULL) {
|
||||
av[1] = "-c";
|
||||
|
@ -52,7 +52,7 @@ add_preserved_fd(struct preserved_fd_list *pfds, int fd)
|
||||
|
||||
pfd_new = malloc(sizeof(*pfd));
|
||||
if (pfd_new == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
pfd_new->lowfd = fd;
|
||||
pfd_new->highfd = fd;
|
||||
pfd_new->flags = fcntl(fd, F_GETFD);
|
||||
@ -135,7 +135,7 @@ closefrom_except(int startfd, struct preserved_fd_list *pfds)
|
||||
/* Create bitmap of preserved (relocated) fds. */
|
||||
fdsp = calloc(howmany(lastfd + 1, NFDBITS), sizeof(fd_mask));
|
||||
if (fdsp == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
TAILQ_FOREACH(pfd, pfds, entries) {
|
||||
FD_SET(pfd->lowfd, fdsp);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ audit_role_change(const security_context_t old_context,
|
||||
rc = asprintf(&message, "newrole: old-context=%s new-context=%s",
|
||||
old_context, new_context);
|
||||
if (rc == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
|
||||
message, NULL, NULL, ttyn, result);
|
||||
if (rc <= 0)
|
||||
@ -289,7 +289,7 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
|
||||
* Convert "context" back into a string and verify it.
|
||||
*/
|
||||
if ((new_context = strdup(context_str(context))) == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto bad;
|
||||
}
|
||||
if (security_check_context(new_context) < 0) {
|
||||
@ -412,7 +412,7 @@ selinux_execve(const char *path, char *const argv[], char *const envp[],
|
||||
continue;
|
||||
nargv = reallocarray(NULL, argc + 2, sizeof(char *));
|
||||
if (nargv == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return;
|
||||
}
|
||||
if (noexec)
|
||||
|
@ -98,7 +98,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
argv++;
|
||||
argc--;
|
||||
if ((cmnd = strdup(argv[0])) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
/* If invoked as a login shell, modify argv[0] accordingly. */
|
||||
if (login_shell) {
|
||||
|
@ -181,7 +181,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
|
||||
/* Fill in user_info with user name, uid, cwd, etc. */
|
||||
if ((user_info = get_user_info(&user_details)) == NULL)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
|
||||
/* Disable core dumps if not enabled in sudo.conf. */
|
||||
disable_coredumps();
|
||||
@ -358,7 +358,7 @@ fill_group_list(struct user_details *ud, int system_maxgroups)
|
||||
if (ud->ngroups > 0) {
|
||||
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
|
||||
if (ud->groups == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
/* No error on insufficient space if user specified max_groups. */
|
||||
@ -377,7 +377,7 @@ fill_group_list(struct user_details *ud, int system_maxgroups)
|
||||
free(ud->groups);
|
||||
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
|
||||
if (ud->groups == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto done;
|
||||
}
|
||||
rval = getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
|
||||
@ -443,7 +443,7 @@ get_user_groups(struct user_details *ud)
|
||||
}
|
||||
debug_return_str(gid_list);
|
||||
oom:
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -153,7 +153,7 @@ sudo_edit_mktemp(const char *ofile, char **tfile)
|
||||
len = asprintf(tfile, "%s/%s.XXXXXXXX", edit_tmpdir, cp);
|
||||
}
|
||||
if (len == -1)
|
||||
sudo_fatalx(U_("unable to allocate memory"));
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
tfd = mkstemps(*tfile, suff ? strlen(suff) : 0);
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||
"%s -> %s, fd %d", ofile, *tfile, tfd);
|
||||
@ -374,7 +374,7 @@ selinux_edit_create_tfiles(struct command_details *command_details,
|
||||
sesh_nargs = 3 + (nfiles * 2) + 1;
|
||||
sesh_args = sesh_ap = reallocarray(NULL, sesh_nargs, sizeof(char *));
|
||||
if (sesh_args == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
*sesh_ap++ = "sesh";
|
||||
@ -469,7 +469,7 @@ selinux_edit_copy_tfiles(struct command_details *command_details,
|
||||
sesh_nargs = 3 + (nfiles * 2) + 1;
|
||||
sesh_args = sesh_ap = reallocarray(NULL, sesh_nargs, sizeof(char *));
|
||||
if (sesh_args == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
debug_return_int(-1);
|
||||
}
|
||||
*sesh_ap++ = "sesh";
|
||||
@ -581,7 +581,7 @@ sudo_edit(struct command_details *command_details)
|
||||
/* Copy editor files to temporaries. */
|
||||
tf = calloc(nfiles, sizeof(*tf));
|
||||
if (tf == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto cleanup;
|
||||
}
|
||||
#ifdef HAVE_SELINUX
|
||||
@ -601,7 +601,7 @@ sudo_edit(struct command_details *command_details)
|
||||
nargc = editor_argc + nfiles;
|
||||
nargv = reallocarray(NULL, nargc + 1, sizeof(char *));
|
||||
if (nargv == NULL) {
|
||||
sudo_warnx(U_("unable to allocate memory"));
|
||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
goto cleanup;
|
||||
}
|
||||
for (ac = 0; ac < editor_argc; ac++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user