summaryrefslogtreecommitdiff
path: root/sysutils/radmind/patches/patch-stor.c
blob: 33621785d84494e7a86fc354c4d762a6b41a9dd6 (plain)
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
$NetBSD: patch-stor.c,v 1.1 2019/05/03 11:04:34 hauke Exp $

Move to openssl 1.1 api

--- stor.c.orig	2010-12-13 03:42:49.000000000 +0000
+++ stor.c
@@ -32,6 +32,7 @@
 
 #include <snet.h>
 
+#include "openssl_compat.h"
 #include "applefile.h"
 #include "connect.h"
 #include "cksum.h"
@@ -136,7 +137,7 @@ stor_file( SNET *sn, char *pathdesc, cha
     ssize_t             rr, size = 0;
     unsigned int	md_len;
     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 ) ];
 
@@ -146,7 +147,7 @@ stor_file( SNET *sn, char *pathdesc, cha
 	    fprintf( stderr, "line %d: No checksum listed\n", linenum );
 	    exit( 2 );
         }
-	EVP_DigestInit( &mdctx, md );
+	EVP_DigestInit( mdctx, md );
     }
 
     /* Open and stat file */
@@ -202,7 +203,7 @@ stor_file( SNET *sn, char *pathdesc, cha
 	size -= rr;
 	if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
 	if ( cksum ) {
-	    EVP_DigestUpdate( &mdctx, buf, (unsigned int)rr );
+	    EVP_DigestUpdate( mdctx, buf, (unsigned int)rr );
 	}
 	
 	if ( showprogress ) {
@@ -237,8 +238,9 @@ stor_file( SNET *sn, char *pathdesc, cha
 
     /* cksum data sent */
     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 listed in transcript wrong\n", linenum );
@@ -262,7 +264,7 @@ stor_applefile( SNET *sn, char *pathdesc
     unsigned int      	md_len;
     unsigned int	rsrc_len;
     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[ EVP_MAX_MD_SIZE ];
 
@@ -272,7 +274,7 @@ stor_applefile( SNET *sn, char *pathdesc
 	    fprintf( stderr, "line %d: No checksum listed\n", linenum );
 	    exit( 2 );
         }
-        EVP_DigestInit( &mdctx, md );
+        EVP_DigestInit( mdctx, md );
     }
 
     /* Check size listed in transcript */
@@ -339,7 +341,7 @@ stor_applefile( SNET *sn, char *pathdesc
     }
     size -= AS_HEADERLEN;
     if ( cksum ) {
-	EVP_DigestUpdate( &mdctx, (char *)&as_header, AS_HEADERLEN );
+	EVP_DigestUpdate( mdctx, (char *)&as_header, AS_HEADERLEN );
     }
     if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
     if ( showprogress ) {
@@ -357,7 +359,7 @@ stor_applefile( SNET *sn, char *pathdesc
     }
     size -= ( 3 * sizeof( struct as_entry ));
     if ( cksum ) {
-	EVP_DigestUpdate( &mdctx, (char *)&afinfo->as_ents,
+	EVP_DigestUpdate( mdctx, (char *)&afinfo->as_ents,
 	    (unsigned int)( 3 * sizeof( struct as_entry )));
     }
     if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
@@ -375,7 +377,7 @@ stor_applefile( SNET *sn, char *pathdesc
     }
     size -= FINFOLEN;
     if ( cksum ) {
-	EVP_DigestUpdate( &mdctx, afinfo->ai.ai_data, FINFOLEN );
+	EVP_DigestUpdate( mdctx, afinfo->ai.ai_data, FINFOLEN );
     }
     if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
     if ( showprogress ) {
@@ -393,7 +395,7 @@ stor_applefile( SNET *sn, char *pathdesc
 	    }
 	    size -= rc;
 	    if ( cksum ) {
-		EVP_DigestUpdate( &mdctx, buf, (unsigned int)rc );
+		EVP_DigestUpdate( mdctx, buf, (unsigned int)rc );
 	    } 
 	    if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
 	    if ( showprogress ) {
@@ -417,7 +419,7 @@ stor_applefile( SNET *sn, char *pathdesc
 	}
 	size -= rc;
 	if ( cksum ) {
-	    EVP_DigestUpdate( &mdctx, buf, (unsigned int)rc );
+	    EVP_DigestUpdate( mdctx, buf, (unsigned int)rc );
 	}
     	if ( dodots ) { putc( '.', stdout ); fflush( stdout ); }
 	if ( showprogress ) {
@@ -463,8 +465,9 @@ stor_applefile( SNET *sn, char *pathdesc
 
     /* cksum data sent */
     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 listed in transcript wrong\n", linenum );