From 6cdba03d38a71e58576dd2615dc6897bbfdb133d Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 25 Apr 2002 00:56:36 +0000 Subject: Fix password code to deal with new quoting code. --- src/backend/libpq/crypt.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/backend/libpq/crypt.c') diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 7c665300c8..304f557c31 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.45 2002/04/04 04:25:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.46 2002/04/25 00:56:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,18 +31,26 @@ int md5_crypt_verify(const Port *port, const char *user, const char *pgpass) { - char *passwd, - *valuntil, + char *passwd = NULL, + *valuntil = NULL, *crypt_pwd; int retval = STATUS_ERROR; List **line; - + List *token; + if ((line = get_user_line(user)) == NULL) return STATUS_ERROR; - passwd = lfirst(lnext(lnext(*line))); - valuntil = lfirst(lnext(lnext(lnext(*line)))); - + /* Skip over line number and username */ + token = lnext(lnext(*line)); + if (token) + { + passwd = lfirst(token); + token = lnext(token); + if (token) + valuntil = lfirst(token); + } + if (passwd == NULL || *passwd == '\0') { if (passwd) @@ -120,7 +128,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) AbsoluteTime vuntil, current; - if (!valuntil || strcmp(valuntil, "\\N") == 0) + if (!valuntil) vuntil = INVALID_ABSTIME; else vuntil = DatumGetAbsoluteTime(DirectFunctionCall1(nabstimein, -- cgit v1.2.1