summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/usr.bin/openssl/errstr.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/usr.bin/openssl/errstr.c b/src/usr.bin/openssl/errstr.c
index 16d3832c88..9a9c844c6a 100644
--- a/src/usr.bin/openssl/errstr.c
+++ b/src/usr.bin/openssl/errstr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: errstr.c,v 1.2 2015/04/13 15:02:23 jsing Exp $ */ 1/* $OpenBSD: errstr.c,v 1.3 2015/04/14 10:54:40 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <limits.h>
59#include <stdio.h> 60#include <stdio.h>
60#include <stdlib.h> 61#include <stdlib.h>
61#include <string.h> 62#include <string.h>
@@ -93,10 +94,11 @@ int errstr_main(int, char **);
93int 94int
94errstr_main(int argc, char **argv) 95errstr_main(int argc, char **argv)
95{ 96{
96 int i, ret = 0; 97 unsigned long ulval;
98 char *ularg, *ep;
99 int argsused, i;
97 char buf[256]; 100 char buf[256];
98 unsigned long l; 101 int ret = 0;
99 int argsused;
100 102
101 memset(&errstr_config, 0, sizeof(errstr_config)); 103 memset(&errstr_config, 0, sizeof(errstr_config));
102 104
@@ -106,30 +108,35 @@ errstr_main(int argc, char **argv)
106 } 108 }
107 109
108 if (errstr_config.stats) { 110 if (errstr_config.stats) {
109 BIO *out = NULL; 111 BIO *out;
110 112
111 out = BIO_new(BIO_s_file()); 113 if ((out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL) {
112 if ((out != NULL) && BIO_set_fp(out, stdout, BIO_NOCLOSE)) { 114 fprintf(stderr, "Out of memory");
113 lh_ERR_STRING_DATA_node_stats_bio( 115 return (1);
114 ERR_get_string_table(), out);
115 lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(),
116 out);
117 lh_ERR_STRING_DATA_node_usage_stats_bio(
118 ERR_get_string_table(), out);
119 } 116 }
120 if (out != NULL) 117
121 BIO_free_all(out); 118 lh_ERR_STRING_DATA_node_stats_bio(ERR_get_string_table(), out);
119 lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), out);
120 lh_ERR_STRING_DATA_node_usage_stats_bio(
121 ERR_get_string_table(), out);
122
123 BIO_free_all(out);
122 } 124 }
123 125
124 for (i = argsused; i < argc; i++) { 126 for (i = argsused; i < argc; i++) {
125 if (sscanf(argv[i], "%lx", &l)) { 127 errno = 0;
126 ERR_error_string_n(l, buf, sizeof buf); 128 ularg = argv[i];
127 printf("%s\n", buf); 129 ulval = strtoul(ularg, &ep, 16);
128 } else { 130 if (strchr(ularg, '-') != NULL ||
129 printf("%s: bad error code\n", argv[i]); 131 (ularg[0] == '\0' || *ep != '\0') ||
130 errstr_usage(); 132 (errno == ERANGE && ulval == ULONG_MAX)) {
133 printf("%s: bad error code\n", ularg);
131 ret++; 134 ret++;
135 continue;
132 } 136 }
137
138 ERR_error_string_n(ulval, buf, sizeof(buf));
139 printf("%s\n", buf);
133 } 140 }
134 141
135 return (ret); 142 return (ret);