Skip to content

uvhttp_error_helpers.c ​

Functions ​

contains_sensitive_info(const char *str) ​

Return Type: int

uvhttp_handle_memory_failure(const char *context, void(*cleanup_func)(void *), void *cleanup_data) ​

Return Type: void

Handle memory allocation failure.

Parameters:

  • context: Description of the context where failure occurred
  • cleanup_func: Cleanup function pointer (can be NULL)
  • cleanup_data: Argument to pass to cleanup function

Note: Logs error and optionally calls cleanup function Note: Useful for handling out-of-memory situations

uvhttp_handle_write_error(uv_write_t *req, int status, const char *context) ​

Return Type: void

Handle write operation error.

Parameters:

  • req: Write request that failed
  • status: Status code from uv_write callback
  • context: Description of the context where error occurred

Note: Logs error with context information Note: Closes connection on fatal errors

uvhttp_log_safe_error(int error_code, const char *context, const char *user_msg) ​

Return Type: void

Log error safely (avoid sensitive information leakage)

Parameters:

  • error_code: Error code to log
  • context: Description of the context
  • user_msg: User-provided message

Note: Filters sensitive information from error messages Note: Prevents leakage of paths, credentials, etc.

uvhttp_sanitize_error_message(const char *message, char *safe_buffer, size_t buffer_size) ​

Sanitize error message (filter sensitive information)

Parameters:

  • message: Original error message
  • safe_buffer: Output buffer for sanitized message
  • buffer_size: Size of output buffer

Returns: uvhttp_error_t UVHTTP_OK on success, error code otherwise

Note: Removes or masks sensitive information like paths, credentials Note: Ensures safe_buffer is null-terminated

Released under MIT License