# [PATCH] str_pad allows pad_length to be negative

- Thread: https://externals.io/message/31152
- Original archive: https://news-web.php.net/php.internals/31152
- Started by Mattias Bengtsson on 2007-07-21T19:57:31+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #31152 — Mattias Bengtsson — 2007-07-21T19:57:31+00:00

URL: https://externals.io/message/31152#31152

As stated in the manual for `str_pad()` "If the value of pad_length is
negative or less than the length of the input string, no padding takes
place.".

By using a very low negative value it is possible to bypass the check.

Please see attachment.

Cheers, Mattias Bengtsson

---

## #31184 — Jani Taskinen — 2007-07-23T13:28:38+00:00

URL: https://externals.io/message/31152#31184 · In reply to: #31152

Patch applied to both PHP_5_2 and HEAD. Thanks!

--Jani



> As stated in the manual for `str_pad()` "If the value of pad_length is
> negative or less than the length of the input string, no padding takes
> place.".
> 
> By using a very low negative value it is possible to bypass the check.
> 
> Please see attachment.
> 
> Cheers, Mattias Bengtsson
