Fix password code to deal with new quoting code.
authorBruce Momjian <[email protected]>
Thu, 25 Apr 2002 00:56:36 +0000 (00:56 +0000)
committerBruce Momjian <[email protected]>
Thu, 25 Apr 2002 00:56:36 +0000 (00:56 +0000)
src/backend/libpq/crypt.c
src/backend/libpq/hba.c

index 0bbdfb9af2c75dafc804860dd9f6fd07cfa9d4d5..4bccd5a4e12f8fe37979d20cbfac55cc48d19430 100644 (file)
 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,
index 85d77549faab8dd23894e93ad4349365f4f73550..93452f7a18e5d174a0617488ba92411fa1a7da6b 100644 (file)
@@ -109,9 +109,6 @@ next_token(FILE *fp, char *buf, const int bufsz)
                while (c != EOF && c != '\n' &&
                           (!isblank(c) || in_quote == true))
                {
-                       if (c == '"')
-                               in_quote = !in_quote;
-
                        /* skip comments to EOL */
                        if (c == '#' && !in_quote)
                        {
@@ -138,11 +135,14 @@ next_token(FILE *fp, char *buf, const int bufsz)
                                break;
 
                        /* Literal double-quote is two double-quotes */
-                       if (c == '"')
+                       if (in_quote && c == '"')
                                was_quote = !was_quote;
                        else
                                was_quote = false;
 
+                       if (c == '"')
+                               in_quote = !in_quote;
+
                        c = getc(fp);
                }