Skip to content

Fix improper vsyslog detection and conditional compilation#574

Closed
lublog wants to merge 1 commit intotinyproxy:masterfrom
lublog:fix-vsyslog-detection
Closed

Fix improper vsyslog detection and conditional compilation#574
lublog wants to merge 1 commit intotinyproxy:masterfrom
lublog:fix-vsyslog-detection

Conversation

@lublog
Copy link
Copy Markdown

@lublog lublog commented May 1, 2025

Summary

Fix a build and behavior issue in log.c where vsyslog() is conditionally compiled using an incorrect macro: HAVE_VSYSLOG_H.

Problem

The current code checks for vsyslog() support using:

#ifdef HAVE_VSYSLOG_H
    vsyslog(level, fmt, args);

However, vsyslog.h does not exist in any standard C library. Since vsyslog() is not part of the POSIX standard, it should be detected using Autoconf via AC_CHECK_FUNCS, rather than relying on a non-existent header macro.

Fix

  • In configure.ac, modified the function checks from:

    AC_CHECK_FUNCS([strlcpy strlcat setgroups])

    to:

    AC_CHECK_FUNCS([strlcpy strlcat setgroups vsyslog])
  • In log.c, updated the conditional compilation to:

    #ifdef HAVE_VSYSLOG
        vsyslog(level, fmt, args);

@rofl0r rofl0r closed this in d62b7d2 May 1, 2025
@rofl0r
Copy link
Copy Markdown
Contributor

rofl0r commented May 1, 2025

good catch. since the unportable code trying to use it was unused anyway, i just went ahead and removed it instead. out of curiosity: is this PR and the issue text AI-generated?

@lublog
Copy link
Copy Markdown
Author

lublog commented May 1, 2025

I noticed this issue, but my English isn't very good. I was afraid my description might not be accurate enough, so I explained the problem to AI to help generate the proper expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants