diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-10-20 13:54:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-10-20 13:54:08 +0000 |
commit | 8130cbce962d8418e7ddddb1bcc2767978ea4787 (patch) | |
tree | f3ce94772fba519abd098ac04dccf161746f8394 /src | |
parent | a5bd1d357a417679421bd2deb031a644b489bdfe (diff) | |
download | postgresql-8130cbce962d8418e7ddddb1bcc2767978ea4787.tar.gz postgresql-8130cbce962d8418e7ddddb1bcc2767978ea4787.zip |
Clean up md5.c to make it clearer that it is a frontend-and-backend
module. Don't rely on backend palloc semantics; in fact, best to not
use palloc at all, rather than #define'ing it to malloc, because that
just encourages errors of omission. Bug spotted by Volkan YAZICI,
but I went further than he did to fix it.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/libpq/md5.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index 753cba772e1..99e86cba5cf 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -14,24 +14,13 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.30 2005/10/17 16:24:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.31 2005/10/20 13:54:08 tgl Exp $ */ +/* This is intended to be used in both frontend and backend, so use c.h */ +#include "c.h" -#if ! defined(FRONTEND) -#include "postgres.h" #include "libpq/crypt.h" -#endif - -#ifdef FRONTEND -#include "postgres_fe.h" -#include "libpq/crypt.h" - -#undef palloc -#define palloc malloc -#undef pfree -#define pfree free -#endif /* FRONTEND */ /* @@ -325,9 +314,12 @@ pg_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, char *buf) { size_t passwd_len = strlen(passwd); - char *crypt_buf = palloc(passwd_len + salt_len); + char *crypt_buf = malloc(passwd_len + salt_len); bool ret; + if (!crypt_buf) + return false; + /* * Place salt at the end because it may be known by users trying to crack * the MD5 output. @@ -338,7 +330,7 @@ pg_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, strcpy(buf, "md5"); ret = pg_md5_hash(crypt_buf, passwd_len + salt_len, buf + 3); - pfree(crypt_buf); + free(crypt_buf); return ret; } |