I have a patch on tech@ to raise the setitimer(2) input limit to
UINT_MAX seconds:

https://marc.info/?l=openbsd-tech&m=162343190813127&w=2

After that is committed, I'm unclear whether alarm(3) can fail anymore
on OpenBSD.  The only remaining plausible failure case I can see is
EFAULT.  But I'm unsure if that's possible.  Can we get an EFAULT if
both arguments point to stack memory?

For reference, this is the alarm(3) code in its entirety:

unsigned int
alarm(unsigned int secs)
{
        struct itimerval it, oitv;
        struct itimerval *itp = ⁢

        timerclear(&itp->it_interval);
        itp->it_value.tv_sec = secs;
        itp->it_value.tv_usec = 0;
        if (setitimer(ITIMER_REAL, itp, &oitv) == -1)
                return ((unsigned int) -1);
        if (oitv.it_value.tv_usec)
                oitv.it_value.tv_sec++;
        return (oitv.it_value.tv_sec);
}

If EFAULT is possible here, what is the "right" behavior if that were
to happen?  The standard specifies no errors.  The other BSDs (like
us) return -1, which becomes UINT_MAX.

Reply via email to