Skip to content

volk_prefs: fix buffer overflows in config path and preferences#17

Open
mtibbits wants to merge 1 commit into
fix/792-xdg-config-pathfrom
fix/14-volk-prefs-buffer-overflow
Open

volk_prefs: fix buffer overflows in config path and preferences#17
mtibbits wants to merge 1 commit into
fix/792-xdg-config-pathfrom
fix/14-volk-prefs-buffer-overflow

Conversation

@mtibbits
Copy link
Copy Markdown
Owner

@mtibbits mtibbits commented Apr 5, 2026

Depends on #11


Config path construction in volk_get_config_path() used strncpy/strcat
pairs that can overflow when environment variables (VOLK_CONFIGPATH, HOME,
APPDATA) exceed 495 characters. volk_load_preferences() reads config
tokens with sscanf without width limits, overflowing the 128-byte
volk_arch_pref_t fields on crafted config files.

Replace strncpy/strcat with snprintf using an explicit size constant
(1024, matching all existing callers). Add %127s width limits to sscanf.
Upsize the local path buffer in volk_load_preferences to match.

The /etc path block is unchanged — its source is a 4-char literal that
cannot overflow.

Fixes #14

@mtibbits mtibbits force-pushed the fix/14-volk-prefs-buffer-overflow branch 2 times, most recently from 9dcfee2 to 9af9ae1 Compare April 14, 2026 04:43
@mtibbits mtibbits changed the base branch from main to fix/792-xdg-config-path April 25, 2026 03:00
Path construction in volk_get_config_path() used strncpy/strcat pairs
that could overflow when environment variables (VOLK_CONFIGPATH, HOME,
APPDATA) exceeded 495 characters. Replace with snprintf using an
explicit size constant. Also add width limits to sscanf in
volk_load_preferences() to prevent config file tokens from overflowing
the 128-byte volk_arch_pref_t fields.

Fixes #14

Signed-off-by: Matthew Tibbits <894144+mtibbits@users.noreply.github.com>
@mtibbits mtibbits force-pushed the fix/792-xdg-config-path branch from d2a45c7 to a19a383 Compare April 27, 2026 00:11
@mtibbits mtibbits force-pushed the fix/14-volk-prefs-buffer-overflow branch from 9af9ae1 to f5dfe5b Compare April 27, 2026 00:11
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.

volk_prefs: buffer overflow in config path construction

1 participant