]> granicus.if.org Git - pgbouncer/commitdiff
Fix the quoting fix.
authorMarko Kreen <markokr@gmail.com>
Thu, 9 Sep 2010 11:10:31 +0000 (11:10 +0000)
committerMarko Kreen <markokr@gmail.com>
Fri, 10 Sep 2010 09:46:25 +0000 (12:46 +0300)
If we treat "" as special, we need to know
whether we are in quoted string or not.

Otherwise empty field ("") throws the parser off.

src/loader.c

index 0960d0fc53390babd9315df34e18e3f7dffce45f..0f8ce67403e116cf68dc53e625c72cc1e9768563 100644 (file)
@@ -391,12 +391,12 @@ void parse_database(char *name, char *connstr)
  */
 
 /* find next " in string, skipping escaped ones */
-static char *find_quote(char *p)
+static char *find_quote(char *p, bool start)
 {
 loop:
        while (*p && *p != '"')
                p++;
-       if (p[0] == '"' && p[1] == '"') {
+       if (p[0] == '"' && p[1] == '"' && !start) {
                p += 2;
                goto loop;
        }
@@ -502,7 +502,7 @@ bool load_auth_file(const char *fn)
                        break;
                }
                user = ++p;
-               p = find_quote(p);
+               p = find_quote(p, false);
                if (*p != '"') {
                        log_error("broken auth file");
                        break;
@@ -514,13 +514,13 @@ bool load_auth_file(const char *fn)
                *p++ = 0; /* tag username end */
                
                /* get password */
-               p = find_quote(p);
+               p = find_quote(p, true);
                if (*p != '"') {
                        log_error("broken auth file");
                        break;
                }
                password = ++p;
-               p = find_quote(p);
+               p = find_quote(p, false);
                if (*p != '"') {
                        log_error("broken auth file");
                        break;