From 0179324cb8e49724e624c4a6c35de46c975416d4 Mon Sep 17 00:00:00 2001 From: beck <> Date: Mon, 20 Feb 2017 23:21:19 +0000 Subject: Mark ERR_add_error_data and ERR_add_error_vdata as not for internal use, and document ERR_asprintf_error_data as their replacement. ok jsing@, ingo@ --- src/lib/libcrypto/err/err.c | 19 +++++---- src/lib/libcrypto/err/err.h | 4 +- src/lib/libcrypto/man/ERR_asprintf_error_data.3 | 55 +++++++++++++++++++++++++ src/lib/libcrypto/man/ERR_put_error.3 | 14 +++++-- src/lib/libcrypto/man/Makefile | 3 +- 5 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 src/lib/libcrypto/man/ERR_asprintf_error_data.3 (limited to 'src') diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index 1b235c1653..ffe25bf465 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err.c,v 1.44 2017/02/07 15:52:33 jsing Exp $ */ +/* $OpenBSD: err.c,v 1.45 2017/02/20 23:21:19 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1092,14 +1092,6 @@ ERR_asprintf_error_data(char * format, ...) { else ERR_set_error_data(errbuf, ERR_TXT_MALLOCED|ERR_TXT_STRING); } -void -ERR_add_error_data(int num, ...) -{ - va_list args; - va_start(args, num); - ERR_add_error_vdata(num, args); - va_end(args); -} void ERR_add_error_vdata(int num, va_list args) @@ -1121,6 +1113,15 @@ ERR_add_error_vdata(int num, va_list args) ERR_set_error_data(errbuf, ERR_TXT_MALLOCED|ERR_TXT_STRING); } +void +ERR_add_error_data(int num, ...) +{ + va_list args; + va_start(args, num); + ERR_add_error_vdata(num, args); + va_end(args); +} + int ERR_set_mark(void) { diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h index 672dead06b..22cdb2987f 100644 --- a/src/lib/libcrypto/err/err.h +++ b/src/lib/libcrypto/err/err.h @@ -1,4 +1,4 @@ -/* $OpenBSD: err.h,v 1.24 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: err.h,v 1.25 2017/02/20 23:21:19 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -378,8 +378,10 @@ void ERR_print_errors_fp(FILE *fp); void ERR_print_errors(BIO *bp); #endif void ERR_asprintf_error_data(char * format, ...); +#ifndef LIBRESSL_INTERNAL void ERR_add_error_data(int num, ...); void ERR_add_error_vdata(int num, va_list args); +#endif void ERR_load_strings(int lib, ERR_STRING_DATA str[]); void ERR_unload_strings(int lib, ERR_STRING_DATA str[]); void ERR_load_ERR_strings(void); diff --git a/src/lib/libcrypto/man/ERR_asprintf_error_data.3 b/src/lib/libcrypto/man/ERR_asprintf_error_data.3 new file mode 100644 index 0000000000..6481da4750 --- /dev/null +++ b/src/lib/libcrypto/man/ERR_asprintf_error_data.3 @@ -0,0 +1,55 @@ +.\" $OpenBSD: ERR_asprintf_error_data.3,v 1.1 2017/02/20 23:21:19 beck Exp $ +.\" +.\" Copyright (c) 2017 Bob Beck +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.Dd $Mdocdate: February 20 2017 $ +.Dt ERR_ASPRINTF_ERROR_DATA 3 +.Os +.Sh NAME +.Nm ERR_asprintf_error_data +.Nd record a LibreSSL error using a formatted string. +.Sh SYNOPSIS +.In openssl/err.h +.Ft void +.Fo ERR_asprintf_error_data +.Fa "char * format" +.Fa ... +.Fc +.Sh DESCRIPTION +.Nm +builds a string using +.Xr asprintf 3 +called with the provided +.Ar format +and arguments. +The resulting string is then associated with the error code that was most +recently added. +If +.Xr asprintf 3 +fails, the string "malloc failed" is associated instead. +.Pp +.Nm +is intended to be used instead of the OpenSSL functions +.Xr ERR_add_error_data 3 +and +.Xr ERR_add_error_vdata 3 . +.Sh SEE ALSO +.Xr ERR 3 , +.Xr ERR_put_error 3 , +.Xr printf 3 +.Sh HISTORY +.Nm +appeared in +.Ox 5.6 +and is available in all versions of LibreSSL. diff --git a/src/lib/libcrypto/man/ERR_put_error.3 b/src/lib/libcrypto/man/ERR_put_error.3 index 2b41bedea3..3011e16df4 100644 --- a/src/lib/libcrypto/man/ERR_put_error.3 +++ b/src/lib/libcrypto/man/ERR_put_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ERR_put_error.3,v 1.4 2016/11/23 17:54:15 schwarze Exp $ +.\" $OpenBSD: ERR_put_error.3,v 1.5 2017/02/20 23:21:19 beck Exp $ .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file was written by Ulf Moeller . @@ -48,12 +48,13 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 23 2016 $ +.Dd $Mdocdate: February 20 2017 $ .Dt ERR_PUT_ERROR 3 .Os .Sh NAME .Nm ERR_put_error , -.Nm ERR_add_error_data +.Nm ERR_add_error_data , +.Nm ERR_add_error_vdata .Nd record an OpenSSL error .Sh SYNOPSIS .In openssl/err.h @@ -97,6 +98,12 @@ string arguments with the error code added last. .Fn ERR_add_error_vdata is similar except the argument is a .Vt va_list . +Use of +.Fn ERR_add_error_data +and +.Fn ERR_add_error_vdata +is deprecated inside of LibreSSL in favour of +.Xr ERR_asprintf_error_data 3 . .Pp .Xr ERR_load_strings 3 can be used to register error strings so that the application can @@ -136,6 +143,7 @@ which must use the macro. .Sh SEE ALSO .Xr ERR 3 , +.Xr ERR_asprintf_error_data 3 , .Xr ERR_load_strings 3 .Sh HISTORY .Fn ERR_put_error diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 9a64837d31..75239dc387 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.114 2017/01/31 05:40:26 schwarze Exp $ +# $OpenBSD: Makefile,v 1.115 2017/02/20 23:21:19 beck Exp $ .include @@ -92,6 +92,7 @@ MAN= \ EC_POINT_new.3 \ ERR.3 \ ERR_GET_LIB.3 \ + ERR_asprintf_error_data.3 \ ERR_clear_error.3 \ ERR_error_string.3 \ ERR_get_error.3 \ -- cgit v1.2.3-55-g6feb