From: Tom Lane Date: Thu, 24 Jul 2008 17:52:02 +0000 (+0000) Subject: Fix parsing of LDAP URLs so it doesn't reject spaces in the "suffix" part. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=a20f9ee9b0dacd28edc6961fac48cf318bafae09;p=users%2Fbernd%2Fpostgres.git Fix parsing of LDAP URLs so it doesn't reject spaces in the "suffix" part. Per report from César Miguel Oliveira Alves. --- diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index a1ca095eea..a2b0437714 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -1399,8 +1399,14 @@ CheckLDAPAuth(Port *port) } /* - * Crack the LDAP url. We do a very trivial parse.. + * Crack the LDAP url. We do a very trivial parse: + * * ldap[s]://[:]/[;prefix[;suffix]] + * + * This code originally used "%127s" for the suffix, but that doesn't + * work for embedded whitespace. We know that tokens formed by + * hba.c won't include newlines, so we can use a "not newline" scanset + * instead. */ server[0] = '\0'; @@ -1410,13 +1416,13 @@ CheckLDAPAuth(Port *port) /* ldap, including port number */ r = sscanf(port->auth_arg, - "ldap://%127[^:]:%d/%127[^;];%127[^;];%127s", + "ldap://%127[^:]:%d/%127[^;];%127[^;];%127[^\n]", server, &ldapport, basedn, prefix, suffix); if (r < 3) { /* ldaps, including port number */ r = sscanf(port->auth_arg, - "ldaps://%127[^:]:%d/%127[^;];%127[^;];%127s", + "ldaps://%127[^:]:%d/%127[^;];%127[^;];%127[^\n]", server, &ldapport, basedn, prefix, suffix); if (r >= 3) ssl = true; @@ -1425,14 +1431,14 @@ CheckLDAPAuth(Port *port) { /* ldap, no port number */ r = sscanf(port->auth_arg, - "ldap://%127[^/]/%127[^;];%127[^;];%127s", + "ldap://%127[^/]/%127[^;];%127[^;];%127[^\n]", server, basedn, prefix, suffix); } if (r < 2) { /* ldaps, no port number */ r = sscanf(port->auth_arg, - "ldaps://%127[^/]/%127[^;];%127[^;];%127s", + "ldaps://%127[^/]/%127[^;];%127[^;];%127[^\n]", server, basedn, prefix, suffix); if (r >= 2) ssl = true;