Package: boinc / 7.14.2+dfsg-3

fopen_closing.patch Patch series | download
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
Description: this patch makes boinc correctly close the open files.
 This patch allows also MFILE to correctly deallocate its pointers by calling close().
Index: boinc/lib/crypt_prog.cpp
===================================================================
--- boinc.orig/lib/crypt_prog.cpp
+++ boinc/lib/crypt_prog.cpp
@@ -168,6 +168,8 @@
         if (!fpub) die("fopen");
         print_key_hex(fpriv, (KEY*)&private_key, sizeof(private_key));
         print_key_hex(fpub, (KEY*)&public_key, sizeof(public_key));
+	fclose(fpriv);
+	fclose(fpub);
 
     } else if (!strcmp(argv[1], "-sign")) {
         if (argc < 4) {
@@ -182,6 +184,7 @@
         signature.len = 256;
         retval = sign_file(argv[2], private_key, signature);
         print_hex_data(stdout, signature);
+	fclose(fpriv);
     } else if (!strcmp(argv[1], "-sign_string")) {
         if (argc < 4) {
             usage();
@@ -193,6 +196,7 @@
         if (retval) die("scan_key_hex\n");
         generate_signature(argv[2], cbuf, private_key);
         puts(cbuf);
+	fclose(fpriv);
     } else if (!strcmp(argv[1], "-verify")) {
         if (argc < 5) {
             usage();
@@ -207,6 +211,8 @@
         signature.data = signature_buf;
         signature.len = 256;
         retval = scan_hex_data(f, signature);
+	fclose(f);
+	fclose(fpub);
         if (retval) die("scan_hex_data");
 
         char md5_buf[64];
@@ -236,6 +242,8 @@
         if (!fpub) die("fopen");
         retval = scan_key_hex(fpub, (KEY*)&public_key, sizeof(public_key));
         if (retval) die("read_public_key");
+	fclose(fpriv);
+	fclose(fpub);
         strcpy((char*)buf2, "encryption test successful");
         in.data = buf2;
         in.len = strlen((char*)in.data);
@@ -254,6 +262,7 @@
         signature.data = signature_buf;
         signature.len = 256;
         retval = scan_hex_data(f, signature);
+	fclose(f);
         if (retval) die("cannot scan_hex_data");
         certpath = check_validity(argv[4], argv[2], signature.data, argv[5]);
         if (certpath == NULL) {
@@ -426,6 +435,7 @@
                     die("fopen");
                 }
                 print_key_hex(fpub, (KEY*)&public_key, sizeof(public_key));
+		fclose(fpub);
             }
         }
     } else {
Index: boinc/lib/mfile.cpp
===================================================================
--- boinc.orig/lib/mfile.cpp
+++ boinc/lib/mfile.cpp
@@ -42,7 +42,7 @@
 }
 
 MFILE::~MFILE() {
-    if (buf) free(buf);
+    close();
 }
 
 int MFILE::open(const char* path, const char* mode) {
Index: boinc/lib/parse_test.cpp
===================================================================
--- boinc.orig/lib/parse_test.cpp
+++ boinc/lib/parse_test.cpp
@@ -57,6 +57,7 @@
         exit(1);
     }
     parse(f);
+    fclose(f);
 }
 
 /* try it with something like: