Skip to content

lib: use checked arithmetic in string and path length calculations#285

Open
uwezkhan wants to merge 1 commit intodovecot:mainfrom
uwezkhan:checked-length-arithmetic
Open

lib: use checked arithmetic in string and path length calculations#285
uwezkhan wants to merge 1 commit intodovecot:mainfrom
uwezkhan:checked-length-arithmetic

Conversation

@uwezkhan
Copy link
Copy Markdown
Contributor

@uwezkhan uwezkhan commented May 2, 2026

Several core string and path utility helpers manually compute required
buffer sizes using unchecked length arithmetic such as pos + len + 1.

Replace these calculations with MALLOC_ADD/MALLOC_ADD3 so overflow
is detected explicitly before buffer growth calculations proceed.

This improves robustness of core helper routines and ensures oversized
length summations fail safely rather than relying on downstream
allocator assumptions.

Updated call sites include:

  • vstrconcat()
  • p_strarray_join_n()
  • path normalization / directory resolution helpers

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.

1 participant