/bin/dd/args.c r1.28

get_off(char *val)

Code:

num = strtoll(val, &expr, 0);
        if (num == LLONG_MAX)                   /* Overflow. */
                err(1, "%s", oper);
        if (expr == val)                        /* No digits. */
                errx(1, "%s: illegal numeric value", oper);

Incorrect checking of overflow.
Firstly, set errno to 0 before calling strtoll.
Secondly: check of errno == ERANGE. =>

errno = 0;
num = strtoll(val, &expr, 0);
if (errno == ERANGE && num == LLONG_MAX)                        /* Overflow. */
        err(1, "%s", oper);
if (expr == val)                        /* No digits. */
        errx(1, "%s: illegal numeric value", oper);


https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/bin/dd/args.c?rev=1.28


Reply via email to