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