mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Revert error handling improvements for cryptohashes
This reverts commitsab27df2
,af8d530
and3a0cced
, that introduced pg_cryptohash_error(). In order to make the core code able to pass down the new error types that this introduced, some of the MD5-related routines had to be reworked, causing an ABI breakage, but we found that some external extensions rely on them. Maintaining compatibility outweights the error report benefits, so just revert the change in v14. Reported-by: Laurenz Albe Discussion: https://postgr.es/m/9f0c0a96d28cf14fc87296bbe67061c14eb53ae8.camel@cybertec.at
This commit is contained in:
@ -74,7 +74,7 @@ check_password(const char *username,
|
||||
*
|
||||
* We only check for username = password.
|
||||
*/
|
||||
const char *logdetail = NULL;
|
||||
char *logdetail;
|
||||
|
||||
if (plain_crypt_verify(username, shadow_pass, username, &logdetail) == STATUS_OK)
|
||||
ereport(ERROR,
|
||||
|
@ -101,8 +101,7 @@ int_sha2_update(PX_MD *h, const uint8 *data, unsigned dlen)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_update(ctx, data, dlen) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "SHA2",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not update %s context", "SHA2");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -111,8 +110,7 @@ int_sha2_reset(PX_MD *h)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_init(ctx) < 0)
|
||||
elog(ERROR, "could not initialize %s context: %s", "SHA2",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not initialize %s context", "SHA2");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -121,8 +119,7 @@ int_sha2_finish(PX_MD *h, uint8 *dst)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_final(ctx, dst, h->result_size(h)) < 0)
|
||||
elog(ERROR, "could not finalize %s context: %s", "SHA2",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not finalize %s context", "SHA2");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -89,8 +89,7 @@ int_md5_update(PX_MD *h, const uint8 *data, unsigned dlen)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_update(ctx, data, dlen) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not update %s context", "MD5");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -99,8 +98,7 @@ int_md5_reset(PX_MD *h)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_init(ctx) < 0)
|
||||
elog(ERROR, "could not initialize %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not initialize %s context", "MD5");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -109,8 +107,7 @@ int_md5_finish(PX_MD *h, uint8 *dst)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_final(ctx, dst, h->result_size(h)) < 0)
|
||||
elog(ERROR, "could not finalize %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not finalize %s context", "MD5");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -142,8 +139,7 @@ int_sha1_update(PX_MD *h, const uint8 *data, unsigned dlen)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_update(ctx, data, dlen) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not update %s context", "SHA1");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -152,8 +148,7 @@ int_sha1_reset(PX_MD *h)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_init(ctx) < 0)
|
||||
elog(ERROR, "could not initialize %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not initialize %s context", "SHA1");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -162,8 +157,7 @@ int_sha1_finish(PX_MD *h, uint8 *dst)
|
||||
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
|
||||
|
||||
if (pg_cryptohash_final(ctx, dst, h->result_size(h)) < 0)
|
||||
elog(ERROR, "could not finalize %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not finalize %s context", "SHA1");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -319,17 +319,14 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
|
||||
pg_cryptohash_ctx *ctx = pg_cryptohash_create(PG_MD5);
|
||||
|
||||
if (pg_cryptohash_init(ctx) < 0)
|
||||
elog(ERROR, "could not initialize %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not initialize %s context", "MD5");
|
||||
if (pg_cryptohash_update(ctx, ns, sizeof(uu)) < 0 ||
|
||||
pg_cryptohash_update(ctx, (unsigned char *) ptr, len) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not update %s context", "MD5");
|
||||
/* we assume sizeof MD5 result is 16, same as UUID size */
|
||||
if (pg_cryptohash_final(ctx, (unsigned char *) &uu,
|
||||
sizeof(uu)) < 0)
|
||||
elog(ERROR, "could not finalize %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not finalize %s context", "MD5");
|
||||
pg_cryptohash_free(ctx);
|
||||
}
|
||||
else
|
||||
@ -338,15 +335,12 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
|
||||
unsigned char sha1result[SHA1_DIGEST_LENGTH];
|
||||
|
||||
if (pg_cryptohash_init(ctx) < 0)
|
||||
elog(ERROR, "could not initialize %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not initialize %s context", "SHA1");
|
||||
if (pg_cryptohash_update(ctx, ns, sizeof(uu)) < 0 ||
|
||||
pg_cryptohash_update(ctx, (unsigned char *) ptr, len) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not update %s context", "SHA1");
|
||||
if (pg_cryptohash_final(ctx, sha1result, sizeof(sha1result)) < 0)
|
||||
elog(ERROR, "could not finalize %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
elog(ERROR, "could not finalize %s context", "SHA1");
|
||||
pg_cryptohash_free(ctx);
|
||||
|
||||
memcpy(&uu, sha1result, sizeof(uu));
|
||||
|
Reference in New Issue
Block a user