AUDIT_VALUE_NEEDS_ENCODING(3)

πŸ’– AUDIT_VALUE_NEEDS_ENCODING(3) πŸ’–

ok bestie so this is a page from the Linux Audit API, and today's main character is audit_value_needs_encoding β€” she's the one who checks a string to see if it needs encoding. yes that's literally the whole job and she does it flawlessly, no notes ✨


✨ NAME ✨

audit_value_needs_encoding β€” check a string to see if it needs encoding πŸ•΅οΈβ™€οΈ


🌸 SYNOPSIS 🌸

#include <libaudit.h>

int audit_value_needs_encoding(const char *str, unsigned int size);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe. audit_value_needs_encoding() looks at size bytes starting from str and tells you whether that value has to be encoded before it gets logged in an audit name/value field. like, before it goes out into the world, does it need a little makeover first? πŸ’…

specifically β€” and this is the part you gotta remember β€” she's checking for:

  • a double-quote πŸ’€
  • any byte in the range 0x00 through 0x20
  • any byte in the range 0x7F through 0xFF

and just so we're clear, that 0x00 through 0x20 range is including the C0 control bytes and the plain old space. yeah. space counts. she's picky like that, and honestly? iconic. πŸ‘‘


πŸŽ€ the arguments πŸŽ€

  • str β€” the byte string you want checked. lowkey the important part: it does not have to be NUL-terminated, and it's totally fine if it has embedded NUL bytes in there. she's not scared of a \0 bestie. and if str is NULL? then encoding is not needed, simple as that. ✨
  • size β€” the number of bytes to check starting from str. that's it, that's the whole thing. πŸ”’

🌈 RETURN VALUE 🌈

  • 1 β†’ yep, encoding is needed πŸ’…
  • 0 β†’ nope, encoding is not needed 🫢

πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Steve Grubb πŸ’œ


fr fr, that's the whole page. go encode responsibly bestie 🧚

Red Hat Β· May 2026 β€” mwah, ty for reading, ily, bye!! πŸŽ€πŸ’–βœ¨