Reduce the number of "internal error, foo overflow" messages that
need to be translated.
This commit is contained in:
@@ -98,7 +98,7 @@ emalloc2(size_t nmemb, size_t size)
|
||||
if (nmemb == 0 || size == 0)
|
||||
errorx2(1, _("internal error, tried to emalloc2(0)"));
|
||||
if (nmemb > SIZE_MAX / size)
|
||||
errorx2(1, _("internal error, emalloc2() overflow"));
|
||||
errorx2(1, _("internal error, %s overflow"), "emalloc2()");
|
||||
|
||||
size *= nmemb;
|
||||
if ((ptr = malloc(size)) == NULL)
|
||||
@@ -120,7 +120,7 @@ ecalloc(size_t nmemb, size_t size)
|
||||
errorx2(1, _("internal error, tried to ecalloc(0)"));
|
||||
if (nmemb != 1) {
|
||||
if (nmemb > SIZE_MAX / size)
|
||||
errorx2(1, _("internal error, ecalloc() overflow"));
|
||||
errorx2(1, _("internal error, %s overflow"), "ecalloc()");
|
||||
size *= nmemb;
|
||||
}
|
||||
if ((ptr = malloc(size)) == NULL)
|
||||
@@ -160,7 +160,7 @@ erealloc3(void *ptr, size_t nmemb, size_t size)
|
||||
if (nmemb == 0 || size == 0)
|
||||
errorx2(1, _("internal error, tried to erealloc3(0)"));
|
||||
if (nmemb > SIZE_MAX / size)
|
||||
errorx2(1, _("internal error, erealloc3() overflow"));
|
||||
errorx2(1, _("internal error, %s overflow"), "erealloc3()");
|
||||
|
||||
size *= nmemb;
|
||||
ptr = ptr ? realloc(ptr, size) : malloc(size);
|
||||
@@ -182,9 +182,9 @@ erecalloc(void *ptr, size_t onmemb, size_t nmemb, size_t msize)
|
||||
size_t size;
|
||||
|
||||
if (nmemb == 0 || msize == 0)
|
||||
errorx2(1, _("internal error, tried to erealloc3(0)"));
|
||||
errorx2(1, _("internal error, tried to erecalloc(0)"));
|
||||
if (nmemb > SIZE_MAX / msize)
|
||||
errorx2(1, _("internal error, erealloc3() overflow"));
|
||||
errorx2(1, _("internal error, %s overflow"), "erecalloc()");
|
||||
|
||||
size = nmemb * msize;
|
||||
ptr = ptr ? realloc(ptr, size) : malloc(size);
|
||||
|
@@ -396,7 +396,7 @@ expand_prompt(char *old_prompt, char *user, char *host)
|
||||
|
||||
oflow:
|
||||
/* We pre-allocate enough space, so this should never happen. */
|
||||
errorx(1, _("internal error, expand_prompt() overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "expand_prompt()");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -285,11 +285,15 @@ sudo_putenv_nodebug(char *str, bool dupcheck, bool overwrite)
|
||||
char **nenvp;
|
||||
size_t nsize;
|
||||
|
||||
if (env.env_size > SIZE_MAX - 128)
|
||||
errorx2(1, _("internal error, sudo_putenv_nodebug() overflow"));
|
||||
if (env.env_size > SIZE_MAX - 128) {
|
||||
errorx2(1, _("internal error, %s overflow"),
|
||||
"sudo_putenv_nodebug()");
|
||||
}
|
||||
nsize = env.env_size + 128;
|
||||
if (nsize > SIZE_MAX / sizeof(char *))
|
||||
errorx2(1, _("internal error, sudo_putenv_nodebug() overflow"));
|
||||
if (nsize > SIZE_MAX / sizeof(char *)) {
|
||||
errorx2(1, _("internal error, %s overflow"),
|
||||
"sudo_putenv_nodebug()");
|
||||
}
|
||||
nenvp = realloc(env.envp, nsize * sizeof(char *));
|
||||
if (nenvp == NULL) {
|
||||
errno = ENOMEM;
|
||||
@@ -388,7 +392,7 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite)
|
||||
strlcat(estring, "=", esize) >= esize ||
|
||||
strlcat(estring, val, esize) >= esize) {
|
||||
|
||||
errorx(1, _("internal error, sudo_setenv2() overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "sudo_setenv2()");
|
||||
}
|
||||
rval = sudo_putenv(estring, dupcheck, overwrite);
|
||||
if (rval == -1)
|
||||
@@ -440,7 +444,7 @@ sudo_setenv(const char *var, const char *val, int overwrite)
|
||||
rval = sudo_setenv_nodebug(var, val, overwrite);
|
||||
if (rval == -1) {
|
||||
if (errno == EINVAL)
|
||||
errorx(1, _("internal error, sudo_setenv() overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "sudo_setenv()");
|
||||
errorx(1, _("unable to allocate memory"));
|
||||
}
|
||||
debug_return_int(rval);
|
||||
|
@@ -78,8 +78,10 @@ linux_audit_command(char *argv[], int result)
|
||||
command = cp = emalloc(size);
|
||||
for (av = argv; *av != NULL; av++) {
|
||||
n = strlcpy(cp, *av, size - (cp - command));
|
||||
if (n >= size - (cp - command))
|
||||
errorx(1, _("internal error, linux_audit_command() overflow"));
|
||||
if (n >= size - (cp - command)) {
|
||||
errorx(1, _("internal error, %s overflow"),
|
||||
"linux_audit_command()");
|
||||
}
|
||||
cp += n;
|
||||
*cp++ = ' ';
|
||||
}
|
||||
|
@@ -667,14 +667,14 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
(unsigned int)runas_pw->pw_gid;
|
||||
len = snprintf(cp, glsize - (cp - gid_list), "%u", egid);
|
||||
if (len < 0 || len >= glsize - (cp - gid_list))
|
||||
errorx(1, _("internal error, runas_groups overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "runas_groups");
|
||||
cp += len;
|
||||
for (i = 0; i < grlist->ngids; i++) {
|
||||
if (grlist->gids[i] != egid) {
|
||||
len = snprintf(cp, glsize - (cp - gid_list), ",%u",
|
||||
(unsigned int) grlist->gids[i]);
|
||||
if (len < 0 || len >= glsize - (cp - gid_list))
|
||||
errorx(1, _("internal error, runas_groups overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "runas_groups");
|
||||
cp += len;
|
||||
}
|
||||
}
|
||||
@@ -933,7 +933,7 @@ set_cmnd(void)
|
||||
for (to = user_args, av = NewArgv + 1; *av; av++) {
|
||||
n = strlcpy(to, *av, size - (to - user_args));
|
||||
if (n >= size - (to - user_args))
|
||||
errorx(1, _("internal error, set_cmnd() overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "set_cmnd()");
|
||||
to += n;
|
||||
*to++ = ' ';
|
||||
}
|
||||
|
@@ -250,7 +250,7 @@ main(int argc, char *argv[])
|
||||
for (to = user_args, from = argv; *from; from++) {
|
||||
n = strlcpy(to, *from, size - (to - user_args));
|
||||
if (n >= size - (to - user_args))
|
||||
errorx(1, _("internal error, init_vars() overflow"));
|
||||
errorx(1, _("internal error, %s overflow"), "init_vars()");
|
||||
to += n;
|
||||
*to++ = ' ';
|
||||
}
|
||||
|
Reference in New Issue
Block a user