]> granicus.if.org Git - pgbouncer/commitdiff
Check if auth_user is set.
authorMarko Kreen <markokr@gmail.com>
Wed, 8 Apr 2015 06:22:55 +0000 (09:22 +0300)
committerMarko Kreen <markokr@gmail.com>
Wed, 8 Apr 2015 06:22:55 +0000 (09:22 +0300)
Fixes a crash if password packet appears before startup packet (#42).

src/client.c

index 275fd1aaa675fa5694c8452bd40610a1a4918c9d..49b262445a1ca126783686963669899e073ab5b4 100644 (file)
@@ -39,6 +39,12 @@ static bool check_client_passwd(PgSocket *client, const char *passwd)
        const char *correct;
        PgUser *user = client->auth_user;
 
+       /* auth_user may be missing */
+       if (!user) {
+               slog_error(client, "Password packet before auth packet?");
+               return false;
+       }
+
        /* disallow empty passwords */
        if (!*passwd || !*user->passwd)
                return false;