]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch
CryptoPkg/OpensslLib: Switch to upstream fix for OpenSSL RT#3628
[mirror_edk2.git] / CryptoPkg / Library / OpensslLib / EDKII_openssl-1.0.2f.patch
1 diff --git a/Configure b/Configure
2 index 4a715dc..eb61eda 100755
3 --- a/Configure
4 +++ b/Configure
5 @@ -1082,7 +1082,7 @@ if (defined($disabled{"tls1"}))
6 }
7
8 if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
9 - || defined($disabled{"dh"}))
10 + || defined($disabled{"dh"}) || defined($disabled{"stdio"}))
11 {
12 $disabled{"gost"} = "forced";
13 }
14 diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c
15 index 35fd44c..9f39bff 100644
16 --- a/crypto/asn1/a_strex.c
17 +++ b/crypto/asn1/a_strex.c
18 @@ -104,6 +104,7 @@ static int send_bio_chars(void *arg, const void *buf, int len)
19 return 1;
20 }
21
22 +#ifndef OPENSSL_NO_FP_API
23 static int send_fp_chars(void *arg, const void *buf, int len)
24 {
25 if (!arg)
26 @@ -112,6 +113,7 @@ static int send_fp_chars(void *arg, const void *buf, int len)
27 return 0;
28 return 1;
29 }
30 +#endif
31
32 typedef int char_io (void *arg, const void *buf, int len);
33
34 diff --git a/crypto/asn1/asn1_mac.h b/crypto/asn1/asn1_mac.h
35 index abc6dc3..3a672e9 100644
36 --- a/crypto/asn1/asn1_mac.h
37 +++ b/crypto/asn1/asn1_mac.h
38 @@ -70,7 +70,7 @@ extern "C" {
39 # endif
40
41 # define ASN1_MAC_H_err(f,r,line) \
42 - ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
43 + ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),OPENSSL_FILE,(line))
44
45 # define M_ASN1_D2I_vars(a,type,func) \
46 ASN1_const_CTX c; \
47 @@ -81,7 +81,7 @@ extern "C" {
48 c.error=ERR_R_NESTED_ASN1_ERROR; \
49 if ((a == NULL) || ((*a) == NULL)) \
50 { if ((ret=(type)func()) == NULL) \
51 - { c.line=__LINE__; goto err; } } \
52 + { c.line=OPENSSL_LINE; goto err; } } \
53 else ret=(*a);
54
55 # define M_ASN1_D2I_Init() \
56 @@ -90,7 +90,7 @@ extern "C" {
57
58 # define M_ASN1_D2I_Finish_2(a) \
59 if (!asn1_const_Finish(&c)) \
60 - { c.line=__LINE__; goto err; } \
61 + { c.line=OPENSSL_LINE; goto err; } \
62 *(const unsigned char **)pp=c.p; \
63 if (a != NULL) (*a)=ret; \
64 return(ret);
65 @@ -105,7 +105,7 @@ err:\
66
67 # define M_ASN1_D2I_start_sequence() \
68 if (!asn1_GetSequence(&c,&length)) \
69 - { c.line=__LINE__; goto err; }
70 + { c.line=OPENSSL_LINE; goto err; }
71 /* Begin reading ASN1 without a surrounding sequence */
72 # define M_ASN1_D2I_begin() \
73 c.slen = length;
74 @@ -129,21 +129,21 @@ err:\
75 # define M_ASN1_D2I_get(b, func) \
76 c.q=c.p; \
77 if (func(&(b),&c.p,c.slen) == NULL) \
78 - {c.line=__LINE__; goto err; } \
79 + {c.line=OPENSSL_LINE; goto err; } \
80 c.slen-=(c.p-c.q);
81
82 /* Don't use this with d2i_ASN1_BOOLEAN() */
83 # define M_ASN1_D2I_get_x(type,b,func) \
84 c.q=c.p; \
85 if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \
86 - {c.line=__LINE__; goto err; } \
87 + {c.line=OPENSSL_LINE; goto err; } \
88 c.slen-=(c.p-c.q);
89
90 /* use this instead () */
91 # define M_ASN1_D2I_get_int(b,func) \
92 c.q=c.p; \
93 if (func(&(b),&c.p,c.slen) < 0) \
94 - {c.line=__LINE__; goto err; } \
95 + {c.line=OPENSSL_LINE; goto err; } \
96 c.slen-=(c.p-c.q);
97
98 # define M_ASN1_D2I_get_opt(b,func,type) \
99 @@ -164,7 +164,7 @@ err:\
100 M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
101 c.q=c.p; \
102 if (func(&(b),&c.p,c.slen) == NULL) \
103 - {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \
104 + {c.line=OPENSSL_LINE; M_ASN1_next_prev = _tmp; goto err; } \
105 c.slen-=(c.p-c.q);\
106 M_ASN1_next_prev=_tmp;
107
108 @@ -258,20 +258,20 @@ err:\
109 c.q=c.p; \
110 if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
111 (void (*)())free_func,a,b) == NULL) \
112 - { c.line=__LINE__; goto err; } \
113 + { c.line=OPENSSL_LINE; goto err; } \
114 c.slen-=(c.p-c.q);
115
116 # define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \
117 c.q=c.p; \
118 if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\
119 free_func,a,b) == NULL) \
120 - { c.line=__LINE__; goto err; } \
121 + { c.line=OPENSSL_LINE; goto err; } \
122 c.slen-=(c.p-c.q);
123
124 # define M_ASN1_D2I_get_set_strings(r,func,a,b) \
125 c.q=c.p; \
126 if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
127 - { c.line=__LINE__; goto err; } \
128 + { c.line=OPENSSL_LINE; goto err; } \
129 c.slen-=(c.p-c.q);
130
131 # define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
132 @@ -285,16 +285,16 @@ err:\
133 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
134 if (Tinf & 0x80) \
135 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
136 - c.line=__LINE__; goto err; } \
137 + c.line=OPENSSL_LINE; goto err; } \
138 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
139 Tlen = c.slen - (c.p - c.q) - 2; \
140 if (func(&(r),&c.p,Tlen) == NULL) \
141 - { c.line=__LINE__; goto err; } \
142 + { c.line=OPENSSL_LINE; goto err; } \
143 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
144 Tlen = c.slen - (c.p - c.q); \
145 if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \
146 { c.error=ERR_R_MISSING_ASN1_EOS; \
147 - c.line=__LINE__; goto err; } \
148 + c.line=OPENSSL_LINE; goto err; } \
149 }\
150 c.slen-=(c.p-c.q); \
151 }
152 @@ -310,18 +310,18 @@ err:\
153 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
154 if (Tinf & 0x80) \
155 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
156 - c.line=__LINE__; goto err; } \
157 + c.line=OPENSSL_LINE; goto err; } \
158 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
159 Tlen = c.slen - (c.p - c.q) - 2; \
160 if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \
161 (void (*)())free_func, \
162 b,V_ASN1_UNIVERSAL) == NULL) \
163 - { c.line=__LINE__; goto err; } \
164 + { c.line=OPENSSL_LINE; goto err; } \
165 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
166 Tlen = c.slen - (c.p - c.q); \
167 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
168 { c.error=ERR_R_MISSING_ASN1_EOS; \
169 - c.line=__LINE__; goto err; } \
170 + c.line=OPENSSL_LINE; goto err; } \
171 }\
172 c.slen-=(c.p-c.q); \
173 }
174 @@ -337,17 +337,17 @@ err:\
175 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
176 if (Tinf & 0x80) \
177 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
178 - c.line=__LINE__; goto err; } \
179 + c.line=OPENSSL_LINE; goto err; } \
180 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
181 Tlen = c.slen - (c.p - c.q) - 2; \
182 if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \
183 free_func,b,V_ASN1_UNIVERSAL) == NULL) \
184 - { c.line=__LINE__; goto err; } \
185 + { c.line=OPENSSL_LINE; goto err; } \
186 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
187 Tlen = c.slen - (c.p - c.q); \
188 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
189 { c.error=ERR_R_MISSING_ASN1_EOS; \
190 - c.line=__LINE__; goto err; } \
191 + c.line=OPENSSL_LINE; goto err; } \
192 }\
193 c.slen-=(c.p-c.q); \
194 }
195 @@ -355,7 +355,7 @@ err:\
196 /* New macros */
197 # define M_ASN1_New_Malloc(ret,type) \
198 if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
199 - { c.line=__LINE__; goto err2; }
200 + { c.line=OPENSSL_LINE; goto err2; }
201
202 # define M_ASN1_New(arg,func) \
203 if (((arg)=func()) == NULL) return(NULL)
204 diff --git a/crypto/conf/conf.h b/crypto/conf/conf.h
205 index 8d926d5..41cf38e 100644
206 --- a/crypto/conf/conf.h
207 +++ b/crypto/conf/conf.h
208 @@ -118,8 +118,10 @@ typedef void conf_finish_func (CONF_IMODULE *md);
209
210 int CONF_set_default_method(CONF_METHOD *meth);
211 void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
212 +# ifndef OPENSSL_NO_STDIO
213 LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
214 long *eline);
215 +# endif
216 # ifndef OPENSSL_NO_FP_API
217 LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
218 long *eline);
219 @@ -133,7 +135,9 @@ char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
220 long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
221 const char *name);
222 void CONF_free(LHASH_OF(CONF_VALUE) *conf);
223 +#ifndef OPENSSL_NO_FP_API
224 int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
225 +#endif
226 int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
227
228 void OPENSSL_config(const char *config_name);
229 @@ -160,7 +164,9 @@ CONF_METHOD *NCONF_XML(void);
230 void NCONF_free(CONF *conf);
231 void NCONF_free_data(CONF *conf);
232
233 +# ifndef OPENSSL_NO_STDIO
234 int NCONF_load(CONF *conf, const char *file, long *eline);
235 +# endif
236 # ifndef OPENSSL_NO_FP_API
237 int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
238 # endif
239 @@ -170,7 +176,9 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
240 char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
241 int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
242 long *result);
243 +#ifndef OPENSSL_NO_FP_API
244 int NCONF_dump_fp(const CONF *conf, FILE *out);
245 +#endif
246 int NCONF_dump_bio(const CONF *conf, BIO *out);
247
248 # if 0 /* The following function has no error
249 @@ -184,8 +192,10 @@ long NCONF_get_number(CONF *conf, char *group, char *name);
250
251 int CONF_modules_load(const CONF *cnf, const char *appname,
252 unsigned long flags);
253 +#ifndef OPENSSL_NO_STDIO
254 int CONF_modules_load_file(const char *filename, const char *appname,
255 unsigned long flags);
256 +#endif
257 void CONF_modules_unload(int all);
258 void CONF_modules_finish(void);
259 void CONF_modules_free(void);
260 diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
261 index 68c77ce..3d308c7 100644
262 --- a/crypto/conf/conf_def.c
263 +++ b/crypto/conf/conf_def.c
264 @@ -182,6 +182,10 @@ static int def_destroy_data(CONF *conf)
265
266 static int def_load(CONF *conf, const char *name, long *line)
267 {
268 +#ifdef OPENSSL_NO_STDIO
269 + CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB);
270 + return 0;
271 +#else
272 int ret;
273 BIO *in = NULL;
274
275 @@ -202,6 +206,7 @@ static int def_load(CONF *conf, const char *name, long *line)
276 BIO_free(in);
277
278 return ret;
279 +#endif
280 }
281
282 static int def_load_bio(CONF *conf, BIO *in, long *line)
283 diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
284 index 5281384..952b545 100644
285 --- a/crypto/conf/conf_lib.c
286 +++ b/crypto/conf/conf_lib.c
287 @@ -90,6 +90,7 @@ int CONF_set_default_method(CONF_METHOD *meth)
288 return 1;
289 }
290
291 +#ifndef OPENSSL_NO_STDIO
292 LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
293 long *eline)
294 {
295 @@ -111,6 +112,7 @@ LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
296
297 return ltmp;
298 }
299 +#endif
300
301 #ifndef OPENSSL_NO_FP_API
302 LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
303 @@ -255,6 +257,7 @@ void NCONF_free_data(CONF *conf)
304 conf->meth->destroy_data(conf);
305 }
306
307 +#ifndef OPENSSL_NO_STDIO
308 int NCONF_load(CONF *conf, const char *file, long *eline)
309 {
310 if (conf == NULL) {
311 @@ -264,6 +267,7 @@ int NCONF_load(CONF *conf, const char *file, long *eline)
312
313 return conf->meth->load(conf, file, eline);
314 }
315 +#endif
316
317 #ifndef OPENSSL_NO_FP_API
318 int NCONF_load_fp(CONF *conf, FILE *fp, long *eline)
319 diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
320 index 9acfca4..5e0a482 100644
321 --- a/crypto/conf/conf_mod.c
322 +++ b/crypto/conf/conf_mod.c
323 @@ -159,6 +159,7 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
324
325 }
326
327 +#ifndef OPENSSL_NO_STDIO
328 int CONF_modules_load_file(const char *filename, const char *appname,
329 unsigned long flags)
330 {
331 @@ -194,6 +195,7 @@ int CONF_modules_load_file(const char *filename, const char *appname,
332
333 return ret;
334 }
335 +#endif
336
337 static int module_run(const CONF *cnf, char *name, char *value,
338 unsigned long flags)
339 diff --git a/crypto/conf/conf_sap.c b/crypto/conf/conf_sap.c
340 index c042cf2..a25b636 100644
341 --- a/crypto/conf/conf_sap.c
342 +++ b/crypto/conf/conf_sap.c
343 @@ -87,9 +87,11 @@ void OPENSSL_config(const char *config_name)
344 ENGINE_load_builtin_engines();
345 #endif
346 ERR_clear_error();
347 +#ifndef OPENSSL_NO_STDIO
348 CONF_modules_load_file(NULL, config_name,
349 CONF_MFLAGS_DEFAULT_SECTION |
350 CONF_MFLAGS_IGNORE_MISSING_FILE);
351 +#endif
352 openssl_configured = 1;
353 }
354
355 diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
356 index c9f674b..39ead7f 100644
357 --- a/crypto/cryptlib.c
358 +++ b/crypto/cryptlib.c
359 @@ -263,7 +263,7 @@ int CRYPTO_get_new_dynlockid(void)
360 return (0);
361 }
362 pointer->references = 1;
363 - pointer->data = dynlock_create_callback(__FILE__, __LINE__);
364 + pointer->data = dynlock_create_callback(OPENSSL_FILE, OPENSSL_LINE);
365 if (pointer->data == NULL) {
366 OPENSSL_free(pointer);
367 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
368 @@ -289,7 +289,7 @@ int CRYPTO_get_new_dynlockid(void)
369 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
370
371 if (i == -1) {
372 - dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
373 + dynlock_destroy_callback(pointer->data, OPENSSL_FILE, OPENSSL_LINE);
374 OPENSSL_free(pointer);
375 } else
376 i += 1; /* to avoid 0 */
377 @@ -328,7 +328,7 @@ void CRYPTO_destroy_dynlockid(int i)
378 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
379
380 if (pointer) {
381 - dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
382 + dynlock_destroy_callback(pointer->data, OPENSSL_FILE, OPENSSL_LINE);
383 OPENSSL_free(pointer);
384 }
385 }
386 @@ -670,6 +670,7 @@ unsigned long *OPENSSL_ia32cap_loc(void)
387 }
388
389 # if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
390 +#include <stdio.h>
391 # define OPENSSL_CPUID_SETUP
392 # if defined(_WIN32)
393 typedef unsigned __int64 IA32CAP;
394 @@ -980,11 +981,13 @@ void OPENSSL_showfatal(const char *fmta, ...)
395 #else
396 void OPENSSL_showfatal(const char *fmta, ...)
397 {
398 +#ifndef OPENSSL_NO_STDIO
399 va_list ap;
400
401 va_start(ap, fmta);
402 vfprintf(stderr, fmta, ap);
403 va_end(ap);
404 +#endif
405 }
406
407 int OPENSSL_isservice(void)
408 @@ -1011,10 +1014,12 @@ void OpenSSLDie(const char *file, int line, const char *assertion)
409 #endif
410 }
411
412 +#ifndef OPENSSL_NO_STDIO
413 void *OPENSSL_stderr(void)
414 {
415 return stderr;
416 }
417 +#endif
418
419 int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
420 {
421 diff --git a/crypto/cryptlib.h b/crypto/cryptlib.h
422 index fba180a..3e3ea5e 100644
423 --- a/crypto/cryptlib.h
424 +++ b/crypto/cryptlib.h
425 @@ -101,7 +101,9 @@ extern "C" {
426 void OPENSSL_cpuid_setup(void);
427 extern unsigned int OPENSSL_ia32cap_P[];
428 void OPENSSL_showfatal(const char *fmta, ...);
429 +#ifndef OPENSSL_NO_STDIO
430 void *OPENSSL_stderr(void);
431 +#endif
432 extern int OPENSSL_NONPIC_relocated;
433
434 #ifdef __cplusplus
435 diff --git a/crypto/crypto.h b/crypto/crypto.h
436 index c450d7a..063d78e 100644
437 --- a/crypto/crypto.h
438 +++ b/crypto/crypto.h
439 @@ -235,15 +235,15 @@ typedef struct openssl_item_st {
440 # ifndef OPENSSL_NO_LOCKING
441 # ifndef CRYPTO_w_lock
442 # define CRYPTO_w_lock(type) \
443 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
444 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
445 # define CRYPTO_w_unlock(type) \
446 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
447 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
448 # define CRYPTO_r_lock(type) \
449 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
450 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
451 # define CRYPTO_r_unlock(type) \
452 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
453 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
454 # define CRYPTO_add(addr,amount,type) \
455 - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
456 + CRYPTO_add_lock(addr,amount,type,OPENSSL_FILE,OPENSSL_LINE)
457 # endif
458 # else
459 # define CRYPTO_w_lock(a)
460 @@ -378,19 +378,19 @@ int CRYPTO_is_mem_check_on(void);
461 # define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
462 # define is_MemCheck_on() CRYPTO_is_mem_check_on()
463
464 -# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
465 -# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
466 +# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,OPENSSL_FILE,OPENSSL_LINE)
467 +# define OPENSSL_strdup(str) CRYPTO_strdup((str),OPENSSL_FILE,OPENSSL_LINE)
468 # define OPENSSL_realloc(addr,num) \
469 - CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
470 + CRYPTO_realloc((char *)addr,(int)num,OPENSSL_FILE,OPENSSL_LINE)
471 # define OPENSSL_realloc_clean(addr,old_num,num) \
472 - CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
473 + CRYPTO_realloc_clean(addr,old_num,num,OPENSSL_FILE,OPENSSL_LINE)
474 # define OPENSSL_remalloc(addr,num) \
475 - CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
476 + CRYPTO_remalloc((char **)addr,(int)num,OPENSSL_FILE,OPENSSL_LINE)
477 # define OPENSSL_freeFunc CRYPTO_free
478 # define OPENSSL_free(addr) CRYPTO_free(addr)
479
480 # define OPENSSL_malloc_locked(num) \
481 - CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
482 + CRYPTO_malloc_locked((int)num,OPENSSL_FILE,OPENSSL_LINE)
483 # define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
484
485 const char *SSLeay_version(int type);
486 @@ -545,7 +545,7 @@ void CRYPTO_set_mem_debug_options(long bits);
487 long CRYPTO_get_mem_debug_options(void);
488
489 # define CRYPTO_push_info(info) \
490 - CRYPTO_push_info_(info, __FILE__, __LINE__);
491 + CRYPTO_push_info_(info, OPENSSL_FILE, OPENSSL_LINE);
492 int CRYPTO_push_info_(const char *info, const char *file, int line);
493 int CRYPTO_pop_info(void);
494 int CRYPTO_remove_all_info(void);
495 @@ -588,7 +588,7 @@ void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
496
497 /* die if we have to */
498 void OpenSSLDie(const char *file, int line, const char *assertion);
499 -# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
500 +# define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(OPENSSL_FILE, OPENSSL_LINE, #e),1))
501
502 unsigned long *OPENSSL_ia32cap_loc(void);
503 # define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
504 @@ -605,14 +605,14 @@ void OPENSSL_init(void);
505 # define fips_md_init_ctx(alg, cx) \
506 int alg##_Init(cx##_CTX *c) \
507 { \
508 - if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
509 + if (FIPS_mode()) OpenSSLDie(OPENSSL_FILE, OPENSSL_LINE, \
510 "Low level API call to digest " #alg " forbidden in FIPS mode!"); \
511 return private_##alg##_Init(c); \
512 } \
513 int private_##alg##_Init(cx##_CTX *c)
514
515 # define fips_cipher_abort(alg) \
516 - if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
517 + if (FIPS_mode()) OpenSSLDie(OPENSSL_FILE, OPENSSL_LINE, \
518 "Low level API call to cipher " #alg " forbidden in FIPS mode!")
519
520 # else
521 diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c
522 index 01e275f..7633139 100644
523 --- a/crypto/des/read2pwd.c
524 +++ b/crypto/des/read2pwd.c
525 @@ -114,6 +114,10 @@
526 #include <openssl/ui.h>
527 #include <openssl/crypto.h>
528
529 +#ifndef BUFSIZ
530 +#define BUFSIZ 256
531 +#endif
532 +
533 int DES_read_password(DES_cblock *key, const char *prompt, int verify)
534 {
535 int ok;
536 diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
537 index b58e3fa..e5f345a 100644
538 --- a/crypto/dh/dh_pmeth.c
539 +++ b/crypto/dh/dh_pmeth.c
540 @@ -449,6 +449,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
541 *keylen = ret;
542 return 1;
543 } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {
544 +#ifdef OPENSSL_NO_CMS
545 + return 0;
546 +#else
547 unsigned char *Z = NULL;
548 size_t Zlen = 0;
549 if (!dctx->kdf_outlen || !dctx->kdf_oid)
550 @@ -478,6 +481,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
551 OPENSSL_free(Z);
552 }
553 return ret;
554 +#endif
555 }
556 return 1;
557 }
558 diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h
559 index 46f163b..b4a72a0 100644
560 --- a/crypto/engine/eng_int.h
561 +++ b/crypto/engine/eng_int.h
562 @@ -88,7 +88,7 @@ extern "C" {
563 (unsigned int)(e), (isfunct ? "funct" : "struct"), \
564 ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
565 ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
566 - (__FILE__), (__LINE__));
567 + (OPENSSL_FILE), (OPENSSL_LINE));
568
569 # else
570
571 @@ -136,7 +136,7 @@ ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
572 # else
573 ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
574 int l);
575 -# define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__)
576 +# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE)
577 # endif
578 typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
579 ENGINE *def, void *arg);
580 diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
581 index 34b0029..cf622bb 100644
582 --- a/crypto/engine/eng_openssl.c
583 +++ b/crypto/engine/eng_openssl.c
584 @@ -86,7 +86,9 @@
585 * this is no longer automatic in ENGINE_load_builtin_engines().
586 */
587 #define TEST_ENG_OPENSSL_RC4
588 +#ifndef OPENSSL_NO_FP_API
589 #define TEST_ENG_OPENSSL_PKEY
590 +#endif
591 /* #define TEST_ENG_OPENSSL_RC4_OTHERS */
592 #define TEST_ENG_OPENSSL_RC4_P_INIT
593 /* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
594 diff --git a/crypto/err/err.h b/crypto/err/err.h
595 index 585aa8b..04c6cfc 100644
596 --- a/crypto/err/err.h
597 +++ b/crypto/err/err.h
598 @@ -200,39 +200,39 @@ typedef struct err_state_st {
599
600 # define ERR_LIB_USER 128
601
602 -# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
603 -# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
604 -# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
605 -# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
606 -# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
607 -# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
608 -# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
609 -# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
610 -# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
611 -# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
612 -# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
613 -# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
614 -# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
615 -# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
616 -# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
617 -# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
618 -# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
619 -# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
620 -# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
621 -# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
622 -# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
623 -# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
624 -# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
625 -# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
626 -# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
627 -# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)
628 -# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
629 -# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
630 -# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
631 -# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
632 -# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
633 -# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)
634 -# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)
635 +# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
636 +# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
637 +# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
638 +# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
639 +# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
640 +# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
641 +# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
642 +# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
643 +# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
644 +# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
645 +# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
646 +# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
647 +# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
648 +# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
649 +# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
650 +# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
651 +# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
652 +# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
653 +# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
654 +# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
655 +# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
656 +# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
657 +# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
658 +# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
659 +# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
660 +# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
661 +# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
662 +# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
663 +# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
664 +# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
665 +# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
666 +# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
667 +# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
668
669 /*
670 * Borland C seems too stupid to be able to shift and do longs in the
671 diff --git a/crypto/opensslconf.h.in b/crypto/opensslconf.h.in
672 index 7a1c85d..a5f51a7 100644
673 --- a/crypto/opensslconf.h.in
674 +++ b/crypto/opensslconf.h.in
675 @@ -1,5 +1,15 @@
676 /* crypto/opensslconf.h.in */
677
678 +#ifndef OPENSSL_FILE
679 +#ifdef OPENSSL_NO_FILENAMES
680 +#define OPENSSL_FILE ""
681 +#define OPENSSL_LINE 0
682 +#else
683 +#define OPENSSL_FILE __FILE__
684 +#define OPENSSL_LINE __LINE__
685 +#endif
686 +#endif
687 +
688 /* Generate 80386 code? */
689 #undef I386_ONLY
690
691 diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
692 index d3b23fc..87b0b6a 100644
693 --- a/crypto/pem/pem.h
694 +++ b/crypto/pem/pem.h
695 @@ -324,6 +324,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
696
697 # define DECLARE_PEM_read_fp(name, type) /**/
698 # define DECLARE_PEM_write_fp(name, type) /**/
699 +# define DECLARE_PEM_write_fp_const(name, type) /**/
700 # define DECLARE_PEM_write_cb_fp(name, type) /**/
701 # else
702
703 @@ -417,6 +418,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
704 pem_password_cb *cd, void *u);
705 # endif
706
707 +#ifndef OPENSSL_NO_FP_API
708 int PEM_read(FILE *fp, char **name, char **header,
709 unsigned char **data, long *len);
710 int PEM_write(FILE *fp, const char *name, const char *hdr,
711 @@ -428,6 +430,7 @@ int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
712 int klen, pem_password_cb *callback, void *u);
713 STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
714 pem_password_cb *cb, void *u);
715 +#endif
716
717 int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
718 EVP_MD *md_type, unsigned char **ek, int *ekl,
719 @@ -494,6 +497,7 @@ int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
720 EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
721 void *u);
722
723 +#ifndef OPENSSL_NO_FP_API
724 int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
725 char *kstr, int klen,
726 pem_password_cb *cb, void *u);
727 @@ -510,7 +514,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
728 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
729 char *kstr, int klen, pem_password_cb *cd,
730 void *u);
731 -
732 +#endif
733 EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
734 int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);
735
736 diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c
737 index 5747c73..fe465cc 100644
738 --- a/crypto/pem/pem_pk8.c
739 +++ b/crypto/pem/pem_pk8.c
740 @@ -69,10 +69,12 @@
741 static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
742 int nid, const EVP_CIPHER *enc,
743 char *kstr, int klen, pem_password_cb *cb, void *u);
744 +
745 +#ifndef OPENSSL_NO_FP_API
746 static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
747 int nid, const EVP_CIPHER *enc,
748 char *kstr, int klen, pem_password_cb *cb, void *u);
749 -
750 +#endif
751 /*
752 * These functions write a private key in PKCS#8 format: it is a "drop in"
753 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
754 diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c
755 index c4d3724..fd531c9 100644
756 --- a/crypto/pkcs7/pk7_smime.c
757 +++ b/crypto/pkcs7/pk7_smime.c
758 @@ -254,7 +254,8 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
759 STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
760 PKCS7_SIGNER_INFO *si;
761 X509_STORE_CTX cert_ctx;
762 - char buf[4096];
763 + char *buf = NULL;
764 + int bufsiz;
765 int i, j = 0, k, ret = 0;
766 BIO *p7bio = NULL;
767 BIO *tmpin = NULL, *tmpout = NULL;
768 @@ -274,12 +275,29 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
769 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_NO_CONTENT);
770 return 0;
771 }
772 +#if 0
773 + /*
774 + * NB: this test commented out because some versions of Netscape
775 + * illegally include zero length content when signing data. Also
776 + * Microsoft Authenticode includes a SpcIndirectDataContent data
777 + * structure which describes the content to be protected by the
778 + * signature, rather than directly embedding that content. So
779 + * Authenticode implementations are also expected to use
780 + * PKCS7_verify() with explicit external data, on non-detached
781 + * PKCS#7 signatures.
782 + *
783 + * In OpenSSL 1.1 a new flag PKCS7_NO_DUAL_CONTENT has been
784 + * introduced to disable this sanity check. For the 1.0.2 branch
785 + * this change is not acceptable, so the check remains completely
786 + * commented out (as it has been for a long time).
787 + */
788
789 /* Check for data and content: two sets of data */
790 if (!PKCS7_get_detached(p7) && indata) {
791 PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_CONTENT_AND_DATA_PRESENT);
792 return 0;
793 }
794 +#endif
795
796 sinfos = PKCS7_get_signer_info(p7);
797
798 @@ -355,9 +373,14 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
799 } else
800 tmpout = out;
801
802 + bufsiz = 4096;
803 + buf = OPENSSL_malloc(bufsiz);
804 + if (buf == NULL) {
805 + goto err;
806 + }
807 /* We now have to 'read' from p7bio to calculate digests etc. */
808 for (;;) {
809 - i = BIO_read(p7bio, buf, sizeof(buf));
810 + i = BIO_read(p7bio, buf, bufsiz);
811 if (i <= 0)
812 break;
813 if (tmpout)
814 @@ -394,6 +417,9 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
815 }
816 BIO_free_all(p7bio);
817 sk_X509_free(signers);
818 + if (buf != NULL) {
819 + OPENSSL_free(buf);
820 + }
821 return ret;
822 }
823
824 diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
825 index 266111e..f60fac6 100644
826 --- a/crypto/rand/rand_unix.c
827 +++ b/crypto/rand/rand_unix.c
828 @@ -116,7 +116,7 @@
829 #include <openssl/rand.h>
830 #include "rand_lcl.h"
831
832 -#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE))
833 +#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_UEFI))
834
835 # include <sys/types.h>
836 # include <sys/time.h>
837 @@ -439,7 +439,7 @@ int RAND_poll(void)
838 * defined(OPENSSL_SYS_VXWORKS) ||
839 * defined(OPENSSL_SYS_NETWARE)) */
840
841 -#if defined(OPENSSL_SYS_VXWORKS)
842 +#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
843 int RAND_poll(void)
844 {
845 return 0;
846 diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c
847 index 4e06218..f591f0f 100644
848 --- a/crypto/rsa/rsa_ameth.c
849 +++ b/crypto/rsa/rsa_ameth.c
850 @@ -68,10 +68,12 @@
851 #endif
852 #include "asn1_locl.h"
853
854 +#ifndef OPENSSL_NO_CMS
855 static int rsa_cms_sign(CMS_SignerInfo *si);
856 static int rsa_cms_verify(CMS_SignerInfo *si);
857 static int rsa_cms_decrypt(CMS_RecipientInfo *ri);
858 static int rsa_cms_encrypt(CMS_RecipientInfo *ri);
859 +#endif
860
861 static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
862 {
863 @@ -665,6 +667,7 @@ static int rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx,
864 return rv;
865 }
866
867 +#ifndef OPENSSL_NO_CMS
868 static int rsa_cms_verify(CMS_SignerInfo *si)
869 {
870 int nid, nid2;
871 @@ -683,6 +686,7 @@ static int rsa_cms_verify(CMS_SignerInfo *si)
872 }
873 return 0;
874 }
875 +#endif
876
877 /*
878 * Customised RSA item verification routine. This is called when a signature
879 @@ -705,6 +709,7 @@ static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
880 return -1;
881 }
882
883 +#ifndef OPENSSL_NO_CMS
884 static int rsa_cms_sign(CMS_SignerInfo *si)
885 {
886 int pad_mode = RSA_PKCS1_PADDING;
887 @@ -729,6 +734,7 @@ static int rsa_cms_sign(CMS_SignerInfo *si)
888 X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsassaPss), V_ASN1_SEQUENCE, os);
889 return 1;
890 }
891 +#endif
892
893 static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
894 X509_ALGOR *alg1, X509_ALGOR *alg2,
895 @@ -785,6 +791,7 @@ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg,
896 return pss;
897 }
898
899 +#ifndef OPENSSL_NO_CMS
900 static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
901 {
902 EVP_PKEY_CTX *pkctx;
903 @@ -857,7 +864,9 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
904 X509_ALGOR_free(maskHash);
905 return rv;
906 }
907 +#endif
908
909 +#ifndef OPENSSL_NO_CMS
910 static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
911 {
912 const EVP_MD *md, *mgf1md;
913 @@ -920,6 +929,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)
914 ASN1_STRING_free(os);
915 return rv;
916 }
917 +#endif
918
919 const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = {
920 {
921 diff --git a/crypto/srp/srp.h b/crypto/srp/srp.h
922 index d072536..73b945f 100644
923 --- a/crypto/srp/srp.h
924 +++ b/crypto/srp/srp.h
925 @@ -114,7 +114,9 @@ DECLARE_STACK_OF(SRP_gN)
926
927 SRP_VBASE *SRP_VBASE_new(char *seed_key);
928 int SRP_VBASE_free(SRP_VBASE *vb);
929 +#ifndef OPENSSL_NO_STDIO
930 int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
931 +#endif
932 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);
933 char *SRP_create_verifier(const char *user, const char *pass, char **salt,
934 char **verifier, const char *N, const char *g);
935 diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
936 index a3f1a8a..3fbb186 100644
937 --- a/crypto/srp/srp_vfy.c
938 +++ b/crypto/srp/srp_vfy.c
939 @@ -225,6 +225,7 @@ static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
940 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info)));
941 }
942
943 +#ifndef OPENSSL_NO_STDIO
944 static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
945 const char *v)
946 {
947 @@ -239,6 +240,7 @@ static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
948 len = t_fromb64(tmp, s);
949 return ((vinfo->s = BN_bin2bn(tmp, len, NULL)) != NULL);
950 }
951 +#endif
952
953 static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
954 {
955 @@ -279,6 +281,7 @@ int SRP_VBASE_free(SRP_VBASE *vb)
956 return 0;
957 }
958
959 +#ifndef OPENSSL_NO_STDIO
960 static SRP_gN_cache *SRP_gN_new_init(const char *ch)
961 {
962 unsigned char tmp[MAX_LEN];
963 @@ -310,6 +313,7 @@ static void SRP_gN_free(SRP_gN_cache *gN_cache)
964 BN_free(gN_cache->bn);
965 OPENSSL_free(gN_cache);
966 }
967 +#endif
968
969 static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
970 {
971 @@ -326,6 +330,7 @@ static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
972 return SRP_get_default_gN(id);
973 }
974
975 +#ifndef OPENSSL_NO_STDIO
976 static BIGNUM *SRP_gN_place_bn(STACK_OF(SRP_gN_cache) *gN_cache, char *ch)
977 {
978 int i;
979 @@ -467,6 +472,7 @@ int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
980 return error_code;
981
982 }
983 +#endif
984
985 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)
986 {
987 diff --git a/crypto/ts/ts.h b/crypto/ts/ts.h
988 index 16eccbb..a9fe40e 100644
989 --- a/crypto/ts/ts.h
990 +++ b/crypto/ts/ts.h
991 @@ -281,8 +281,10 @@ TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);
992
993 TS_REQ *TS_REQ_dup(TS_REQ *a);
994
995 +#ifndef OPENSSL_NO_FP_API
996 TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);
997 int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);
998 +#endif
999 TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);
1000 int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);
1001
1002 @@ -294,10 +296,12 @@ TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,
1003
1004 TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);
1005
1006 +#ifndef OPENSSL_NO_FP_API
1007 TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);
1008 int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);
1009 -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);
1010 -int i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);
1011 +#endif
1012 +TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);
1013 +int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);
1014
1015 TS_RESP *TS_RESP_new(void);
1016 void TS_RESP_free(TS_RESP *a);
1017 @@ -306,10 +310,12 @@ TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);
1018 TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);
1019 TS_RESP *TS_RESP_dup(TS_RESP *a);
1020
1021 +#ifndef OPENSSL_NO_FP_API
1022 TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);
1023 int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);
1024 -TS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);
1025 -int i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);
1026 +#endif
1027 +TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);
1028 +int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);
1029
1030 TS_STATUS_INFO *TS_STATUS_INFO_new(void);
1031 void TS_STATUS_INFO_free(TS_STATUS_INFO *a);
1032 @@ -325,10 +331,12 @@ TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,
1033 long length);
1034 TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);
1035
1036 +#ifndef OPENSSL_NO_FP_API
1037 TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);
1038 int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);
1039 -TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);
1040 -int i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);
1041 +#endif
1042 +TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);
1043 +int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);
1044
1045 TS_ACCURACY *TS_ACCURACY_new(void);
1046 void TS_ACCURACY_free(TS_ACCURACY *a);
1047 @@ -728,15 +736,18 @@ int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);
1048 * ts/ts_conf.c
1049 */
1050
1051 +#ifndef OPENSSL_NO_STDIO
1052 X509 *TS_CONF_load_cert(const char *file);
1053 STACK_OF(X509) *TS_CONF_load_certs(const char *file);
1054 EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);
1055 +#endif
1056 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section);
1057 int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,
1058 TS_RESP_CTX *ctx);
1059 int TS_CONF_set_crypto_device(CONF *conf, const char *section,
1060 const char *device);
1061 int TS_CONF_set_default_engine(const char *name);
1062 +#ifndef OPENSSL_NO_STDIO
1063 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
1064 const char *cert, TS_RESP_CTX *ctx);
1065 int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
1066 @@ -744,6 +755,7 @@ int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
1067 int TS_CONF_set_signer_key(CONF *conf, const char *section,
1068 const char *key, const char *pass,
1069 TS_RESP_CTX *ctx);
1070 +#endif
1071 int TS_CONF_set_def_policy(CONF *conf, const char *section,
1072 const char *policy, TS_RESP_CTX *ctx);
1073 int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);
1074 @@ -784,6 +796,11 @@ void ERR_load_TS_strings(void);
1075 # define TS_F_TS_CHECK_SIGNING_CERTS 103
1076 # define TS_F_TS_CHECK_STATUS_INFO 104
1077 # define TS_F_TS_COMPUTE_IMPRINT 145
1078 +# define TS_F_TS_CONF_INVALID 151
1079 +# define TS_F_TS_CONF_LOAD_CERT 153
1080 +# define TS_F_TS_CONF_LOAD_CERTS 154
1081 +# define TS_F_TS_CONF_LOAD_KEY 155
1082 +# define TS_F_TS_CONF_LOOKUP_FAIL 152
1083 # define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146
1084 # define TS_F_TS_GET_STATUS_TEXT 105
1085 # define TS_F_TS_MSG_IMPRINT_SET_ALGO 118
1086 @@ -822,6 +839,8 @@ void ERR_load_TS_strings(void);
1087 /* Reason codes. */
1088 # define TS_R_BAD_PKCS7_TYPE 132
1089 # define TS_R_BAD_TYPE 133
1090 +# define TS_R_CANNOT_LOAD_CERT 137
1091 +# define TS_R_CANNOT_LOAD_KEY 138
1092 # define TS_R_CERTIFICATE_VERIFY_ERROR 100
1093 # define TS_R_COULD_NOT_SET_ENGINE 127
1094 # define TS_R_COULD_NOT_SET_TIME 115
1095 @@ -854,6 +873,8 @@ void ERR_load_TS_strings(void);
1096 # define TS_R_UNACCEPTABLE_POLICY 125
1097 # define TS_R_UNSUPPORTED_MD_ALGORITHM 126
1098 # define TS_R_UNSUPPORTED_VERSION 113
1099 +# define TS_R_VAR_BAD_VALUE 135
1100 +# define TS_R_VAR_LOOKUP_FAILURE 136
1101 # define TS_R_WRONG_CONTENT_TYPE 114
1102
1103 #ifdef __cplusplus
1104 diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c
1105 index 4716b23..c4416ba 100644
1106 --- a/crypto/ts/ts_conf.c
1107 +++ b/crypto/ts/ts_conf.c
1108 @@ -92,6 +92,7 @@
1109
1110 /* Function definitions for certificate and key loading. */
1111
1112 +#ifndef OPENSSL_NO_STDIO
1113 X509 *TS_CONF_load_cert(const char *file)
1114 {
1115 BIO *cert = NULL;
1116 @@ -102,7 +103,7 @@ X509 *TS_CONF_load_cert(const char *file)
1117 x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
1118 end:
1119 if (x == NULL)
1120 - fprintf(stderr, "unable to load certificate: %s\n", file);
1121 + TSerr(TS_F_TS_CONF_LOAD_CERT, TS_R_CANNOT_LOAD_CERT);
1122 BIO_free(cert);
1123 return x;
1124 }
1125 @@ -129,7 +130,7 @@ STACK_OF(X509) *TS_CONF_load_certs(const char *file)
1126 }
1127 end:
1128 if (othercerts == NULL)
1129 - fprintf(stderr, "unable to load certificates: %s\n", file);
1130 + TSerr(TS_F_TS_CONF_LOAD_CERTS, TS_R_CANNOT_LOAD_CERT);
1131 sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
1132 BIO_free(certs);
1133 return othercerts;
1134 @@ -145,21 +146,24 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass)
1135 pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass);
1136 end:
1137 if (pkey == NULL)
1138 - fprintf(stderr, "unable to load private key: %s\n", file);
1139 + TSerr(TS_F_TS_CONF_LOAD_KEY, TS_R_CANNOT_LOAD_KEY);
1140 BIO_free(key);
1141 return pkey;
1142 }
1143 +#endif /* !OPENSSL_NO_STDIO */
1144
1145 /* Function definitions for handling configuration options. */
1146
1147 static void TS_CONF_lookup_fail(const char *name, const char *tag)
1148 {
1149 - fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag);
1150 + TSerr(TS_F_TS_CONF_LOOKUP_FAIL, TS_R_VAR_LOOKUP_FAILURE);
1151 + ERR_add_error_data(3, name, "::", tag);
1152 }
1153
1154 static void TS_CONF_invalid(const char *name, const char *tag)
1155 {
1156 - fprintf(stderr, "invalid variable value for %s::%s\n", name, tag);
1157 + TSerr(TS_F_TS_CONF_INVALID, TS_R_VAR_BAD_VALUE);
1158 + ERR_add_error_data(3, name, "::", tag);
1159 }
1160
1161 const char *TS_CONF_get_tsa_section(CONF *conf, const char *section)
1162 @@ -237,6 +241,7 @@ int TS_CONF_set_default_engine(const char *name)
1163
1164 #endif
1165
1166 +#ifndef OPENSSL_NO_STDIO
1167 int TS_CONF_set_signer_cert(CONF *conf, const char *section,
1168 const char *cert, TS_RESP_CTX *ctx)
1169 {
1170 @@ -302,6 +307,7 @@ int TS_CONF_set_signer_key(CONF *conf, const char *section,
1171 EVP_PKEY_free(key_obj);
1172 return ret;
1173 }
1174 +#endif /* !OPENSSL_NO_STDIO */
1175
1176 int TS_CONF_set_def_policy(CONF *conf, const char *section,
1177 const char *policy, TS_RESP_CTX *ctx)
1178 diff --git a/crypto/ts/ts_err.c b/crypto/ts/ts_err.c
1179 index ff1abf4..3f5b78f 100644
1180 --- a/crypto/ts/ts_err.c
1181 +++ b/crypto/ts/ts_err.c
1182 @@ -1,6 +1,6 @@
1183 /* crypto/ts/ts_err.c */
1184 /* ====================================================================
1185 - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
1186 + * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
1187 *
1188 * Redistribution and use in source and binary forms, with or without
1189 * modification, are permitted provided that the following conditions
1190 @@ -87,6 +87,11 @@ static ERR_STRING_DATA TS_str_functs[] = {
1191 {ERR_FUNC(TS_F_TS_CHECK_SIGNING_CERTS), "TS_CHECK_SIGNING_CERTS"},
1192 {ERR_FUNC(TS_F_TS_CHECK_STATUS_INFO), "TS_CHECK_STATUS_INFO"},
1193 {ERR_FUNC(TS_F_TS_COMPUTE_IMPRINT), "TS_COMPUTE_IMPRINT"},
1194 + {ERR_FUNC(TS_F_TS_CONF_INVALID), "ts_CONF_invalid"},
1195 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERT), "TS_CONF_load_cert"},
1196 + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERTS), "TS_CONF_load_certs"},
1197 + {ERR_FUNC(TS_F_TS_CONF_LOAD_KEY), "TS_CONF_load_key"},
1198 + {ERR_FUNC(TS_F_TS_CONF_LOOKUP_FAIL), "ts_CONF_lookup_fail"},
1199 {ERR_FUNC(TS_F_TS_CONF_SET_DEFAULT_ENGINE), "TS_CONF_set_default_engine"},
1200 {ERR_FUNC(TS_F_TS_GET_STATUS_TEXT), "TS_GET_STATUS_TEXT"},
1201 {ERR_FUNC(TS_F_TS_MSG_IMPRINT_SET_ALGO), "TS_MSG_IMPRINT_set_algo"},
1202 @@ -132,6 +137,8 @@ static ERR_STRING_DATA TS_str_functs[] = {
1203 static ERR_STRING_DATA TS_str_reasons[] = {
1204 {ERR_REASON(TS_R_BAD_PKCS7_TYPE), "bad pkcs7 type"},
1205 {ERR_REASON(TS_R_BAD_TYPE), "bad type"},
1206 + {ERR_REASON(TS_R_CANNOT_LOAD_CERT), "cannot load certificate"},
1207 + {ERR_REASON(TS_R_CANNOT_LOAD_KEY), "cannot load private key"},
1208 {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"},
1209 {ERR_REASON(TS_R_COULD_NOT_SET_ENGINE), "could not set engine"},
1210 {ERR_REASON(TS_R_COULD_NOT_SET_TIME), "could not set time"},
1211 @@ -170,6 +177,8 @@ static ERR_STRING_DATA TS_str_reasons[] = {
1212 {ERR_REASON(TS_R_UNACCEPTABLE_POLICY), "unacceptable policy"},
1213 {ERR_REASON(TS_R_UNSUPPORTED_MD_ALGORITHM), "unsupported md algorithm"},
1214 {ERR_REASON(TS_R_UNSUPPORTED_VERSION), "unsupported version"},
1215 + {ERR_REASON(TS_R_VAR_BAD_VALUE), "var bad value"},
1216 + {ERR_REASON(TS_R_VAR_LOOKUP_FAILURE), "cannot find config variable"},
1217 {ERR_REASON(TS_R_WRONG_CONTENT_TYPE), "wrong content type"},
1218 {0, NULL}
1219 };
1220 diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c
1221 index 0f29011..80dd40e 100644
1222 --- a/crypto/ui/ui_util.c
1223 +++ b/crypto/ui/ui_util.c
1224 @@ -56,6 +56,10 @@
1225 #include <string.h>
1226 #include "ui_locl.h"
1227
1228 +#ifndef BUFSIZ
1229 +#define BUFSIZ 256
1230 +#endif
1231 +
1232 int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
1233 int verify)
1234 {
1235 diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
1236 index 9ee8f8d..64b052e 100644
1237 --- a/crypto/x509/by_dir.c
1238 +++ b/crypto/x509/by_dir.c
1239 @@ -69,6 +69,8 @@
1240 # include <sys/stat.h>
1241 #endif
1242
1243 +#ifndef OPENSSL_NO_STDIO
1244 +
1245 #include <openssl/lhash.h>
1246 #include <openssl/x509.h>
1247
1248 @@ -434,3 +436,5 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
1249 BUF_MEM_free(b);
1250 return (ok);
1251 }
1252 +
1253 +#endif /* OPENSSL_NO_STDIO */
1254 diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
1255 index 0429767..7ddc21c 100644
1256 --- a/crypto/x509/x509_vfy.c
1257 +++ b/crypto/x509/x509_vfy.c
1258 @@ -940,6 +940,8 @@ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
1259 ctx->current_crl = crl;
1260 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1261 ptime = &ctx->param->check_time;
1262 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
1263 + return 1;
1264 else
1265 ptime = NULL;
1266
1267 @@ -1663,6 +1665,8 @@ static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
1268
1269 if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1270 ptime = &ctx->param->check_time;
1271 + else if (ctx->param->flags & X509_V_FLAG_NO_CHECK_TIME)
1272 + return 1;
1273 else
1274 ptime = NULL;
1275
1276 diff --git a/crypto/x509/x509_vfy.h b/crypto/x509/x509_vfy.h
1277 index 2663e1c..3790ef5 100644
1278 --- a/crypto/x509/x509_vfy.h
1279 +++ b/crypto/x509/x509_vfy.h
1280 @@ -438,6 +438,8 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
1281 * will force the behaviour to match that of previous versions.
1282 */
1283 # define X509_V_FLAG_NO_ALT_CHAINS 0x100000
1284 +/* Do not check certificate/CRL validity against current time */
1285 +# define X509_V_FLAG_NO_CHECK_TIME 0x200000
1286
1287 # define X509_VP_FLAG_DEFAULT 0x1
1288 # define X509_VP_FLAG_OVERWRITE 0x2
1289 @@ -490,9 +492,10 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
1290 X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);
1291
1292 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
1293 -
1294 +#ifndef OPENSSL_NO_STDIO
1295 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
1296 X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
1297 +#endif
1298
1299 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
1300 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
1301 diff --git a/crypto/x509v3/ext_dat.h b/crypto/x509v3/ext_dat.h
1302 index c3a6fce..01edd2a 100644
1303 --- a/crypto/x509v3/ext_dat.h
1304 +++ b/crypto/x509v3/ext_dat.h
1305 @@ -127,8 +127,10 @@ static const X509V3_EXT_METHOD *standard_exts[] = {
1306 &v3_idp,
1307 &v3_alt[2],
1308 &v3_freshest_crl,
1309 +#ifndef OPENSSL_SYS_UEFI
1310 &v3_ct_scts[0],
1311 &v3_ct_scts[1],
1312 +#endif
1313 };
1314
1315 /* Number of standard extensions */
1316 diff --git a/crypto/x509v3/v3_pci.c b/crypto/x509v3/v3_pci.c
1317 index 34cad53..12f12a7 100644
1318 --- a/crypto/x509v3/v3_pci.c
1319 +++ b/crypto/x509v3/v3_pci.c
1320 @@ -149,6 +149,7 @@ static int process_pci_value(CONF_VALUE *val,
1321 goto err;
1322 }
1323 OPENSSL_free(tmp_data2);
1324 +#ifndef OPENSSL_NO_STDIO
1325 } else if (strncmp(val->value, "file:", 5) == 0) {
1326 unsigned char buf[2048];
1327 int n;
1328 @@ -181,6 +182,7 @@ static int process_pci_value(CONF_VALUE *val,
1329 X509V3_conf_err(val);
1330 goto err;
1331 }
1332 +#endif /* !OPENSSL_NO_STDIO */
1333 } else if (strncmp(val->value, "text:", 5) == 0) {
1334 val_len = strlen(val->value + 5);
1335 tmp_data = OPENSSL_realloc((*policy)->data,
1336 diff --git a/crypto/x509v3/x509v3.h b/crypto/x509v3/x509v3.h
1337 index f5c6156..a2e78aa 100644
1338 --- a/crypto/x509v3/x509v3.h
1339 +++ b/crypto/x509v3/x509v3.h
1340 @@ -688,8 +688,9 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
1341 int ml);
1342 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
1343 int indent);
1344 +#ifndef OPENSSL_NO_FP_API
1345 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
1346 -
1347 +#endif
1348 int X509V3_extensions_print(BIO *out, char *title,
1349 STACK_OF(X509_EXTENSION) *exts,
1350 unsigned long flag, int indent);
1351 diff --git a/demos/engines/cluster_labs/hw_cluster_labs_err.h b/demos/engines/cluster_labs/hw_cluster_labs_err.h
1352 index 3300e11..e9e58d5 100644
1353 --- a/demos/engines/cluster_labs/hw_cluster_labs_err.h
1354 +++ b/demos/engines/cluster_labs/hw_cluster_labs_err.h
1355 @@ -67,7 +67,7 @@ extern "C" {
1356 static void ERR_load_CL_strings(void);
1357 static void ERR_unload_CL_strings(void);
1358 static void ERR_CL_error(int function, int reason, char *file, int line);
1359 -# define CLerr(f,r) ERR_CL_error((f),(r),__FILE__,__LINE__)
1360 +# define CLerr(f,r) ERR_CL_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1361
1362 /* Error codes for the CL functions. */
1363
1364 diff --git a/demos/engines/ibmca/hw_ibmca_err.h b/demos/engines/ibmca/hw_ibmca_err.h
1365 index c17e0c9..10d0212 100644
1366 --- a/demos/engines/ibmca/hw_ibmca_err.h
1367 +++ b/demos/engines/ibmca/hw_ibmca_err.h
1368 @@ -67,7 +67,7 @@ extern "C" {
1369 static void ERR_load_IBMCA_strings(void);
1370 static void ERR_unload_IBMCA_strings(void);
1371 static void ERR_IBMCA_error(int function, int reason, char *file, int line);
1372 -# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),__FILE__,__LINE__)
1373 +# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1374
1375 /* Error codes for the IBMCA functions. */
1376
1377 diff --git a/demos/engines/rsaref/rsaref_err.h b/demos/engines/rsaref/rsaref_err.h
1378 index 4356815..598836f 100644
1379 --- a/demos/engines/rsaref/rsaref_err.h
1380 +++ b/demos/engines/rsaref/rsaref_err.h
1381 @@ -68,7 +68,7 @@ extern "C" {
1382 static void ERR_load_RSAREF_strings(void);
1383 static void ERR_unload_RSAREF_strings(void);
1384 static void ERR_RSAREF_error(int function, int reason, char *file, int line);
1385 -# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),__FILE__,__LINE__)
1386 +# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1387 /* Error codes for the RSAREF functions. */
1388
1389 /* Function codes. */
1390 diff --git a/demos/engines/zencod/hw_zencod_err.h b/demos/engines/zencod/hw_zencod_err.h
1391 index f4a8358..94d3293 100644
1392 --- a/demos/engines/zencod/hw_zencod_err.h
1393 +++ b/demos/engines/zencod/hw_zencod_err.h
1394 @@ -67,7 +67,7 @@ extern "C" {
1395 static void ERR_load_ZENCOD_strings(void);
1396 static void ERR_unload_ZENCOD_strings(void);
1397 static void ERR_ZENCOD_error(int function, int reason, char *file, int line);
1398 -# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),__FILE__,__LINE__)
1399 +# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1400
1401 /* Error codes for the ZENCOD functions. */
1402
1403 diff --git a/doc/crypto/threads.pod b/doc/crypto/threads.pod
1404 index dc0e939..fe123bb 100644
1405 --- a/doc/crypto/threads.pod
1406 +++ b/doc/crypto/threads.pod
1407 @@ -51,15 +51,15 @@ CRYPTO_destroy_dynlockid, CRYPTO_lock - OpenSSL thread support
1408 void CRYPTO_lock(int mode, int n, const char *file, int line);
1409
1410 #define CRYPTO_w_lock(type) \
1411 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
1412 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
1413 #define CRYPTO_w_unlock(type) \
1414 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
1415 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,OPENSSL_FILE,OPENSSL_LINE)
1416 #define CRYPTO_r_lock(type) \
1417 - CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
1418 + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
1419 #define CRYPTO_r_unlock(type) \
1420 - CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
1421 + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,OPENSSL_FILE,OPENSSL_LINE)
1422 #define CRYPTO_add(addr,amount,type) \
1423 - CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
1424 + CRYPTO_add_lock(addr,amount,type,OPENSSL_FILE,OPENSSL_LINE)
1425
1426 =head1 DESCRIPTION
1427
1428 diff --git a/e_os.h b/e_os.h
1429 index 1fa36c1..3e9dae2 100644
1430 --- a/e_os.h
1431 +++ b/e_os.h
1432 @@ -136,7 +136,7 @@ extern "C" {
1433 # define MSDOS
1434 # endif
1435
1436 -# if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
1437 +# if (defined(MSDOS) || defined(OPENSSL_SYS_UEFI)) && !defined(GETPID_IS_MEANINGLESS)
1438 # define GETPID_IS_MEANINGLESS
1439 # endif
1440
1441 diff --git a/e_os2.h b/e_os2.h
1442 index 7be9989..909e22f 100644
1443 --- a/e_os2.h
1444 +++ b/e_os2.h
1445 @@ -97,7 +97,14 @@ extern "C" {
1446 * For 32 bit environment, there seems to be the CygWin environment and then
1447 * all the others that try to do the same thing Microsoft does...
1448 */
1449 -# if defined(OPENSSL_SYSNAME_UWIN)
1450 +/*
1451 + * UEFI lives here because it might be built with a Microsoft toolchain and
1452 + * we need to avoid the false positive match on Windows.
1453 + */
1454 +# if defined(OPENSSL_SYSNAME_UEFI)
1455 +# undef OPENSSL_SYS_UNIX
1456 +# define OPENSSL_SYS_UEFI
1457 +# elif defined(OPENSSL_SYSNAME_UWIN)
1458 # undef OPENSSL_SYS_UNIX
1459 # define OPENSSL_SYS_WIN32_UWIN
1460 # else
1461 diff --git a/engines/ccgost/e_gost_err.h b/engines/ccgost/e_gost_err.h
1462 index a2018ec..9eacdcf 100644
1463 --- a/engines/ccgost/e_gost_err.h
1464 +++ b/engines/ccgost/e_gost_err.h
1465 @@ -67,7 +67,7 @@ extern "C" {
1466 void ERR_load_GOST_strings(void);
1467 void ERR_unload_GOST_strings(void);
1468 void ERR_GOST_error(int function, int reason, char *file, int line);
1469 -# define GOSTerr(f,r) ERR_GOST_error((f),(r),__FILE__,__LINE__)
1470 +# define GOSTerr(f,r) ERR_GOST_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1471
1472 /* Error codes for the GOST functions. */
1473
1474 diff --git a/engines/e_4758cca_err.h b/engines/e_4758cca_err.h
1475 index 2f29d96..47a2635 100644
1476 --- a/engines/e_4758cca_err.h
1477 +++ b/engines/e_4758cca_err.h
1478 @@ -67,7 +67,7 @@ extern "C" {
1479 static void ERR_load_CCA4758_strings(void);
1480 static void ERR_unload_CCA4758_strings(void);
1481 static void ERR_CCA4758_error(int function, int reason, char *file, int line);
1482 -# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),__FILE__,__LINE__)
1483 +# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1484
1485 /* Error codes for the CCA4758 functions. */
1486
1487 diff --git a/engines/e_aep_err.h b/engines/e_aep_err.h
1488 index 2ed0114..1f8fa5b 100644
1489 --- a/engines/e_aep_err.h
1490 +++ b/engines/e_aep_err.h
1491 @@ -67,7 +67,7 @@ extern "C" {
1492 static void ERR_load_AEPHK_strings(void);
1493 static void ERR_unload_AEPHK_strings(void);
1494 static void ERR_AEPHK_error(int function, int reason, char *file, int line);
1495 -# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),__FILE__,__LINE__)
1496 +# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1497
1498 /* Error codes for the AEPHK functions. */
1499
1500 diff --git a/engines/e_atalla_err.h b/engines/e_atalla_err.h
1501 index 7b71eff..d958496 100644
1502 --- a/engines/e_atalla_err.h
1503 +++ b/engines/e_atalla_err.h
1504 @@ -67,7 +67,7 @@ extern "C" {
1505 static void ERR_load_ATALLA_strings(void);
1506 static void ERR_unload_ATALLA_strings(void);
1507 static void ERR_ATALLA_error(int function, int reason, char *file, int line);
1508 -# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__)
1509 +# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1510
1511 /* Error codes for the ATALLA functions. */
1512
1513 diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h
1514 index b5d06dc..cfe46b1 100644
1515 --- a/engines/e_capi_err.h
1516 +++ b/engines/e_capi_err.h
1517 @@ -67,7 +67,7 @@ extern "C" {
1518 static void ERR_load_CAPI_strings(void);
1519 static void ERR_unload_CAPI_strings(void);
1520 static void ERR_CAPI_error(int function, int reason, char *file, int line);
1521 -# define CAPIerr(f,r) ERR_CAPI_error((f),(r),__FILE__,__LINE__)
1522 +# define CAPIerr(f,r) ERR_CAPI_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1523
1524 /* Error codes for the CAPI functions. */
1525
1526 diff --git a/engines/e_chil_err.h b/engines/e_chil_err.h
1527 index d86a4ce..3d961b9 100644
1528 --- a/engines/e_chil_err.h
1529 +++ b/engines/e_chil_err.h
1530 @@ -67,7 +67,7 @@ extern "C" {
1531 static void ERR_load_HWCRHK_strings(void);
1532 static void ERR_unload_HWCRHK_strings(void);
1533 static void ERR_HWCRHK_error(int function, int reason, char *file, int line);
1534 -# define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),__FILE__,__LINE__)
1535 +# define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1536
1537 /* Error codes for the HWCRHK functions. */
1538
1539 diff --git a/engines/e_cswift_err.h b/engines/e_cswift_err.h
1540 index fde3a82..7c20691 100644
1541 --- a/engines/e_cswift_err.h
1542 +++ b/engines/e_cswift_err.h
1543 @@ -67,7 +67,7 @@ extern "C" {
1544 static void ERR_load_CSWIFT_strings(void);
1545 static void ERR_unload_CSWIFT_strings(void);
1546 static void ERR_CSWIFT_error(int function, int reason, char *file, int line);
1547 -# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__)
1548 +# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1549
1550 /* Error codes for the CSWIFT functions. */
1551
1552 diff --git a/engines/e_gmp_err.h b/engines/e_gmp_err.h
1553 index 637abbc..ccaf3da 100644
1554 --- a/engines/e_gmp_err.h
1555 +++ b/engines/e_gmp_err.h
1556 @@ -67,7 +67,7 @@ extern "C" {
1557 static void ERR_load_GMP_strings(void);
1558 static void ERR_unload_GMP_strings(void);
1559 static void ERR_GMP_error(int function, int reason, char *file, int line);
1560 -# define GMPerr(f,r) ERR_GMP_error((f),(r),__FILE__,__LINE__)
1561 +# define GMPerr(f,r) ERR_GMP_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1562
1563 /* Error codes for the GMP functions. */
1564
1565 diff --git a/engines/e_nuron_err.h b/engines/e_nuron_err.h
1566 index aa7849c..e607d3e 100644
1567 --- a/engines/e_nuron_err.h
1568 +++ b/engines/e_nuron_err.h
1569 @@ -67,7 +67,7 @@ extern "C" {
1570 static void ERR_load_NURON_strings(void);
1571 static void ERR_unload_NURON_strings(void);
1572 static void ERR_NURON_error(int function, int reason, char *file, int line);
1573 -# define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__)
1574 +# define NURONerr(f,r) ERR_NURON_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1575
1576 /* Error codes for the NURON functions. */
1577
1578 diff --git a/engines/e_sureware_err.h b/engines/e_sureware_err.h
1579 index bef8623..54f2848 100644
1580 --- a/engines/e_sureware_err.h
1581 +++ b/engines/e_sureware_err.h
1582 @@ -68,7 +68,7 @@ static void ERR_load_SUREWARE_strings(void);
1583 static void ERR_unload_SUREWARE_strings(void);
1584 static void ERR_SUREWARE_error(int function, int reason, char *file,
1585 int line);
1586 -# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),__FILE__,__LINE__)
1587 +# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1588
1589 /* Error codes for the SUREWARE functions. */
1590
1591 diff --git a/engines/e_ubsec_err.h b/engines/e_ubsec_err.h
1592 index c8aec7c..67110ed 100644
1593 --- a/engines/e_ubsec_err.h
1594 +++ b/engines/e_ubsec_err.h
1595 @@ -67,7 +67,7 @@ extern "C" {
1596 static void ERR_load_UBSEC_strings(void);
1597 static void ERR_unload_UBSEC_strings(void);
1598 static void ERR_UBSEC_error(int function, int reason, char *file, int line);
1599 -# define UBSECerr(f,r) ERR_UBSEC_error((f),(r),__FILE__,__LINE__)
1600 +# define UBSECerr(f,r) ERR_UBSEC_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1601
1602 /* Error codes for the UBSEC functions. */
1603
1604 diff --git a/ssl/d1_both.c b/ssl/d1_both.c
1605 index d1fc716..d5f661a 100644
1606 --- a/ssl/d1_both.c
1607 +++ b/ssl/d1_both.c
1608 @@ -1053,7 +1053,7 @@ int dtls1_send_change_cipher_spec(SSL *s, int a, int b)
1609 int dtls1_read_failed(SSL *s, int code)
1610 {
1611 if (code > 0) {
1612 - fprintf(stderr, "invalid state reached %s:%d", __FILE__, __LINE__);
1613 + fprintf(stderr, "dtls1_read_failed(); invalid state reached\n");
1614 return 1;
1615 }
1616
1617 diff --git a/ssl/ssl_asn1.c b/ssl/ssl_asn1.c
1618 index 35cc27c..a1f5335 100644
1619 --- a/ssl/ssl_asn1.c
1620 +++ b/ssl/ssl_asn1.c
1621 @@ -418,7 +418,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1622 if (ssl_version == SSL2_VERSION) {
1623 if (os.length != 3) {
1624 c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH;
1625 - c.line = __LINE__;
1626 + c.line = OPENSSL_LINE;
1627 goto err;
1628 }
1629 id = 0x02000000L |
1630 @@ -429,14 +429,14 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1631 || ssl_version == DTLS1_BAD_VER) {
1632 if (os.length != 2) {
1633 c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH;
1634 - c.line = __LINE__;
1635 + c.line = OPENSSL_LINE;
1636 goto err;
1637 }
1638 id = 0x03000000L |
1639 ((unsigned long)os.data[0] << 8L) | (unsigned long)os.data[1];
1640 } else {
1641 c.error = SSL_R_UNKNOWN_SSL_VERSION;
1642 - c.line = __LINE__;
1643 + c.line = OPENSSL_LINE;
1644 goto err;
1645 }
1646
1647 @@ -526,7 +526,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
1648 if (os.data != NULL) {
1649 if (os.length > SSL_MAX_SID_CTX_LENGTH) {
1650 c.error = SSL_R_BAD_LENGTH;
1651 - c.line = __LINE__;
1652 + c.line = OPENSSL_LINE;
1653 goto err;
1654 } else {
1655 ret->sid_ctx_length = os.length;
1656 diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
1657 index a73f866..d534c0a 100644
1658 --- a/ssl/ssl_cert.c
1659 +++ b/ssl/ssl_cert.c
1660 @@ -855,12 +855,13 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x)
1661 return (add_client_CA(&(ctx->client_CA), x));
1662 }
1663
1664 +#ifndef OPENSSL_NO_STDIO
1665 +
1666 static int xname_cmp(const X509_NAME *const *a, const X509_NAME *const *b)
1667 {
1668 return (X509_NAME_cmp(*a, *b));
1669 }
1670
1671 -#ifndef OPENSSL_NO_STDIO
1672 /**
1673 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed;
1674 * it doesn't really have anything to do with clients (except that a common use
1675 @@ -928,7 +929,6 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
1676 ERR_clear_error();
1677 return (ret);
1678 }
1679 -#endif
1680
1681 /**
1682 * Add a file of certs to a stack.
1683 @@ -1048,6 +1048,7 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
1684 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
1685 return ret;
1686 }
1687 +#endif /* !OPENSSL_NO_STDIO */
1688
1689 /* Add a certificate to a BUF_MEM structure */
1690
1691 diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
1692 index 5478840..c2ad7c9 100644
1693 --- a/ssl/ssl_conf.c
1694 +++ b/ssl/ssl_conf.c
1695 @@ -362,6 +362,7 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value)
1696 return CONF_parse_list(value, ',', 1, ssl_set_option_list, cctx);
1697 }
1698
1699 +#ifndef OPENSSL_NO_STDIO
1700 static int cmd_Certificate(SSL_CONF_CTX *cctx, const char *value)
1701 {
1702 int rv = 1;
1703 @@ -428,7 +429,9 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
1704 BIO_free(in);
1705 return rv > 0;
1706 }
1707 -#endif
1708 +#endif /* !OPENSSL_NO_DH */
1709 +#endif /* !OPENSSL_NO_STDIO */
1710 +
1711 typedef struct {
1712 int (*cmd) (SSL_CONF_CTX *cctx, const char *value);
1713 const char *str_file;
1714 @@ -454,12 +457,14 @@ static const ssl_conf_cmd_tbl ssl_conf_cmds[] = {
1715 SSL_CONF_CMD_STRING(CipherString, "cipher"),
1716 SSL_CONF_CMD_STRING(Protocol, NULL),
1717 SSL_CONF_CMD_STRING(Options, NULL),
1718 +#ifndef OPENSSL_NO_STDIO
1719 SSL_CONF_CMD(Certificate, "cert", SSL_CONF_TYPE_FILE),
1720 SSL_CONF_CMD(PrivateKey, "key", SSL_CONF_TYPE_FILE),
1721 SSL_CONF_CMD(ServerInfoFile, NULL, SSL_CONF_TYPE_FILE),
1722 #ifndef OPENSSL_NO_DH
1723 SSL_CONF_CMD(DHParameters, "dhparam", SSL_CONF_TYPE_FILE)
1724 #endif
1725 +#endif
1726 };
1727
1728 static int ssl_conf_cmd_skip_prefix(SSL_CONF_CTX *cctx, const char **pcmd)
1729 diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
1730 index 514fcb3..2a54cc9 100644
1731 --- a/ssl/t1_enc.c
1732 +++ b/ssl/t1_enc.c
1733 @@ -780,9 +780,7 @@ int tls1_enc(SSL *s, int send)
1734 * we can't write into the input stream: Can this ever
1735 * happen?? (steve)
1736 */
1737 - fprintf(stderr,
1738 - "%s:%d: rec->data != rec->input\n",
1739 - __FILE__, __LINE__);
1740 + fprintf(stderr, "tls1_enc: rec->data != rec->input\n");
1741 else if (RAND_bytes(rec->input, ivlen) <= 0)
1742 return -1;
1743 }
1744 diff --git a/util/mkerr.pl b/util/mkerr.pl
1745 index 09ebebe..cd57ade 100644
1746 --- a/util/mkerr.pl
1747 +++ b/util/mkerr.pl
1748 @@ -89,7 +89,7 @@ Options:
1749 void ERR_load_<LIB>_strings(void);
1750 void ERR_unload_<LIB>_strings(void);
1751 void ERR_<LIB>_error(int f, int r, char *fn, int ln);
1752 - #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__)
1753 + #define <LIB>err(f,r) ERR_<LIB>_error(f,r,OPENSSL_FILE,OPENSSL_LINE)
1754 while the code facilitates the use of these in an environment
1755 where the error support routines are dynamically loaded at
1756 runtime.
1757 @@ -474,7 +474,7 @@ EOF
1758 ${staticloader}void ERR_load_${lib}_strings(void);
1759 ${staticloader}void ERR_unload_${lib}_strings(void);
1760 ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
1761 -# define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
1762 +# define ${lib}err(f,r) ERR_${lib}_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
1763
1764 EOF
1765 }