← Back to context

Comment by api

2 days ago

TBH that sounds like a straight up bug in that it deviates dangerously from the spec.

The spec only defines a single error state - ENOSYS, that is basically only for systems that don't implement crypt at all.

Error handling is underspecified. The spec doesn't give you enough well-defined behaviour, meaning everyone lists pages of error-handling extensions they have added.

Which is notable because musl is more known for adhering to the spec to the point where they break programs that assume nonstandard behavior.

  • > adhering to the spec

    Pedantic, but more "author's understanding of the spec" which isn't always correct.

    > assume nonstandard behavior

    I go back and forth on this one (spec vs standard behavior). It feels like at some point the most widely used impl -is- the spec, as we've seen in other places (web standards).

    • To the best of my knowledge, only OpenBSD and Fedora have a crypt(3) that returns NULL. Everybody else returns a string starting with "*" on error.

      For example on Debian the manpage says:

      > Upon error, crypt_r, crypt_rn, and crypt_ra write an _invalid_ hash to the output field of their _data_ argument, and crypt writes an invalid hash to its static storage area. This string will be shorter than 13 characters, will begin with a ‘*’, and will not compare equal to _setting_.