mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-04 08:15:15 +00:00
Add missing warnings for memory allocation failure.
Add function name to memory allocation warnings.
This commit is contained in:
@@ -4041,9 +4041,11 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
|
|||||||
}
|
}
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
paths = malloc(sizeof(*paths) * max_paths);
|
paths = reallocarray(NULL, max_paths, sizeof(*paths));
|
||||||
if (paths == NULL)
|
if (paths == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
while ((dent = readdir(dir)) != NULL) {
|
while ((dent = readdir(dir)) != NULL) {
|
||||||
struct path_list *pl;
|
struct path_list *pl;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@@ -4062,6 +4064,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
|
|||||||
}
|
}
|
||||||
pl = malloc(sizeof(*pl));
|
pl = malloc(sizeof(*pl));
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
free(path);
|
free(path);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -4071,6 +4074,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
|
|||||||
max_paths <<= 1;
|
max_paths <<= 1;
|
||||||
tmp = reallocarray(paths, max_paths, sizeof(*paths));
|
tmp = reallocarray(paths, max_paths, sizeof(*paths));
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
free(path);
|
free(path);
|
||||||
free(pl);
|
free(pl);
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -4178,7 +4182,7 @@ push_include_int(char *path, bool isdir)
|
|||||||
istacksize += SUDOERS_STACK_INCREMENT;
|
istacksize += SUDOERS_STACK_INCREMENT;
|
||||||
new_istack = reallocarray(istack, istacksize, sizeof(*istack));
|
new_istack = reallocarray(istack, istacksize, sizeof(*istack));
|
||||||
if (new_istack == NULL) {
|
if (new_istack == NULL) {
|
||||||
sudo_warn(NULL);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
@@ -4336,7 +4340,7 @@ parse_include(char *base)
|
|||||||
len += (int)(ep - cp);
|
len += (int)(ep - cp);
|
||||||
path = pp = malloc(len + dirlen + 1);
|
path = pp = malloc(len + dirlen + 1);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
sudo_warn(NULL);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
debug_return_str(NULL);
|
debug_return_str(NULL);
|
||||||
}
|
}
|
||||||
|
@@ -770,9 +770,11 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
|
|||||||
}
|
}
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
paths = malloc(sizeof(*paths) * max_paths);
|
paths = reallocarray(NULL, max_paths, sizeof(*paths));
|
||||||
if (paths == NULL)
|
if (paths == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
while ((dent = readdir(dir)) != NULL) {
|
while ((dent = readdir(dir)) != NULL) {
|
||||||
struct path_list *pl;
|
struct path_list *pl;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@@ -791,6 +793,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
|
|||||||
}
|
}
|
||||||
pl = malloc(sizeof(*pl));
|
pl = malloc(sizeof(*pl));
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
free(path);
|
free(path);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
@@ -800,6 +803,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
|
|||||||
max_paths <<= 1;
|
max_paths <<= 1;
|
||||||
tmp = reallocarray(paths, max_paths, sizeof(*paths));
|
tmp = reallocarray(paths, max_paths, sizeof(*paths));
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
free(path);
|
free(path);
|
||||||
free(pl);
|
free(pl);
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -907,7 +911,7 @@ push_include_int(char *path, bool isdir)
|
|||||||
istacksize += SUDOERS_STACK_INCREMENT;
|
istacksize += SUDOERS_STACK_INCREMENT;
|
||||||
new_istack = reallocarray(istack, istacksize, sizeof(*istack));
|
new_istack = reallocarray(istack, istacksize, sizeof(*istack));
|
||||||
if (new_istack == NULL) {
|
if (new_istack == NULL) {
|
||||||
sudo_warn(NULL);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
@@ -1065,7 +1069,7 @@ parse_include(char *base)
|
|||||||
len += (int)(ep - cp);
|
len += (int)(ep - cp);
|
||||||
path = pp = malloc(len + dirlen + 1);
|
path = pp = malloc(len + dirlen + 1);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
sudo_warn(NULL);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
debug_return_str(NULL);
|
debug_return_str(NULL);
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ fill_txt(const char *src, int len, int olen)
|
|||||||
|
|
||||||
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
|
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
sudo_warn(NULL);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ fill_cmnd(const char *src, int len)
|
|||||||
|
|
||||||
dst = sudoerslval.command.cmnd = malloc(len + 1);
|
dst = sudoerslval.command.cmnd = malloc(len + 1);
|
||||||
if (sudoerslval.command.cmnd == NULL) {
|
if (sudoerslval.command.cmnd == NULL) {
|
||||||
sudo_warn(NULL);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
@@ -144,9 +144,9 @@ fill_args(const char *s, int len, int addspace)
|
|||||||
|
|
||||||
p = realloc(sudoerslval.command.args, arg_size);
|
p = realloc(sudoerslval.command.args, arg_size);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
free(sudoerslval.command.args);
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
sudo_warn(NULL);
|
|
||||||
sudoerserror(NULL);
|
sudoerserror(NULL);
|
||||||
|
free(sudoerslval.command.args);
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
} else
|
} else
|
||||||
sudoerslval.command.args = p;
|
sudoerslval.command.args = p;
|
||||||
|
Reference in New Issue
Block a user