Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb1f289

Browse files
committed
Clean up some SCRAM attribute processing
Correct the comment for read_any_attr(). Give a clearer error messagewhen parsing at the end of the string, when the client-final-messagedoes not contain a "p" attribute (for some reason).Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://www.postgresql.org/message-id/flat/2fb8a15b-de35-682d-a77b-edcc9c52fa12%402ndquadrant.com
1 parentf8cf524 commitdb1f289

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎src/backend/libpq/auth-scram.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ sanitize_str(const char *s)
790790
/*
791791
* Read the next attribute and value in a SCRAM exchange message.
792792
*
793-
* Returns NULL if there is attribute.
793+
* The attribute character is set in *attr_p, the attribute value is the
794+
* return value.
794795
*/
795796
staticchar*
796797
read_any_attr(char**input,char*attr_p)
@@ -799,6 +800,12 @@ read_any_attr(char **input, char *attr_p)
799800
char*end;
800801
charattr=*begin;
801802

803+
if (attr=='\0')
804+
ereport(ERROR,
805+
(errcode(ERRCODE_PROTOCOL_VIOLATION),
806+
errmsg("malformed SCRAM message"),
807+
errdetail("Attribute expected, but found end of string.")));
808+
802809
/*------
803810
* attr-val = ALPHA "=" value
804811
* ;; Generic syntax of any attribute sent
@@ -1298,7 +1305,7 @@ read_client_final_message(scram_state *state, const char *input)
12981305

12991306
state->client_final_nonce=read_attr_value(&p,'r');
13001307

1301-
/* ignore optional extensions */
1308+
/* ignore optional extensions, read until we find "p" attribute */
13021309
do
13031310
{
13041311
proof=p-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp