News for hackers. Stuff that matters.
Re:Sshole by creata on Thursday November 05, 2026 @01:26PM (#50382560)
I don't think that's the problem. The man page for crypt clearly says that erroring is a possibility and that it's not standardized how it errors:

> The behavior of crypt on errors isn't well standardized. Some implementations simply can't fail (except by crashing the program), others return a null pointer or a fixed string. Most implementations don't set errno, but some do. POSIX specifies returning a null pointer and setting errno, but it defines only one possible error, ENOSYS, in the case where crypt is not supported at all.

In my opinion the problem is that the behavior of crypt is underspecified - it isn't even specified how it signals failure, which is shocking.

You can't check errno to see if there was a failure because, as the man page says, the value of errno is unspecified when crypt succeeds.

Re:Sshole by throwaway2037 on Friday November 06, 2026 @12:51AM (#50388678)

    > You can't check errno to see if there was a failure because, as the man page says, the value of errno is unspecified when crypt succeeds.
You can set errno to zero before the call. If the value is non-zero after the call, that is a good heuristic for failure.
Re:Sshole by zbentley on Friday November 06, 2026 @02:44AM (#50389350)
...unless crypt() is one of the many, many functions which themselves internally call functions that set errno. In which case you can't be sure.