X-Git-Url: https://git.openssl.org/?a=blobdiff_plain;f=crypto%2Ferr%2Ferr_prn.c;h=a0168ac8ed628fd4d511059d68b0bffaebad92ed;hb=60df657b3a72065c0df0349abf228d7399e20bac;hp=81e34bd6ce7acfeccbe690aa6ab9953c390ed350;hpb=677532629d84e39f4cb8edfe017fbfc8120d45d0;p=openssl.git diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c index 81e34bd6ce..a0168ac8ed 100644 --- a/crypto/err/err_prn.c +++ b/crypto/err/err_prn.c @@ -57,9 +57,9 @@ */ #include +#include "cryptlib.h" #include #include -#include "cryptlib.h" #include #include @@ -72,21 +72,29 @@ void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), const char *file,*data; int line,flags; unsigned long es; + CRYPTO_THREADID cur; - es=CRYPTO_thread_id(); + CRYPTO_THREADID_current(&cur); + es=CRYPTO_THREADID_hash(&cur); while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) { ERR_error_string_n(l, buf, sizeof buf); BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, file, line, (flags & ERR_TXT_STRING) ? data : ""); - cb(buf2, strlen(buf2), u); + if (cb(buf2, strlen(buf2), u) <= 0) + break; /* abort outputting the error report */ } } #ifndef OPENSSL_NO_FP_API static int print_fp(const char *str, size_t len, void *fp) { - return fprintf((FILE *)fp, "%s", str); + BIO bio; + + BIO_set(&bio,BIO_s_file()); + BIO_set_fp(&bio,fp,BIO_NOCLOSE); + + return BIO_printf(&bio, "%s", str); } void ERR_print_errors_fp(FILE *fp) {