do_tzset() did't always reset the DST transition rules r0 and r1. That means the rules from older TZ settings could leak into newer ones.
POSIX allows ttyname(_r) and isatty to return EBADF if passed file descriptor is invalid. maintainer's note: these are optional ("may fail") errors, but it's non-conforming for ttyname_r to return ENOTTY when it failed for a different reason.