Skip to content

Commit

Permalink
Check if auth_user is set.
Browse files Browse the repository at this point in the history
Fixes a crash if password packet appears before startup packet (#42).
  • Loading branch information
markokr committed Apr 8, 2015
1 parent 82c7b4d commit 74d6e5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ static bool handle_client_startup(PgSocket *client, PktHdr *pkt)
}
break;
case 'p': /* PasswordMessage */
/* too early */
if (!client->auth_user) {
disconnect_client(client, true, "client password pkt before startup packet");
return false;
}

/* haven't requested it */
if (cf_auth_type <= AUTH_TRUST) {
disconnect_client(client, true, "unrequested passwd pkt");
Expand Down

0 comments on commit 74d6e5f

Please sign in to comment.