Skip to content

Commit

Permalink
wsutil: Downgrade severity of ws_returh.h macros
Browse files Browse the repository at this point in the history
Downgrade the severity of this issue. Even though it is critical
in the sense that it is a (recoverable) programming error, by
breaking the contract for the function arguments, for practical
purposes we don't want to constantly trip our fuzzers with this
issue (running with a fatal critical level) so downgrade the
ws_return.h severity to "info".

At the same time use a dedicated log domain to the debugging
purpose can be fulfilled by setting the "InvalidArg" domain
as fatal.

Remove the duplicated function name from the output while at it.
  • Loading branch information
randstr committed Apr 16, 2023
1 parent 20f6197 commit 152e5a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/ws_log_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#define LOG_DOMAIN_MMDB "MaxMindDB"

#define LOG_DOMAIN_EINVAL "InvalidArg"

/*
* Ascending order by priority needs to be maintained. Higher priorities have
* higher values.
Expand Down
9 changes: 6 additions & 3 deletions wsutil/ws_return.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
* appropriate. And it should only be used if failing the condition
* doesn't necessarily lead to an inconsistent state for the program.
*
* It is possible to set the fatal log level to "critical" to abort
* It is possible to set the fatal log domain to "InvalidArg" to abort
* execution for debugging purposes, if one of these checks fail.
*/

#define ws_warn_zero_len(var) ws_critical("Zero length '%s' passed to %s()", var, __func__)
#define ws_warn_badarg(...) \
ws_log_full(LOG_DOMAIN_EINVAL, LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)

#define ws_warn_null_ptr(var) ws_critical("Null pointer '%s' passed to %s()", var, __func__)
#define ws_warn_zero_len(var) ws_warn_badarg("Zero length argument '%s' is invalid", var)

#define ws_warn_null_ptr(var) ws_warn_badarg("Null pointer argument '%s' is invalid", var)


#define ws_return_str_if_zero(scope, len) \
Expand Down

0 comments on commit 152e5a5

Please sign in to comment.