Re: [HACKERS] Code quality issues in ICU patch

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: [HACKERS] Code quality issues in ICU patch
Дата
Msg-id 3bd750fc-27da-ffbd-825c-313f538bcdfd@2ndquadrant.com
обсуждение исходный текст
Ответ на [HACKERS] Code quality issues in ICU patch  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] Code quality issues in ICU patch  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] Code quality issues in ICU patch  (Noah Misch <noah@leadboat.com>)
Список pgsql-hackers
On 6/23/17 12:31, Tom Lane wrote:
> icu_to_uchar() and icu_from_uchar(), and perhaps other places, are
> touchingly naive about integer overflow hazards in buffer size
> calculations.  I call particular attention to this bit in
> icu_from_uchar():
> 
>     len_result = UCNV_GET_MAX_BYTES_FOR_STRING(len_uchar, ucnv_getMaxCharSize(icu_converter));
> 
> The ICU man pages say that that macro is defined as
> 
> #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize)     (((int32_t)(length)+10)*(int32_t)(maxCharSize))
> 
> which means that getting this to overflow (resulting in
> probably-exploitable memory overruns) would be about as hard as taking
> candy from a baby.

Here is a patch that should address this.

(I don't think the overruns were exploitable.  You'd just get a buffer
overflow error from the ucnv_* function.)

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: [HACKERS] Fix a typo in snapmgr.c
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: [HACKERS] Causal reads take II