some SCRAM read_any_attr() confusion

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема some SCRAM read_any_attr() confusion
Дата
Msg-id 2fb8a15b-de35-682d-a77b-edcc9c52fa12@2ndquadrant.com
обсуждение исходный текст
Ответы Re: some SCRAM read_any_attr() confusion  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
I was a bit confused by some of the comments around the SCRAM function
read_any_attr(), used to skip over extensions.

The comment "Returns NULL if there is attribute.", besides being
strangely worded, appears to be wrong anyway, because the function never
returns NULL.

This lead me to wonder how this loop would terminate if there is no "p"
attribute in the message:

    /* ignore optional extensions */
    do
    {
        proof = p - 1;
        value = read_any_attr(&p, &attr);
    } while (attr != 'p');

What actually happens is

ERROR:  malformed SCRAM message
DETAIL:  Attribute expected, but found invalid character "0x00".

which serves the purpose but was probably not quite intended that way.

I propose the attached patch to clean this up a bit, with better
comments and a better error message.

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

Вложения

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

Предыдущее
От: Binguo Bao
Дата:
Сообщение: Re: [proposal] de-TOAST'ing using a iterator
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: some SCRAM read_any_attr() confusion