ERR_GET_LIB(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’– ERR_GET_LIB(3): OpenSSL error-code detective vibes πŸ’–

okay so bestie, this is the ERR_GET_LIB(3) page from the Library Functions Manual, section 3 β€” and it’s literally all about pulling apart OpenSSL error codes so you can see what actually went down. ✨


🌸 NAME 🌸

ERR_GET_LIB, ERR_GET_FUNC, ERR_GET_REASON, ERR_FATAL_ERROR β€” get library, function and reason codes for OpenSSL errors.


πŸŽ€ SYNOPSIS πŸŽ€

library β€œlibcrypto” #include <openssl/err.h>

int
ERR_GET_LIB(unsigned long e);

int
ERR_GET_FUNC(unsigned long e);

int
ERR_GET_REASON(unsigned long e);

int
ERR_FATAL_ERROR(unsigned long e);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the error code you get back from ERR_get_error(3) is made of three little pieces: a library number, a function code, and a reason code. ERR_GET_LIB(), ERR_GET_FUNC(), and ERR_GET_REASON() are the functions that extract those pieces for you. Slay. πŸ’…

The library number and function code tell you where the error happened, while the reason code is the info about what went wrong. It’s giving β€œwho, what, where” but for errors. πŸ‘‘

Every sub-library of OpenSSL has its own unique library number; function codes and reason codes are unique within each sub-library. Important note, bestie: different libraries may use the same value to signal different functions and reasons. So don’t just assume the number means the same thing everywhere. πŸ™ˆ

ERR_R_* reason codes such as ERR_R_MALLOC_FAILURE are globally unique. But when you’re checking for sub-library specific reason codes, be sure to also compare the library number. That part is lowkey essential.

ERR_FATAL_ERROR() tells you whether a given error code is a fatal error. πŸ’€

And plot twist: these functions are implemented as macros. Not full-on functions, bestie β€” macros. ✨


🌈 RETURN VALUES 🌈

  • ERR_GET_LIB(), ERR_GET_FUNC(), and ERR_GET_REASON() return the library number, function code, and reason code, respectively. Cute and specific. πŸŽ€
  • ERR_FATAL_ERROR() returns non-zero if the error is fatal, or 0 otherwise. Periodt. πŸ’…

🫢 SEE ALSO 🫢


πŸ‘‘ HISTORY πŸ‘‘

ERR_GET_LIB(), ERR_GET_FUNC(), ERR_GET_REASON(), and ERR_FATAL_ERROR() first appeared in SSLeay 0.4.4 and have been available since OpenBSD 2.4. Iconic longevity behavior, fr fr. ⭐


xoxo, Debian πŸ’– June 8, 2025 β€” ERR_GET_LIB(3), signing off 🫢

πŸ“¦ where this page comes from