pgsql: Fix several one-byte buffer over-reads in to_number

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема pgsql: Fix several one-byte buffer over-reads in to_number
Дата
Msg-id E1bWmJV-00083U-Gm@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Fix several one-byte buffer over-reads in to_number
Список pgsql-committers
Fix several one-byte buffer over-reads in to_number

Several places in NUM_numpart_from_char(), which is called from the SQL
function to_number(text, text), could accidentally read one byte past
the end of the input buffer (which comes from the input text datum and
is not null-terminated).

1. One leading space character would be skipped, but there was no check
   that the input was at least one byte long.  This does not happen in
   practice, but for defensiveness, add a check anyway.

2. Commit 4a3a1e2cf apparently accidentally doubled that code that skips
   one space character (so that two spaces might be skipped), but there
   was no overflow check before skipping the second byte.  Fix by
   removing that duplicate code.

3. A logic error would allow a one-byte over-read when looking for a
   trailing sign (S) placeholder.

In each case, the extra byte cannot be read out directly, but looking at
it might cause a crash.

The third item was discovered by Piotr Stefaniak, the first two were
found and analyzed by Tom Lane and Peter Eisentraut.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9a46324fd46506c86b190d3163902ed90072c53c

Modified Files
--------------
src/backend/utils/adt/formatting.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Fix several one-byte buffer over-reads in to_number
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Fix several one-byte buffer over-reads in to_number