const char *value,
unsigned int multiplier)
{
- struct rlimit rlim;
- rlim_t limit;
+ char *endptr;
+ long l;
+ rlim_t limit;
+ struct rlimit rlim;
/* The "-" is special, not belonging to a strange negative limit.
* It is infinity, in a controlled way.
* Also, we are limited to base 10 here (hex numbers will not
* work with the limit string parser as is anyway)
*/
- char *endptr;
- long longlimit = strtol (value, &endptr, 10);
+ l = strtol(value, &endptr, 10);
if (value == endptr) {
/* No argument at all. No-op.
*/
return 0;
}
- longlimit *= multiplier;
- limit = longlimit;
- if (longlimit != limit)
- {
+ if (__builtin_mul_overflow(l, multiplier, &limit)) {
/* FIXME: Again, silent error handling...
* Wouldn't screaming make more sense?
*/