ERR: refactor global error codes
authorRichard Levitte <levitte@openssl.org>
Mon, 29 Jun 2020 10:08:27 +0000 (12:08 +0200)
committerRichard Levitte <levitte@openssl.org>
Sun, 5 Jul 2020 19:13:03 +0000 (21:13 +0200)
commit163b2bcd8b2e5cd149dfc8dce1ca096805559379
treed62a1561c421631050de445b65ca63816a8bb820
parentdd76b90ef6cf9bd344c9a6cd0de536a734d1b6a3
ERR: refactor global error codes

Some ERR_R_ codes overlapped other ERR_R_ codes:

- ERR_R_BUF_LIB vs ERR_R_PASSED_INVALID_ARGUMENT
- ERR_R_DSA_LIB vs ERR_R_INTERRUPTED_OR_CANCELLED

Looking back at history, this was originally not an issue, because
the ERR_R_ codes that weren't ERR_LIB_ aliases had bit 2**6 set.
However, new codes without that bit came in, and we got the overlap
that is mentioned above.

To get rid of the overlap, we repartition the codes as follows:

- ERR_R_{name}_LIB that are aliases for ERR_LIB_{name} are confined to
  the range 1..63.
- Other ERR_R_ codes are confined to 64..99

We also expand the reason codes to 24 bits of data, where the 4 top
bits are for reason code flags.  We also allocate a "fatal" flag
ERR_RFLAG_FATAL.  The reason code ERR_R_FATAL stops acting as a flag,
but is coded in such a way that it still serves as one for code that
happens to use it as such.

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/12343)
include/openssl/err.h