Cast int to size_t before adding instead of casting the result.
Quiets PVS-Studio warning V1028.
This commit is contained in:
@@ -286,7 +286,8 @@ find_editor(int nfiles, char * const files[], char **argv_out[])
|
||||
}
|
||||
if (editor_path != editor)
|
||||
free(editor);
|
||||
nargv = reallocarray(NULL, (size_t)(nargc + 1 + nfiles + 1), sizeof(char *));
|
||||
nargv = reallocarray(NULL, (size_t)nargc + 1 + (size_t)nfiles + 1,
|
||||
sizeof(char *));
|
||||
if (nargv == NULL) {
|
||||
sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n");
|
||||
free(editor_path);
|
||||
|
@@ -158,7 +158,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char * const *files,
|
||||
nargc++;
|
||||
if (nfiles != 0)
|
||||
nargc += nfiles + 1;
|
||||
nargv = reallocarray(NULL, (size_t)(nargc + 1), sizeof(char *));
|
||||
nargv = reallocarray(NULL, (size_t)nargc + 1, sizeof(char *));
|
||||
if (nargv == NULL)
|
||||
goto oom;
|
||||
sudoers_gc_add(GC_PTR, nargv);
|
||||
|
@@ -206,7 +206,7 @@ group_plugin_load(const struct sudoers_context *ctx, const char *plugin_info)
|
||||
}
|
||||
}
|
||||
if (ac != 0) {
|
||||
argv = reallocarray(NULL, (size_t)(ac + 1), sizeof(char *));
|
||||
argv = reallocarray(NULL, (size_t)ac + 1, sizeof(char *));
|
||||
if (argv == NULL) {
|
||||
sudo_warnx(U_("%s: %s"), __func__,
|
||||
U_("unable to allocate memory"));
|
||||
|
@@ -796,7 +796,7 @@ sudoers_policy_store_result(struct sudoers_context *ctx, bool accepted,
|
||||
|
||||
/* We reserve an extra spot in the list for the effective gid. */
|
||||
glsize = sizeof("runas_groups=") - 1 +
|
||||
((size_t)(gidlist->ngids + 1) * (MAX_UID_T_LEN + 1));
|
||||
(((size_t)gidlist->ngids + 1) * (MAX_UID_T_LEN + 1));
|
||||
gid_list = malloc(glsize);
|
||||
if (gid_list == NULL) {
|
||||
sudo_gidlist_delref(gidlist);
|
||||
|
@@ -1551,11 +1551,11 @@ find_sessions(const char *dir, regex_t *re, const char *user, const char *tty)
|
||||
|
||||
/* Check for dir with a log file. */
|
||||
if (lstat(pathbuf, &sb) == 0 && S_ISREG(sb.st_mode)) {
|
||||
pathbuf[sdlen + (size_t)(len - 4)] = '\0';
|
||||
pathbuf[sdlen + (size_t)len - 4] = '\0';
|
||||
list_session(&lbuf, pathbuf, re, user, tty);
|
||||
} else {
|
||||
/* Strip off "/log" and recurse if a non-log dir. */
|
||||
pathbuf[sdlen + (size_t)(len - 4)] = '\0';
|
||||
pathbuf[sdlen + (size_t)len - 4] = '\0';
|
||||
if (checked_type ||
|
||||
(lstat(pathbuf, &sb) == 0 && S_ISDIR(sb.st_mode)))
|
||||
find_sessions(pathbuf, re, user, tty);
|
||||
|
@@ -1884,7 +1884,7 @@ ptrace_intercept_execve(pid_t pid, struct intercept_closure *closure)
|
||||
*/
|
||||
if (argv_mismatch) {
|
||||
/* argv pointers */
|
||||
space += (size_t)(argc + 1 + regs.compat) * regs.wordsize;
|
||||
space += ((size_t)argc + 1 + regs.compat) * regs.wordsize;
|
||||
|
||||
/* argv strings */
|
||||
for (argc = 0; closure->run_argv[argc] != NULL; argc++) {
|
||||
@@ -1905,7 +1905,7 @@ ptrace_intercept_execve(pid_t pid, struct intercept_closure *closure)
|
||||
set_sc_arg2(®s, sp);
|
||||
|
||||
/* Skip over argv pointers (plus NULL) for string table. */
|
||||
strtab += (size_t)(argc + 1 + regs.compat) * regs.wordsize;
|
||||
strtab += ((size_t)argc + 1 + regs.compat) * regs.wordsize;
|
||||
|
||||
nwritten = ptrace_write_vec(pid, ®s, closure->run_argv,
|
||||
sp, strtab);
|
||||
|
Reference in New Issue
Block a user