]>
Commit | Line | Data |
---|---|---|
1 | Fix gsize vs guint64 confusion in secure-logging module. | |
2 | --- syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slogkey/slogkey.c.orig 2020-04-30 16:18:56.000000000 +0200 | |
3 | +++ syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slogkey/slogkey.c 2020-05-10 17:43:50.686930970 +0200 | |
4 | @@ -76,7 +76,7 @@ | |
5 | // Display key counter | |
6 | char key[KEY_LENGTH]; | |
7 | char *keyfile = argv[2]; | |
8 | - size_t counter; | |
9 | + guint64 counter; | |
10 | ret = readKey(key, &counter, keyfile); | |
11 | if(!ret) | |
12 | { | |
13 | --- syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slog.h.orig 2020-04-30 16:18:56.000000000 +0200 | |
14 | +++ syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slog.h 2020-05-10 18:14:12.007892114 +0200 | |
15 | @@ -110,11 +110,11 @@ | |
16 | unsigned char *iv, | |
17 | unsigned char *plaintext); | |
18 | ||
19 | -void cmac(unsigned char *key, const void *input, guint64 length, unsigned char *out, guint64 *outlen); | |
20 | +void cmac(unsigned char *key, const void *input, gsize length, unsigned char *out, gsize *outlen); | |
21 | ||
22 | ||
23 | -gchar *convertToBase64(unsigned char *input, guint64 len); | |
24 | -guchar *convertToBin(char *input, guint64 *outLen); | |
25 | +gchar *convertToBase64(unsigned char *input, gsize len); | |
26 | +guchar *convertToBin(char *input, gsize *outLen); | |
27 | ||
28 | /* | |
29 | * Derive key = evolve key multiple times | |
30 | --- syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slog.c.orig 2020-04-30 16:18:56.000000000 +0200 | |
31 | +++ syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slog.c 2020-05-10 18:24:58.711228981 +0200 | |
32 | @@ -365,12 +365,12 @@ | |
33 | { | |
34 | memcpy(bigBuf, inputBigMac, AES_BLOCKSIZE); | |
35 | ||
36 | - guint64 outlen; | |
37 | + gsize outlen; | |
38 | cmac(MACKey, bigBuf, AES_BLOCKSIZE+IV_LENGTH+AES_BLOCKSIZE+ct_length, outputBigMac, &outlen ); | |
39 | } | |
40 | else //First aggregated MAC | |
41 | { | |
42 | - guint64 outlen = 0; | |
43 | + gsize outlen = 0; | |
44 | ||
45 | cmac(MACKey, &bigBuf[AES_BLOCKSIZE], IV_LENGTH+AES_BLOCKSIZE+ct_length, outputBigMac, &outlen); | |
46 | } | |
47 | @@ -406,14 +406,14 @@ | |
48 | } | |
49 | } | |
50 | ||
51 | -guchar *convertToBin(char *input, guint64 *outLen) | |
52 | +guchar *convertToBin(char *input, gsize *outLen) | |
53 | { | |
54 | return g_base64_decode ((const gchar *) input, outLen); | |
55 | } | |
56 | ||
57 | -gchar *convertToBase64(unsigned char *input, guint64 len) | |
58 | +gchar *convertToBase64(unsigned char *input, gsize len) | |
59 | { | |
60 | - return g_base64_encode ((const guchar *) input, (gsize) len); | |
61 | + return g_base64_encode ((const guchar *) input, len); | |
62 | } | |
63 | ||
64 | /* | |
65 | @@ -430,14 +430,16 @@ | |
66 | * If Parameter 5 == 0, there was an error. | |
67 | * | |
68 | */ | |
69 | -void cmac(unsigned char *key, const void *input, guint64 length, unsigned char *out, guint64 *outlen) | |
70 | +void cmac(unsigned char *key, const void *input, gsize length, unsigned char *out, gsize *outlen) | |
71 | { | |
72 | CMAC_CTX *ctx = CMAC_CTX_new(); | |
73 | ||
74 | CMAC_Init(ctx, key, KEY_LENGTH, EVP_aes_256_cbc(), NULL); | |
75 | CMAC_Update(ctx, input, length); | |
76 | ||
77 | - CMAC_Final(ctx, out, outlen); | |
78 | + size_t outsize; | |
79 | + CMAC_Final(ctx, out, &outsize); | |
80 | + *outlen = outsize; | |
81 | CMAC_CTX_free(ctx); | |
82 | } | |
83 | ||
84 | @@ -481,7 +483,7 @@ | |
85 | // Prepare plaintext | |
86 | for (int i=0; i<outputLength/AES_BLOCKSIZE; i++) | |
87 | { | |
88 | - guint64 outlen; | |
89 | + gsize outlen; | |
90 | cmac(key, input, AES_BLOCKSIZE, &buf[i*AES_BLOCKSIZE], &outlen); | |
91 | input[inputLength-1]++; | |
92 | } | |
93 | @@ -489,7 +491,7 @@ | |
94 | if (outputLength % AES_BLOCKSIZE!=0) | |
95 | { | |
96 | int index = outputLength/AES_BLOCKSIZE; | |
97 | - guint64 outlen; | |
98 | + gsize outlen; | |
99 | cmac(key, input, AES_BLOCKSIZE, &buf[(index)*AES_BLOCKSIZE], &outlen); | |
100 | } | |
101 | ||
102 | @@ -603,7 +605,7 @@ | |
103 | return 0; | |
104 | } | |
105 | ||
106 | - guint64 outlen = 0; | |
107 | + gsize outlen = 0; | |
108 | status = g_io_channel_write_chars(macfile, outputBuffer, CMAC_LENGTH, &outlen, &error); | |
109 | if(status != G_IO_STATUS_NORMAL) | |
110 | { | |
111 | @@ -732,7 +734,7 @@ | |
112 | return 0; | |
113 | } | |
114 | ||
115 | - guint64 outlen = 0; | |
116 | + gsize outlen = 0; | |
117 | unsigned char keyBuffer[KEY_LENGTH]; | |
118 | bzero(keyBuffer, KEY_LENGTH); | |
119 | unsigned char zeroBuffer[CMAC_LENGTH]; | |
120 | @@ -861,7 +863,7 @@ | |
121 | return 0; | |
122 | } | |
123 | ||
124 | - guint64 outlen=0; | |
125 | + gsize outlen=0; | |
126 | unsigned char testOutput[CMAC_LENGTH]; | |
127 | ||
128 | cmac((guchar *)keydata, &(littleEndianCounter), sizeof(littleEndianCounter), testOutput, &outlen); | |
129 | @@ -916,7 +918,7 @@ | |
130 | return 0; | |
131 | } | |
132 | ||
133 | - guint64 outlen = 0; | |
134 | + gsize outlen = 0; | |
135 | // Write key | |
136 | status = g_io_channel_write_chars(keyfile, key, KEY_LENGTH, &outlen, &error); | |
137 | if(status != G_IO_STATUS_NORMAL) | |
138 | @@ -1029,7 +1031,7 @@ | |
139 | if (tab != NULL) | |
140 | { | |
141 | char key[CTR_LEN_SIMPLE+1]; | |
142 | - snprintf(key, CTR_LEN_SIMPLE+1, "%lu", logEntryOnDisk); | |
143 | + snprintf(key, CTR_LEN_SIMPLE+1, "%"G_GUINT64_FORMAT, logEntryOnDisk); | |
144 | if(g_hash_table_contains(tab, key) == TRUE) | |
145 | { | |
146 | msg_error("[SLOG] ERROR: Duplicate entry detected", evt_tag_long("entry", logEntryOnDisk)); | |
147 | @@ -1068,7 +1070,7 @@ | |
148 | GString *line = input[i]; | |
149 | ||
150 | char *ct = &(line->str)[COUNTER_LENGTH+1]; | |
151 | - guint64 outputLength; | |
152 | + gsize outputLength; | |
153 | ||
154 | // binBuf = IV + TAG + CT | |
155 | guchar *binBuf = convertToBin(ct, &outputLength); | |
156 | @@ -1088,12 +1090,12 @@ | |
157 | if (pt_length>0) | |
158 | { | |
159 | // Include colon, whitespace, and \0 | |
160 | - g_string_append_printf(output[i], "%0*lx: %.*s", CTR_LEN_SIMPLE, logEntryOnDisk, pt_length, pt); | |
161 | + g_string_append_printf(output[i], "%0*"G_GINT64_MODIFIER"x: %.*s", CTR_LEN_SIMPLE, logEntryOnDisk, pt_length, pt); | |
162 | ||
163 | if (tab != NULL) | |
164 | { | |
165 | char *key = malloc(CTR_LEN_SIMPLE+1); | |
166 | - snprintf(key, CTR_LEN_SIMPLE+1, "%lu", logEntryOnDisk); | |
167 | + snprintf(key, CTR_LEN_SIMPLE+1, "%"G_GUINT64_FORMAT, logEntryOnDisk); | |
168 | ||
169 | if (g_hash_table_insert(tab, key, (gpointer)logEntryOnDisk) == FALSE) | |
170 | { | |
171 | @@ -1106,7 +1108,7 @@ | |
172 | // Update BigHMAC | |
173 | if ((*numberOfLogEntries) == 0UL) //First aggregated MAC | |
174 | { | |
175 | - guint64 outlen = 0; | |
176 | + gsize outlen = 0; | |
177 | ||
178 | unsigned char MACKey[KEY_LENGTH]; | |
179 | deriveMACSubKey(mainKey, MACKey); | |
180 | @@ -1116,7 +1118,7 @@ | |
181 | else | |
182 | { | |
183 | // numberOfEntries > 0 | |
184 | - guint64 outlen; | |
185 | + gsize outlen; | |
186 | unsigned char bigBuf[AES_BLOCKSIZE+IV_LENGTH+AES_BLOCKSIZE+pt_length]; | |
187 | memcpy(bigBuf, cmac_tag, AES_BLOCKSIZE); | |
188 | memcpy(&bigBuf[AES_BLOCKSIZE], binBuf, IV_LENGTH+AES_BLOCKSIZE+pt_length); | |
189 | @@ -1169,7 +1171,7 @@ | |
190 | { | |
191 | // Hashtable key | |
192 | char key[CTR_LEN_SIMPLE+1]; | |
193 | - snprintf(key, CTR_LEN_SIMPLE+1, "%lu", i); | |
194 | + snprintf(key, CTR_LEN_SIMPLE+1, "%"G_GUINT64_FORMAT, i); | |
195 | ||
196 | if(g_hash_table_contains(tab, key) == FALSE) | |
197 | { | |
198 | --- syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slogimport/slogimport.c.orig 2020-04-30 16:18:56.000000000 +0200 | |
199 | +++ syslog-ng-syslog-ng-3.27.1/modules/secure-logging/slogimport/slogimport.c 2020-05-10 18:29:54.983177242 +0200 | |
200 | @@ -49,7 +49,7 @@ | |
201 | char mac[CMAC_LENGTH]; | |
202 | ||
203 | // Read key and counter | |
204 | - size_t counter; | |
205 | + guint64 counter; | |
206 | int ret = readKey(key, &counter, argv[1]); | |
207 | if (ret!=1) | |
208 | { | |
209 | @@ -59,7 +59,7 @@ | |
210 | ||
211 | if (argc==8) | |
212 | { | |
213 | - sscanf(argv[7], "%zu", &counter); | |
214 | + sscanf(argv[7], "%"G_GUINT64_FORMAT, &counter); | |
215 | } | |
216 | ||
217 | // Open input file | |
218 | --- syslog-ng-syslog-ng-3.27.1/modules/secure-logging/tests/test_secure_logging.c.orig 2020-04-30 16:18:56.000000000 +0200 | |
219 | +++ syslog-ng-syslog-ng-3.27.1/modules/secure-logging/tests/test_secure_logging.c 2020-05-10 18:37:11.932385333 +0200 | |
220 | @@ -179,9 +179,9 @@ | |
221 | ||
222 | GHashTable *tab = NULL; | |
223 | ||
224 | - size_t next = 0; | |
225 | - size_t start = 0; | |
226 | - size_t numberOfLogEntries = 0UL; | |
227 | + guint64 next = 0; | |
228 | + guint64 start = 0; | |
229 | + guint64 numberOfLogEntries = 0; | |
230 | ||
231 | GString **outputBuffer = (GString **) malloc(sizeof(GString *) * totalNumberOfMessages); | |
232 | ||
233 | @@ -216,9 +216,9 @@ | |
234 | ||
235 | GHashTable *tab = NULL; | |
236 | ||
237 | - size_t next = 0; | |
238 | - size_t start = 0; | |
239 | - size_t numberOfLogEntries = 0UL; | |
240 | + guint64 next = 0; | |
241 | + guint64 start = 0; | |
242 | + guint64 numberOfLogEntries = 0; | |
243 | ||
244 | GString **outputBuffer = (GString **) malloc(sizeof(GString *) * totalNumberOfMessages); | |
245 |