Skip to content

httpd: fix crash in rfbHttpShutdownSockets when httpDir is NULL#723

Open
ivanxgb wants to merge 1 commit into
LibVNC:masterfrom
ivanxgb:fix/http-shutdown-crash-704
Open

httpd: fix crash in rfbHttpShutdownSockets when httpDir is NULL#723
ivanxgb wants to merge 1 commit into
LibVNC:masterfrom
ivanxgb:fix/http-shutdown-crash-704

Conversation

@ivanxgb
Copy link
Copy Markdown

@ivanxgb ivanxgb commented May 21, 2026

Summary

This Pull Request resolves a crash (segmentation fault / access violation) that occurs in if no HTTP directory is configured () and no client has connected during the server's lifecycle (fixes #704).

Cause

In , the HTTP socket initialization returns early if is . Because of this, the mutexes of the file-static structure (, , ) are never initialized via .
However, during shutdown in , these mutexes are unconditionally locked, unlocked, and destroyed, leading to an immediate segmentation fault.

Fix

We introduced a file-static boolean flag in to track whether these client-related mutexes have been successfully initialized. The shutdown operations are now safely wrapped in a conditional check:

Verification & Testing

The fix has been compiled and verified inside a secure sandbox container on a Debian Bookworm VPS, utilizing the following minimal reproduction program:

  • Pre-patch: Program terminates with a Segmentation Fault (Access Violation).
  • Post-patch: Program runs and shuts down cleanly with Exit Code 0.

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.

Crash on rfbShutdownServer() when no client has connected

1 participant