Skip to content

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

Closed
uwezkhan wants to merge 1 commit into
dovecot:mainfrom
uwezkhan:checked-length-arithmetic
Closed

lib: use checked arithmetic in string and path length calculations#285
uwezkhan wants to merge 1 commit into
dovecot: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

@cmouse
Copy link
Copy Markdown
Contributor

cmouse commented May 22, 2026

merged as 651436a

@cmouse cmouse closed this May 22, 2026
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