Fix integer truncation in frontend pnstrdup()

Поиск
Список
Период
Сортировка
Искать

Fix integer truncation in frontend pnstrdup()

От:
Chao Li <li.evan.chao@gmail.com>
Дата:
Вложения:
Hi,

While reading code during patch review, I noticed that the frontend pnstrdup() defined in fe_memutils.c uses an int len to store the string length returned by strnlen(). Since strnlen() returns a size_t, in theory this could cause integer truncation or signed overflow, though in practice it should be very unlikely to happen.

The backend pnstrdup() defined in mcxt.c doesn't have this problem. It keeps the string length in a Size.

The attached patch is a trivial fix for the frontend pnstrdup(), reusing the existing "Size size" variable to store the result of strnlen().

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/




Re: Fix integer truncation in frontend pnstrdup()

От:
David Rowley <dgrowleyml@gmail.com>
Дата:
On Tue, 20 Oct 2026 at 20:41, Chao Li  wrote:
> The attached patch is a trivial fix for the frontend pnstrdup(), reusing the existing "Size size" variable to store the result of strnlen().

I've pushed this to master only.

David


FAQ