diff options
Diffstat (limited to 'contrib/pgcrypto/pgcrypto.c')
-rw-r--r-- | contrib/pgcrypto/pgcrypto.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index 6efc044b007..f28f960ad05 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -26,13 +26,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.15 2003/11/29 22:39:28 pgsql Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.16 2004/05/07 00:24:57 tgl Exp $ */ -#include <postgres.h> -#include <fmgr.h> +#include "postgres.h" + #include <ctype.h> +#include "fmgr.h" +#include "parser/scansup.h" + #include "px.h" #include "px-crypt.h" #include "pgcrypto.h" @@ -554,26 +557,12 @@ find_provider(text *name, char *desc, int silent) { void *res; - char buf[PX_MAX_NAMELEN + 1], - *p; - unsigned len; - unsigned i; + char *buf; int err; - len = VARSIZE(name) - VARHDRSZ; - if (len > PX_MAX_NAMELEN) - { - if (silent) - return NULL; - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("%s type does not exist (name too long)", desc))); - } - - p = VARDATA(name); - for (i = 0; i < len; i++) - buf[i] = tolower((unsigned char) p[i]); - buf[len] = 0; + buf = downcase_truncate_identifier(VARDATA(name), + VARSIZE(name) - VARHDRSZ, + false); err = provider_lookup(buf, &res); @@ -582,5 +571,7 @@ find_provider(text *name, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("%s type does not exist: \"%s\"", desc, buf))); + pfree(buf); + return err ? NULL : res; } |