pgcrypto: report init errors as PXE_CIPHER_INIT
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 6 May 2022 12:41:33 +0000 (14:41 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 6 May 2022 12:41:33 +0000 (14:41 +0200)
Report OpenSSL errors during initialization as PXE_CIPHER_INIT since
that's just what they were, and not generic unknown errors. This also
removes the last users of the generic error, and thus it can be removed.

Discussion: http://postgr.es/m/C89D932C-501E-4473-9750-638CFCD9095E@yesql.se

contrib/pgcrypto/openssl.c
contrib/pgcrypto/px.c
contrib/pgcrypto/px.h

index 68fd61b716f2b18e9dd292443bd980b8e89b8084..53e64297c28449b2ae78d46f6cb65a1074d22a3e 100644 (file)
@@ -209,13 +209,13 @@ px_find_digest(const char *name, PX_MD **res)
    if (!ctx)
    {
        pfree(digest);
-       return -1;
+       return PXE_CIPHER_INIT;
    }
    if (EVP_DigestInit_ex(ctx, md, NULL) == 0)
    {
        EVP_MD_CTX_destroy(ctx);
        pfree(digest);
-       return -1;
+       return PXE_CIPHER_INIT;
    }
 
    digest->algo = md;
index c139798f3b2a32d240087a100aaa2ba37d562195..40b6a04d526492919337f30d1621775cdee6509b 100644 (file)
@@ -41,7 +41,6 @@ struct error_desc
 
 static const struct error_desc px_err_list[] = {
    {PXE_OK, "Everything ok"},
-   {PXE_ERR_GENERIC, "Some PX error (not specified)"},
    {PXE_NO_HASH, "No such hash algorithm"},
    {PXE_NO_CIPHER, "No such cipher algorithm"},
    {PXE_BAD_OPTION, "Unknown option"},
index f175862f8e0a5d7583959b443c5a0fe7cc4c1575..4ef40f3f1c53fb3409343ac40718da03fdbd8dfe 100644 (file)
@@ -44,7 +44,7 @@
  * PX error codes
  */
 #define PXE_OK                     0
-#define PXE_ERR_GENERIC                -1
+/* -1 is unused */
 #define PXE_NO_HASH                    -2
 #define PXE_NO_CIPHER              -3
 /* -4 is unused */