{
uintmax_t val;
if (xstrtoumax (str + 1, nullptr, 10, &val, "") != LONGINT_OK
- || INTMAX_MAX < val)
+ || ckd_add (&p->repeat, val, 0))
{
error (EXIT_FAILURE, 0,
_("%s}: integer required between '{' and '}'"),
quote (global_argv[argnum]));
}
- p->repeat = val;
}
*end = '}';
{
uintmax_t tmp;
if (xstrtoumax (owner_name, nullptr, 0, &tmp, "") != LONGINT_OK
- || UID_T_MAX < tmp)
+ || ckd_add (&owner_id, tmp, 0))
error (EXIT_FAILURE, 0, _("invalid user %s"),
quoteaf (owner_name));
- owner_id = tmp;
}
else
owner_id = pw->pw_uid;
{
uintmax_t tmp;
if (xstrtoumax (group_name, nullptr, 0, &tmp, "") != LONGINT_OK
- || GID_T_MAX < tmp)
+ || ckd_add (&group_id, tmp, 0))
error (EXIT_FAILURE, 0, _("invalid group %s"),
quoteaf (group_name));
- group_id = tmp;
}
else
group_id = gr->gr_gid;
/* Okay, we have written "soff" bytes. */
- if (OFF_T_MAX - offset < soff)
+ if (ckd_add (&offset, offset, soff))
{
error (0, 0, _("%s: file too large"), qname);
other_error = true;
goto free_pattern_mem;
}
- offset += soff;
-
bool done = offset == size;
/* Time to print progress? */
enum strtol_error e = xstrtoumax (s, &suffix, 10, &n, "EgGkKmMPQRtTYZ");
/* The default unit is KiB. */
- if (e == LONGINT_OK && c_isdigit (suffix[-1]))
- {
- if (n <= UINTMAX_MAX / 1024)
- n *= 1024;
- else
- e = LONGINT_OVERFLOW;
- }
+ if (e == LONGINT_OK && c_isdigit (suffix[-1]) && ckd_mul (&n, n, 1024))
+ e = LONGINT_OVERFLOW;
/* A 'b' suffix means bytes; a '%' suffix means percent of memory. */
if (e == LONGINT_INVALID_SUFFIX_CHAR && c_isdigit (suffix[-1]) && ! suffix[1])
for (p = s->head->next; p; p = p->next)
{
count len = 0;
- count new_length;
switch (p->type)
{
any length greater than the maximum repeat count, in case the
length is later used to compute the repeat count for an
indefinite element. */
- new_length = length + len;
- if (! (length <= new_length && new_length <= REPEAT_COUNT_MAXIMUM))
+ if (ckd_add (&length, length, len) || REPEAT_COUNT_MAXIMUM < length)
error (EXIT_FAILURE, 0, _("too many characters in set"));
- length = new_length;
}
s->length = length;