ObjFW  Diff

Differences From Artifact [634a2aa8de]:

To Artifact [ec67a88887]:


16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32



33
34
35
36
37
38
39
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







+







-
-
-
+
+
+







 */

#include "config.h"

#import "OFApplication.h"
#import "OFArray.h"
#import "OFFile.h"
#import "OFLocale.h"
#import "OFMD5Hash.h"
#import "OFRIPEMD160Hash.h"
#import "OFSHA1Hash.h"
#import "OFSHA224Hash.h"
#import "OFSHA256Hash.h"
#import "OFSHA384Hash.h"
#import "OFSHA512Hash.h"
#import "OFStdIOStream.h"
#import "OFLocale.h"
#import "OFSandbox.h"
#import "OFSandbox.h"
#import "OFSecureData.h"
#import "OFStdIOStream.h"

#import "OFOpenItemFailedException.h"
#import "OFReadFailedException.h"

@interface OFHash: OFObject <OFApplicationDelegate>
@end

76
77
78
79
80
81
82









83

84
85
86
87














88
89
90
91
92
93
94
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







+
+
+
+
+
+
+
+
+
-
+




+
+
+
+
+
+
+
+
+
+
+
+
+
+







{
	OFArray OF_GENERIC(OFString *) *arguments = [OFApplication arguments];
	id <OFCryptoHash> hash;
	bool first = true;
	int exitStatus = 0;

#ifdef OF_HAVE_SANDBOX
	OFSandbox *sandbox;

	/*
	 * SHA-512 is the largest hash supported, so no matter which hash will
	 * be used in the end, this is enough secure memory.
	 */
	[OFSecureData preallocateMemoryWithSize:
	    class_getInstanceSize([OFSHA512Hash class])];

	OFSandbox *sandbox = [[OFSandbox alloc] init];
	sandbox = [[OFSandbox alloc] init];
	@try {
		[sandbox setAllowsStdIO: true];
		[sandbox setAllowsReadingFiles: true];
		[sandbox setAllowsUserDatabaseReading: true];

		for (OFString *path in arguments) {
			if (first) {
				first = false;
				continue;
			}

			[sandbox unveilPath: path
				permissions: @"r"];
		}
		first = true;

		[sandbox unveilPath: @LANGUAGE_DIR
			permissions: @"r"];

		[OFApplication activateSandbox: sandbox];
	} @finally {
		[sandbox release];
	}
#endif