]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ERR: Remove ERR_put_func_error() and reimplement ERR_put_error() as a macro
authorRichard Levitte <levitte@openssl.org>
Wed, 24 Jul 2019 11:25:56 +0000 (13:25 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 31 Jul 2019 04:44:45 +0000 (06:44 +0200)
Also, deprecate ERR_put_error()

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9452)

crypto/err/err.c
doc/man3/ERR_put_error.pod
include/openssl/err.h
test/errtest.c
util/libcrypto.num
util/private.num

index 60f945c845916985fa7a529e67b310de8f2a557e..f129c1c7d668495f83712162f5e661cdf2e13203 100644 (file)
@@ -355,44 +355,6 @@ void err_free_strings_int(void)
 
 /********************************************************/
 
 
 /********************************************************/
 
-void ERR_put_func_error(int lib, const char *func, int reason,
-                        const char *file, int line)
-{
-    ERR_put_error(lib, 0, reason, file, line);
-    ERR_add_error_data(2, "calling function ", func);
-}
-
-void ERR_put_error(int lib, int func, int reason, const char *file, int line)
-{
-    ERR_STATE *es;
-
-#ifdef _OSD_POSIX
-    /*
-     * In the BS2000-OSD POSIX subsystem, the compiler generates path names
-     * in the form "*POSIX(/etc/passwd)". This dirty hack strips them to
-     * something sensible. @@@ We shouldn't modify a const string, though.
-     */
-    if (strncmp(file, "*POSIX(", sizeof("*POSIX(") - 1) == 0) {
-        char *end;
-
-        /* Skip the "*POSIX(" prefix */
-        file += sizeof("*POSIX(") - 1;
-        end = &file[strlen(file) - 1];
-        if (*end == ')')
-            *end = '\0';
-        /* Optional: use the basename of the path only. */
-        if ((end = strrchr(file, '/')) != NULL)
-            file = &end[1];
-    }
-#endif
-    es = ERR_get_state();
-    if (es == NULL)
-        return;
-
-    err_get_slot(es);
-    err_clear(es, es->top, 0);
-}
-
 void ERR_clear_error(void)
 {
     int i;
 void ERR_clear_error(void)
 {
     int i;
index d9bbba99a06ac10b2d6e43d4f4c00a76d1d32ce8..729eb574ce0f305debf9ba3714a166101c33ee57 100644 (file)
@@ -3,8 +3,8 @@
 =head1 NAME
 
 ERR_raise, ERR_raise_data,
 =head1 NAME
 
 ERR_raise, ERR_raise_data,
-ERR_put_error, ERR_put_func_error,
-ERR_add_error_data, ERR_add_error_vdata - record an error
+ERR_put_error, ERR_add_error_data, ERR_add_error_vdata
+- record an error
 
 =head1 SYNOPSIS
 
 
 =head1 SYNOPSIS
 
@@ -13,13 +13,13 @@ ERR_add_error_data, ERR_add_error_vdata - record an error
  void ERR_raise(int lib, int reason);
  void ERR_raise_data(int lib, int reason, const char *fmt, ...);
 
  void ERR_raise(int lib, int reason);
  void ERR_raise_data(int lib, int reason, const char *fmt, ...);
 
- void ERR_put_error(int lib, int func, int reason, const char *file, int line);
- void ERR_put_func_error(int lib, const char *func, int reason,
-                         const char *file, int line);
-
  void ERR_add_error_data(int num, ...);
  void ERR_add_error_vdata(int num, va_list arg);
 
  void ERR_add_error_data(int num, ...);
  void ERR_add_error_vdata(int num, va_list arg);
 
+Deprecated since OpenSSL 3.0:
+
+ void ERR_put_error(int lib, int func, int reason, const char *file, int line);
+
 =head1 DESCRIPTION
 
 ERR_raise() adds a new error to the thread's error queue.  The
 =head1 DESCRIPTION
 
 ERR_raise() adds a new error to the thread's error queue.  The
@@ -37,10 +37,6 @@ signals that the error of reason code B<reason> occurred in function
 B<func> of library B<lib>, in line number B<line> of B<file>.
 This function is usually called by a macro.
 
 B<func> of library B<lib>, in line number B<line> of B<file>.
 This function is usually called by a macro.
 
-ERR_put_func_err() is similar except that the B<func> is a string naming
-a function external to OpenSSL, usually provided by the platform on which
-OpenSSL and the application is running.
-
 ERR_add_error_data() associates the concatenation of its B<num> string
 arguments with the error code added last.
 ERR_add_error_vdata() is similar except the argument is a B<va_list>.
 ERR_add_error_data() associates the concatenation of its B<num> string
 arguments with the error code added last.
 ERR_add_error_vdata() is similar except the argument is a B<va_list>.
@@ -52,6 +48,8 @@ error messages for the error code.
 
 =head2 Reporting errors
 
 
 =head2 Reporting errors
 
+=for comment TODO(3.0) should this be internal documentation?
+
 Each sub-library has a specific macro XXXerr() that is used to report
 errors. Its first argument is a function code B<XXX_F_...>, the second
 argument is a reason code B<XXX_R_...>. Function codes are derived
 Each sub-library has a specific macro XXXerr() that is used to report
 errors. Its first argument is a function code B<XXX_F_...>, the second
 argument is a reason code B<XXX_R_...>. Function codes are derived
@@ -78,12 +76,12 @@ the ASN1err() macro.
 
 =head1 RETURN VALUES
 
 
 =head1 RETURN VALUES
 
-ERR_raise(), ERR_put_error() and ERR_add_error_data()
-return no values.
+ERR_raise(), ERR_put_error(), ERR_add_error_data() and
+ERR_add_error_vdata() return no values.
 
 =head1 NOTES
 
 
 =head1 NOTES
 
-ERR_raise() is implemented as a macro.
+ERR_raise() and ERR_put_error() are implemented as macros.
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
index 7aac9b88d4a48741b93bd75fbb7bddaa48662195..142321d2c862e07c55e511b607536f98ff01d30e 100644 (file)
@@ -252,9 +252,14 @@ void ERR_vset_error(int lib, int reason, const char *fmt, va_list args);
      ERR_set_debug(OPENSSL_FILE,OPENSSL_LINE,OPENSSL_FUNC),     \
      ERR_set_error)
 
      ERR_set_debug(OPENSSL_FILE,OPENSSL_LINE,OPENSSL_FUNC),     \
      ERR_set_error)
 
-void ERR_put_error(int lib, int func, int reason, const char *file, int line);
-void ERR_put_func_error(int lib, const char *func, int reason,
-                        const char *file, int line);
+#if !OPENSSL_API_3
+/* Backward compatibility */
+#define ERR_put_error(lib, func, reason, file, line)            \
+    (ERR_new(),                                                 \
+     ERR_set_debug((file), (line), NULL),                       \
+     ERR_set_error((lib), (reason), NULL))
+#endif
+
 void ERR_set_error_data(char *data, int flags);
 
 unsigned long ERR_get_error(void);
 void ERR_set_error_data(char *data, int flags);
 
 unsigned long ERR_get_error(void);
index 88ff8600926fe4a697b0ae214e6b10216c0e4f79..1a18335b6e4245bd70fe58fa819e042e1ade4b1d 100644 (file)
@@ -47,12 +47,14 @@ static int vdata_appends(void)
 /* Test that setting a platform error sets the right values. */
 static int platform_error(void)
 {
 /* Test that setting a platform error sets the right values. */
 static int platform_error(void)
 {
-    const char *file = __FILE__, *f, *data;
-    const int line = __LINE__;
+    const char *file, *f, *data;
+    int line;
     int l;
     unsigned long e;
 
     int l;
     unsigned long e;
 
-    ERR_put_func_error(ERR_LIB_SYS, "exit", ERR_R_INTERNAL_ERROR, file, line);
+    file = __FILE__;
+    line = __LINE__ + 1; /* The error is generated on the next line */
+    FUNCerr("exit", ERR_R_INTERNAL_ERROR);
     if (!TEST_ulong_ne(e = ERR_get_error_line_data(&f, &l, &data, NULL), 0)
             || !TEST_int_eq(ERR_GET_REASON(e), ERR_R_INTERNAL_ERROR)
             || !TEST_int_eq(l, line)
     if (!TEST_ulong_ne(e = ERR_get_error_line_data(&f, &l, &data, NULL), 0)
             || !TEST_int_eq(ERR_GET_REASON(e), ERR_R_INTERNAL_ERROR)
             || !TEST_int_eq(l, line)
index da7395c9cb16d7ee46c7888740aa84d26b04b5df..a6c5097e1c8bf0d8221d470c72fda10d32b1ad9d 100644 (file)
@@ -998,7 +998,7 @@ OPENSSL_LH_get_down_load                1023        3_0_0   EXIST::FUNCTION:
 EVP_md4                                 1024   3_0_0   EXIST::FUNCTION:MD4
 X509_set_subject_name                   1025   3_0_0   EXIST::FUNCTION:
 i2d_PKCS8PrivateKey_nid_bio             1026   3_0_0   EXIST::FUNCTION:
 EVP_md4                                 1024   3_0_0   EXIST::FUNCTION:MD4
 X509_set_subject_name                   1025   3_0_0   EXIST::FUNCTION:
 i2d_PKCS8PrivateKey_nid_bio             1026   3_0_0   EXIST::FUNCTION:
-ERR_put_error                           1027   3_0_0   EXIST::FUNCTION:
+ERR_put_error                           1027   3_0_0   NOEXIST::FUNCTION:
 ERR_add_error_data                      1028   3_0_0   EXIST::FUNCTION:
 X509_ALGORS_it                          1029   3_0_0   EXIST::FUNCTION:
 MD5_Update                              1030   3_0_0   EXIST::FUNCTION:MD5
 ERR_add_error_data                      1028   3_0_0   EXIST::FUNCTION:
 X509_ALGORS_it                          1029   3_0_0   EXIST::FUNCTION:
 MD5_Update                              1030   3_0_0   EXIST::FUNCTION:MD5
@@ -4690,7 +4690,7 @@ EVP_KEYMGMT_up_ref                      4795      3_0_0   EXIST::FUNCTION:
 EVP_KEYMGMT_free                        4796   3_0_0   EXIST::FUNCTION:
 EVP_KEYMGMT_provider                    4797   3_0_0   EXIST::FUNCTION:
 X509_PUBKEY_dup                         4798   3_0_0   EXIST::FUNCTION:
 EVP_KEYMGMT_free                        4796   3_0_0   EXIST::FUNCTION:
 EVP_KEYMGMT_provider                    4797   3_0_0   EXIST::FUNCTION:
 X509_PUBKEY_dup                         4798   3_0_0   EXIST::FUNCTION:
-ERR_put_func_error                      4799   3_0_0   EXIST::FUNCTION:
+ERR_put_func_error                      4799   3_0_0   NOEXIST::FUNCTION:
 EVP_MD_name                             4800   3_0_0   EXIST::FUNCTION:
 EVP_CIPHER_name                         4801   3_0_0   EXIST::FUNCTION:
 EVP_MD_provider                         4802   3_0_0   EXIST::FUNCTION:
 EVP_MD_name                             4800   3_0_0   EXIST::FUNCTION:
 EVP_CIPHER_name                         4801   3_0_0   EXIST::FUNCTION:
 EVP_MD_provider                         4802   3_0_0   EXIST::FUNCTION:
index 3c00589c9b9a4fdeea7d31c79858d3bb61110c69..82cb72e606e9c345d5a66f7900e296e203acf31a 100644 (file)
@@ -195,6 +195,7 @@ ERR_GET_LIB                             define
 ERR_GET_REASON                          define
 ERR_PACK                                define
 ERR_free_strings                        define deprecated 1.1.0
 ERR_GET_REASON                          define
 ERR_PACK                                define
 ERR_free_strings                        define deprecated 1.1.0
+ERR_put_error                           define deprecated 3.0
 ERR_load_crypto_strings                 define deprecated 1.1.0
 ERR_raise                               define
 ERR_raise_data                          define
 ERR_load_crypto_strings                 define deprecated 1.1.0
 ERR_raise                               define
 ERR_raise_data                          define