1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
$NetBSD: patch-retr.c,v 1.4 2019/05/09 09:37:36 hauke Exp $
Remove stale extern declaration
Move to openssl 1.1 api
--- retr.c.orig 2010-12-13 03:42:49.000000000 +0000
+++ retr.c
@@ -31,6 +31,7 @@
#include <snet.h>
+#include "openssl_compat.h"
#include "applefile.h"
#include "connect.h"
#include "cksum.h"
@@ -47,7 +48,6 @@ extern int verbose;
extern int showprogress;
extern int dodots;
extern int cksum;
-extern int errno;
extern int create_prefix;
extern SSL_CTX *ctx;
@@ -74,7 +74,7 @@ retr( SNET *sn, char *pathdesc, char *pa
char buf[ 8192 ];
ssize_t rr;
extern EVP_MD *md;
- EVP_MD_CTX mdctx;
+ EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
unsigned char md_value[ EVP_MAX_MD_SIZE ];
char cksum_b64[ SZ_BASE64_E( EVP_MAX_MD_SIZE ) ];
@@ -84,7 +84,7 @@ retr( SNET *sn, char *pathdesc, char *pa
fprintf( stderr, "%s\n", pathdesc );
return( 1 );
}
- EVP_DigestInit( &mdctx, md );
+ EVP_DigestInit( mdctx, md );
}
if ( verbose ) printf( ">>> RETR %s\n", pathdesc );
@@ -165,7 +165,7 @@ retr( SNET *sn, char *pathdesc, char *pa
goto error2;
}
if ( cksum ) {
- EVP_DigestUpdate( &mdctx, buf, (unsigned int)rr );
+ EVP_DigestUpdate( mdctx, buf, (unsigned int)rr );
}
if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
size -= rr;
@@ -197,8 +197,9 @@ retr( SNET *sn, char *pathdesc, char *pa
/* cksum file */
if ( cksum ) {
- EVP_DigestFinal( &mdctx, md_value, &md_len );
+ EVP_DigestFinal( mdctx, md_value, &md_len );
base64_e( md_value, md_len, cksum_b64 );
+ EVP_MD_CTX_free(mdctx);
if ( strcmp( trancksum, cksum_b64 ) != 0 ) {
fprintf( stderr, "line %d: checksum in transcript does not match "
"checksum from server\n", linenum );
@@ -246,7 +247,7 @@ retr_applefile( SNET *sn, char *pathdesc
struct as_entry ae_ents[ 3 ];
struct timeval tv;
extern EVP_MD *md;
- EVP_MD_CTX mdctx;
+ EVP_MD_CTX *mdctx;
unsigned char md_value[ EVP_MAX_MD_SIZE ];
char cksum_b64[ SZ_BASE64_E( EVP_MAX_MD_SIZE ) ];
@@ -256,7 +257,7 @@ retr_applefile( SNET *sn, char *pathdesc
fprintf( stderr, "%s\n", pathdesc );
return( 1 );
}
- EVP_DigestInit( &mdctx, md );
+ EVP_DigestInit( mdctx, md );
}
if ( verbose ) printf( ">>> RETR %s\n", pathdesc );
@@ -316,7 +317,7 @@ retr_applefile( SNET *sn, char *pathdesc
return( -1 );
}
if ( cksum ) {
- EVP_DigestUpdate( &mdctx, (char *)&ah, (unsigned int)rc );
+ EVP_DigestUpdate( mdctx, (char *)&ah, (unsigned int)rc );
}
/* name temp file */
@@ -373,7 +374,7 @@ retr_applefile( SNET *sn, char *pathdesc
/* Should we check for valid ae_ents here? YES! */
if ( cksum ) {
- EVP_DigestUpdate( &mdctx, (char *)&ae_ents, (unsigned int)rc );
+ EVP_DigestUpdate( mdctx, (char *)&ae_ents, (unsigned int)rc );
}
if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
@@ -398,7 +399,7 @@ retr_applefile( SNET *sn, char *pathdesc
goto error2;
}
if ( cksum ) {
- EVP_DigestUpdate( &mdctx, finfo, (unsigned int)rc );
+ EVP_DigestUpdate( mdctx, finfo, (unsigned int)rc );
}
if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
size -= rc;
@@ -448,7 +449,7 @@ retr_applefile( SNET *sn, char *pathdesc
goto error3;
}
if ( cksum ) {
- EVP_DigestUpdate( &mdctx, buf, (unsigned int)rc );
+ EVP_DigestUpdate( mdctx, buf, (unsigned int)rc );
}
if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
if ( showprogress ) {
@@ -482,7 +483,7 @@ retr_applefile( SNET *sn, char *pathdesc
}
if ( cksum ) {
- EVP_DigestUpdate( &mdctx, buf, (unsigned int)rc );
+ EVP_DigestUpdate( mdctx, buf, (unsigned int)rc );
}
if ( dodots ) { putc( '.', stdout ); fflush( stdout); }
if ( showprogress ) {
@@ -523,8 +524,9 @@ retr_applefile( SNET *sn, char *pathdesc
if ( verbose ) printf( "<<< .\n" );
if ( cksum ) {
- EVP_DigestFinal( &mdctx, md_value, &md_len );
+ EVP_DigestFinal( mdctx, md_value, &md_len );
base64_e(( char*)&md_value, md_len, cksum_b64 );
+ EVP_MD_CTX_free(mdctx);
if ( strcmp( trancksum, cksum_b64 ) != 0 ) {
fprintf( stderr, "line %d: checksum in transcript does not match "
"checksum from server\n", linenum );
|