libcanlock(3)

🌸 libcanlock(3) β€” the cl_clear_secret glow-up πŸ’…

okay bestie, so we're deep in libcanlock 3.3.3 territory and this page is all about wiping secrets out of memory like the FBI is at the door πŸ•΅οΈβ€β™€οΈβœ¨ Strap in.


✨ NAME ✨

cl_clear_secret β€” overwrites secret data in memory, using libcanlock 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <libcanlock-3/canlock.h>

int cl_clear_secret(void *sec, size_t sec_size,
                    size_t buf_size);

like, that's the whole vibe. two size_t's and a void pointer, no cap πŸ’€


πŸ’– DESCRIPTION πŸ’–

so the cl_clear_secret() function tries to overwrite sec_size bytes of memory, starting at whatever address sec points to. it's giving "shred the evidence" energy πŸ”₯

here's the catch tho β€” buf_size must be set to the size of the whole buffer. don't skip that, fr fr, it's literally required.

and now for the ✨implementation drama✨ (this part is super important, bestie, pay attention):

  • the C standard provides memset_explicit() since C23. that one is preferred, if available. it's the main character πŸ‘‘
  • the C standard provides memset_s() since C11, but only in the optional Annex K. it gets called with both length values, if available.
  • otherwise, nonportable functions like NetBSD explicit_memset() get used, if available.
  • and if nothing better is available? we fall back to a plain call to memset() instead. πŸ™ˆ
⚠️ okay this is the scary bit: with that memset() fallback, the compiler may translate this attempt to NOP β€” like, it might just... not do it 😭. In that case, a positive value is returned as a warning. so like, check your return values, bestie!!

⭐ RETURN VALUE ⭐

  • 0 β€” success, we ate, everything worked πŸ’…
  • negative values β€” error. it's giving "something went wrong"
  • positive values β€” warning. like, "technically fine but look out"

the value -1 is returned if the parameter sec is NULL, or if sec_size is greater than buf_size 🚩

the value 1 indicates missing support for explicit memory access from the system 😬


πŸ¦‹ AUTHORS πŸ¦‹

Michael Baeuerle 🌟 (the icon behind it all)


🌈 REPORTING BUGS 🌈

found a bug? don't be shy, report it to <mailto:michael.baeuerle@gmx.net> πŸ’Œ


🧚 STANDARDS 🧚

libcanlock tries to comply with the following standards, and honestly? we stan the effort:


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, bestie!! πŸ“ the manual itself is dated 2026-07-06 and comes from the Unix manual set, from libcanlock 3.3.3 β€” go forth and clear those secrets πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from