Browse code

Further cleanups

git-svn: trunk@3322

Nigel Horne authored on 2007/10/27 01:29:26
Showing 2 changed files
... ...
@@ -1,7 +1,11 @@
1
+Fri Oct 26 16:36:12 BST 2007 (njh)
2
+----------------------------------
3
+  * libclamav/vba_extract.c:	Further cleanups
4
+
1 5
 Wed Oct 24 09:08:12 BST 2007 (njh)
2 6
 ----------------------------------
3 7
   * clamav-milter:	Improved SPF checking for phish false positives
4
-  			Improved chroot failure diagnostics
8
+			Improved chroot failure diagnostics
5 9
 			Added option to report phish false positives
6 10
 
7 11
 Tue Oct 23 12:05:05 BST 2007 (trog)
... ...
@@ -13,7 +17,7 @@ Tue Oct 23 12:05:05 BST 2007 (trog)
13 13
 Mon Oct 22 20:39:10 BST 2007 (njh)
14 14
 ----------------------------------
15 15
   * libclamav/vba_extract.c:	Fixed warnings, removed double close() and
16
-  			some code tidies
16
+			some code tidies
17 17
 
18 18
 Thu Oct 18 20:42:11 EDT 2007 (tk)
19 19
 ---------------------------------
... ...
@@ -125,8 +129,8 @@ Wed Oct  3 18:26:12 EEST 2007 (edwin)
125 125
 Wed Oct  3 15:10:28 EEST 2007 (edwin)
126 126
 ------------------------------------
127 127
   * libclamav/regex_list.[ch]: avoid some false positives when there are
128
-  spaces in URL. 
129
- 
128
+  spaces in URL.
129
+
130 130
 Wed Oct  3 01:48:26 CEST 2007 (tk)
131 131
 ----------------------------------
132 132
   * libclamav/matcher-ac.[ch]: - add basic support for string alternatives
... ...
@@ -46,6 +46,41 @@
46 46
 #define	O_BINARY	0
47 47
 #endif
48 48
 
49
+#ifndef HAVE_ATTRIB_PACKED
50
+#define __attribute__(x)
51
+#endif
52
+
53
+#ifdef HAVE_PRAGMA_PACK
54
+#pragma pack(1)
55
+#endif
56
+
57
+#ifdef HAVE_PRAGMA_PACK_HPPA
58
+#pragma pack 1
59
+#endif
60
+
61
+struct vba56_header {
62
+	unsigned char magic[2];
63
+	unsigned char version[4];
64
+	uint16_t ooff __attribute__ ((packed));	/* 0x00FF */
65
+	uint32_t LidA __attribute__ ((packed));  /* Language identifiers */
66
+	uint32_t LidB __attribute__ ((packed));
67
+	uint16_t CharSet __attribute__ ((packed));
68
+	uint16_t LenA __attribute__ ((packed));
69
+	uint32_t UnknownB __attribute__ ((packed));
70
+	uint32_t UnknownC __attribute__ ((packed));
71
+	uint16_t LenB __attribute__ ((packed));
72
+	uint16_t LenC __attribute__ ((packed));
73
+	uint16_t LenD __attribute__ ((packed));
74
+};
75
+
76
+#ifdef HAVE_PRAGMA_PACK
77
+#pragma pack()
78
+#endif
79
+
80
+#ifdef HAVE_PRAGMA_PACK_HPPA
81
+#pragma pack
82
+#endif
83
+
49 84
 typedef struct vba_version_tag {
50 85
 	unsigned char signature[4];
51 86
 	const char *name;
... ...
@@ -53,11 +88,10 @@ typedef struct vba_version_tag {
53 53
 	int is_mac;
54 54
 } vba_version_t;
55 55
 
56
-
57 56
 static uint16_t vba_endian_convert_16(uint16_t value, int is_mac)
58 57
 {
59 58
 	if (is_mac)
60
-		return be16_to_host(value);
59
+		return (uint16_t)be16_to_host(value);
61 60
 	else
62 61
 		return le16_to_host(value);
63 62
 }
... ...
@@ -117,10 +151,11 @@ get_unicode_name(const char *name, int size, int is_mac)
117 117
                 } else {
118 118
                         if (name[i] < 10 && name[i] >= 0) {
119 119
                                 newname[j++] = '_';
120
-                                newname[j++] = name[i] + '0';
120
+                                newname[j++] = (char)(name[i] + '0');
121 121
                         }
122 122
 			else {
123
-				const uint16_t x = (((uint16_t)name[i]) << 8) | name[i+1];
123
+				const uint16_t x = (uint16_t)(((name[i]) << 8) | name[i + 1]);
124
+
124 125
 				newname[j++] = '_';
125 126
 				newname[j++] = (char)('a'+((x&0xF)));
126 127
 				newname[j++] = (char)('a'+((x>>4)&0xF));
... ...
@@ -150,14 +185,14 @@ static void vba56_test_middle(int fd)
150 150
 		0x85, 0x2e, 0x02, 0x60, 0x8c, 0x4d, 0x0b, 0xb4, 0x00, 0x00
151 151
 	};
152 152
 
153
-        if (cli_readn(fd, &test_middle, 20) != 20) {
154
-                return;
155
-        }
153
+	if(cli_readn(fd, &test_middle, 20) != 20) {
154
+		return;
155
+	}
156 156
 
157 157
 	if ((memcmp(test_middle, middle1_str, 20) != 0) &&
158 158
 		(memcmp(test_middle, middle2_str, 20) != 0)) {
159 159
 		cli_dbgmsg("middle not found\n");
160
-	        lseek(fd, -20, SEEK_CUR);
160
+		lseek(fd, -20, SEEK_CUR);
161 161
 	} else {
162 162
 		cli_dbgmsg("middle found\n");
163 163
 	}
... ...
@@ -187,7 +222,8 @@ static int vba_read_project_strings(int fd, int is_mac)
187 187
 			return FALSE;
188 188
 		}
189 189
 		offset = lseek(fd, 0, SEEK_CUR);
190
-		if (cli_readn(fd, buff, length) != length) {
190
+
191
+		if (cli_readn(fd, buff, length) != (int)length) {
191 192
 			cli_dbgmsg("read name failed - rewinding\n");
192 193
 			lseek(fd, offset, SEEK_SET);
193 194
 			free(buff);
... ...
@@ -248,26 +284,16 @@ static int vba_read_project_strings(int fd, int is_mac)
248 248
 
249 249
 vba_project_t *vba56_dir_read(const char *dir)
250 250
 {
251
-	unsigned char magic[2];
252
-	unsigned char version[4];
253 251
 	unsigned char *buff;
254
-        const unsigned char vba56_signature[] = { 0xcc, 0x61 };
252
+	const unsigned char vba56_signature[] = { 0xcc, 0x61 };
255 253
 	uint16_t record_count, length;
256
-	uint16_t ooff;
254
+	uint16_t ffff;
257 255
 	uint16_t byte_count;
258 256
 	uint32_t offset;
259
-	uint32_t LidA;  /* Language identifiers */
260
-	uint32_t LidB;
261
-	uint16_t CharSet;
262
-	uint16_t LenA;
263
-	uint32_t UnknownB;
264
-	uint32_t UnknownC;
265
-	uint16_t LenB;
266
-	uint16_t LenC;
267
-	uint16_t LenD;
268
-	int i, j, fd, is_mac;
257
+	int i, fd, is_mac;
269 258
 	vba_project_t *vba_project;
270 259
 	char *fullname;
260
+	struct vba56_header v56h;
271 261
 
272 262
 	cli_dbgmsg("in vba56_dir_read()\n");
273 263
 
... ...
@@ -286,38 +312,36 @@ vba_project_t *vba56_dir_read(const char *dir)
286 286
         }
287 287
 	free(fullname);
288 288
 
289
-	if (cli_readn(fd, &magic, 2) != 2) {
289
+	if(cli_readn(fd, &v56h, sizeof(struct vba56_header)) != sizeof(struct vba56_header)) {
290 290
 		close(fd);
291 291
 		return NULL;
292 292
 	}
293
-	if (memcmp(magic, vba56_signature, 2) != 0) {
293
+	if (memcmp(v56h.magic, vba56_signature, sizeof(v56h.magic)) != 0) {
294 294
 		close(fd);
295 295
 		return NULL;
296 296
 	}
297 297
 
298
-	if (cli_readn(fd, &version, 4) != 4) {
299
-		close(fd);
300
-		return NULL;
301
-	}
302
-	for (i=0 ; i < NUM_VBA_VERSIONS ; i++) {
303
-		if (memcmp(version, vba_version[i].signature, 4) == 0) {
298
+	for(i = 0; i < NUM_VBA_VERSIONS; i++)
299
+		if(memcmp(v56h.version, vba_version[i].signature, sizeof(vba_version[i].signature)) == 0)
304 300
 			break;
305
-		}
306
-	}
307 301
 
308 302
 	if (i == NUM_VBA_VERSIONS) {
309 303
 		cli_warnmsg("Unknown VBA version signature %x %x %x %x\n",
310
-			version[0], version[1], version[2], version[3]);
311
-		if (version[3] == 0x01) {
312
-			cli_warnmsg("Guessing little-endian\n");
313
-			is_mac = FALSE;
314
-		} else if (version[3] == 0x0e) {
315
-			cli_warnmsg("Guessing big-endian\n");
316
-			is_mac = TRUE;
317
-		} else {
318
-			cli_warnmsg("Unable to guess VBA type\n");
319
-			close(fd);
320
-			return NULL;
304
+			v56h.version[0], v56h.version[1],
305
+			v56h.version[2], v56h.version[3]);
306
+		switch(v56h.version[3]) {
307
+			case 0x01:
308
+				cli_warnmsg("Guessing little-endian\n");
309
+				is_mac = FALSE;
310
+				break;
311
+			case 0x0E:
312
+				cli_warnmsg("Guessing big-endian\n");
313
+				is_mac = TRUE;
314
+				break;
315
+			default:
316
+				cli_warnmsg("Unable to guess VBA type\n");
317
+				close(fd);
318
+				return NULL;
321 319
 		}
322 320
 	} else {
323 321
 		cli_dbgmsg("VBA Project: %s, VBA Version=%d\n", vba_version[i].name,
... ...
@@ -325,68 +349,13 @@ vba_project_t *vba56_dir_read(const char *dir)
325 325
 		is_mac = vba_version[i].is_mac;
326 326
 	}
327 327
 
328
-	/*****************************************/
329
-
330
-	/* two bytes, should be equal to 0x00ff */
331
-	if (cli_readn(fd, &ooff, 2) != 2) {
332
-		close(fd);
333
-		return NULL;
334
-	}
335
-
336
-	if (cli_readn(fd, &LidA, 4) != 4) {
337
-		close(fd);
338
-		return NULL;
339
-	}
340
-
341
-	if (cli_readn(fd, &LidB, 4) != 4) {
342
-		close(fd);
343
-		return NULL;
344
-	}
345
-
346
-	if (cli_readn(fd, &CharSet, 2) != 2) {
347
-		close(fd);
348
-		return NULL;
349
-	}
350
-	if (cli_readn(fd, &LenA, 2) != 2) {
351
-		close(fd);
352
-		return NULL;
353
-	}
354
-
355
-	if (cli_readn(fd, &UnknownB, 4) != 4) {
328
+#if	0
329
+	if((vba_endian_convert_16(v56h.ooff, is_mac) != 0xFF00)) {
330
+		cli_warnmsg("Expected 0xFF00, got 0x%x\n", v56h.ooff);
356 331
 		close(fd);
357 332
 		return NULL;
358 333
 	}
359
-	if (cli_readn(fd, &UnknownC, 4) != 4) {
360
-		close(fd);
361
-		return NULL;
362
-	}
363
-
364
-	if (cli_readn(fd, &LenB, 2) != 2) {
365
-		close(fd);
366
-		return NULL;
367
-	}
368
-	if (cli_readn(fd, &LenC, 2) != 2) {
369
-		close(fd);
370
-		return NULL;
371
-	}
372
-	if (cli_readn(fd, &LenD, 2) != 2) {
373
-		close(fd);
374
-		return NULL;
375
-	}
376
-
377
-        LidA = vba_endian_convert_32(LidA, is_mac);
378
-        LidB = vba_endian_convert_32(LidB, is_mac);
379
-        CharSet = vba_endian_convert_16(CharSet, is_mac);
380
-        LenA = vba_endian_convert_16(LenA, is_mac);
381
-        LenB = vba_endian_convert_16(LenB, is_mac);
382
-        LenC = vba_endian_convert_16(LenC, is_mac);
383
-        LenD = vba_endian_convert_16(LenD, is_mac);
384
-
385
-	cli_dbgmsg(" LidA: %d\n LidB: %d\n CharSet: %d\n", LidA, LidB, CharSet);
386
-	cli_dbgmsg(" LenA: %d\n UnknownB: %d\n UnknownC: %d\n", LenA, UnknownB, UnknownC);
387
-	cli_dbgmsg(" LenB: %d\n LenC: %d\n LenD: %d\n", LenB, LenC, LenD);
388
-
389
-	record_count = LenC;
334
+#endif
390 335
 
391 336
 	if (!vba_read_project_strings(fd, is_mac)) {
392 337
 		close(fd);
... ...
@@ -395,39 +364,39 @@ vba_project_t *vba56_dir_read(const char *dir)
395 395
 
396 396
 	/* junk some more stuff */
397 397
 	do {
398
-		if (cli_readn(fd, &ooff, 2) != 2) {
398
+		if (cli_readn(fd, &ffff, 2) != 2) {
399 399
 			close(fd);
400 400
 			return NULL;
401 401
 		}
402
-	} while(ooff != 0xFFFF);
402
+	} while(ffff != 0xFFFF);
403 403
 
404 404
 	/* check for alignment error */
405 405
 	lseek(fd, -3, SEEK_CUR);
406
-	if (cli_readn(fd, &ooff, 2) != 2) {
406
+	if (cli_readn(fd, &ffff, 2) != 2) {
407 407
 		close(fd);
408 408
 		return NULL;
409 409
 	}
410
-	if (ooff != 0xFFFF) {
410
+	if (ffff != 0xFFFF) {
411 411
 		lseek(fd, 1, SEEK_CUR);
412 412
 	}
413 413
 
414
-	if (cli_readn(fd, &ooff, 2) != 2) {
414
+	if (cli_readn(fd, &ffff, 2) != 2) {
415 415
 		close(fd);
416 416
 		return NULL;
417 417
 	}
418 418
 
419 419
 	/* no idea what this stuff is */
420
-	if (ooff != 0xFFFF) {
421
-		ooff = vba_endian_convert_16(ooff, is_mac);
422
-		lseek(fd, ooff, SEEK_CUR);
420
+	if (ffff != 0xFFFF) {
421
+		ffff = vba_endian_convert_16(ffff, is_mac);
422
+		lseek(fd, ffff, SEEK_CUR);
423 423
 	}
424
-	if (cli_readn(fd, &ooff, 2) != 2) {
424
+	if (cli_readn(fd, &ffff, 2) != 2) {
425 425
 		close(fd);
426 426
 		return NULL;
427 427
 	}
428
-	if (ooff != 0xFFFF) {
429
-		ooff = vba_endian_convert_16(ooff, is_mac);
430
-		lseek(fd, ooff, SEEK_CUR);
428
+	if (ffff != 0xFFFF) {
429
+		ffff = vba_endian_convert_16(ffff, is_mac);
430
+		lseek(fd, ffff, SEEK_CUR);
431 431
 	}
432 432
 	lseek(fd, 100, SEEK_CUR);
433 433
 
... ...
@@ -439,8 +408,8 @@ vba_project_t *vba56_dir_read(const char *dir)
439 439
 	cli_dbgmsg("\nVBA Record count: %d\n", record_count);
440 440
 	if (record_count == 0) {
441 441
 		close(fd);
442
-                return NULL;
443
-        }
442
+		return NULL;
443
+	}
444 444
 	if (record_count > 1000) {
445 445
 		/* Almost certainly an error */
446 446
 		cli_dbgmsg("\nVBA Record count too big");
... ...
@@ -470,30 +439,34 @@ vba_project_t *vba56_dir_read(const char *dir)
470 470
 		return NULL;
471 471
 	}
472 472
 	vba_project->count = record_count;
473
-	for (i=0 ; i < record_count ; i++) {
474
-		if (cli_readn(fd, &length, 2) != 2) {
475
-			goto out_error;
476
-		}
473
+	for(i = 0; i < record_count; i++) {
474
+		if(cli_readn(fd, &length, 2) != 2)
475
+			break;
476
+
477 477
 		length = vba_endian_convert_16(length, is_mac);
478 478
 		if (length == 0) {
479 479
 			cli_dbgmsg("zero name length\n");
480
-			goto out_error;
481
-                }
480
+			break;
481
+		}
482 482
 		buff = (unsigned char *) cli_malloc(length);
483 483
 		if (!buff) {
484 484
 			cli_dbgmsg("cli_malloc failed\n");
485
-			goto out_error;
485
+			break;
486 486
 		}
487 487
 		if (cli_readn(fd, buff, length) != length) {
488 488
 			cli_dbgmsg("read name failed\n");
489 489
 			free(buff);
490
-			goto out_error;
490
+			break;
491 491
 		}
492 492
 		vba_project->name[i] = get_unicode_name((const char *)buff, length, is_mac);
493 493
 		if (!vba_project->name[i]) {
494 494
 			offset = lseek(fd, 0, SEEK_CUR);
495 495
 			vba_project->name[i] = (char *) cli_malloc(18);
496
-			snprintf(vba_project->name[i], 18, "clamav-%.10d", offset);
496
+			if(vba_project->name[i] == NULL) {
497
+				free(buff);
498
+				break;
499
+			}
500
+			snprintf(vba_project->name[i], 18, "clamav-%.10d", (int)offset);
497 501
 		}
498 502
 		cli_dbgmsg("project name: %s, ", vba_project->name[i]);
499 503
 		free(buff);
... ...
@@ -501,42 +474,39 @@ vba_project_t *vba56_dir_read(const char *dir)
501 501
 		/* some kind of string identifier ?? */
502 502
 		if (cli_readn(fd, &length, 2) != 2) {
503 503
 			free(vba_project->name[i]);
504
-			goto out_error;
504
+			break;
505 505
 		}
506 506
 		length = vba_endian_convert_16(length, is_mac);
507 507
 		lseek(fd, length, SEEK_CUR);
508 508
 
509 509
 		/* unknown stuff */
510
-		if (cli_readn(fd, &ooff, 2) != 2) {
510
+		if (cli_readn(fd, &ffff, 2) != 2) {
511 511
 			free(vba_project->name[i]);
512
-			goto out_error;
512
+			break;
513 513
 		}
514
-		ooff = vba_endian_convert_16(ooff, is_mac);
515
-		if (ooff == 0xFFFF) {
514
+		ffff = vba_endian_convert_16(ffff, is_mac);
515
+		if (ffff == 0xFFFF) {
516 516
 			lseek(fd, 2, SEEK_CUR);
517
-			if (cli_readn(fd, &ooff, 2) != 2) {
517
+			if (cli_readn(fd, &ffff, 2) != 2) {
518 518
 				free(vba_project->name[i]);
519
-				goto out_error;
519
+				break;
520 520
 			}
521
-			ooff = vba_endian_convert_16(ooff, is_mac);
522
-			lseek(fd, ooff, SEEK_CUR);
521
+			ffff = vba_endian_convert_16(ffff, is_mac);
522
+			lseek(fd, ffff, SEEK_CUR);
523 523
 		} else {
524
-			lseek(fd, 2 + ooff, SEEK_CUR);
524
+			lseek(fd, 2 + ffff, SEEK_CUR);
525 525
 		}
526 526
 
527 527
 		lseek(fd, 8, SEEK_CUR);
528 528
 		if (cli_readn(fd, &byte_count, 2) != 2) {
529 529
 			free(vba_project->name[i]);
530
-			goto out_error;
530
+			break;
531 531
 		}
532 532
 		byte_count = vba_endian_convert_16(byte_count, is_mac);
533
-		for (j=0 ; j<byte_count; j++) {
534
-			lseek(fd, 8, SEEK_CUR);
535
-		}
536
-		lseek(fd, 5, SEEK_CUR);
533
+		lseek(fd, (8 * byte_count) + 5, SEEK_CUR);
537 534
 		if (cli_readn(fd, &offset, 4) != 4) {
538 535
 			free(vba_project->name[i]);
539
-			goto out_error;
536
+			break;
540 537
 		}
541 538
 		offset = vba_endian_convert_32(offset, is_mac);
542 539
 		vba_project->offset[i] = offset;
... ...
@@ -544,29 +514,21 @@ vba_project_t *vba56_dir_read(const char *dir)
544 544
 		lseek(fd, 2, SEEK_CUR);
545 545
 	}
546 546
 
547
+	close(fd);
547 548
 
548
-	{ /* There appears to be some code in here */
549
-
550
-	off_t foffset;
549
+	if(i < record_count) {
550
+		/* above loop failed */
551
+		while(--i >= 0)
552
+			free(vba_project->name[i]);
551 553
 
552
-		foffset = lseek(fd, 0, SEEK_CUR);
553
-		cli_dbgmsg("\nOffset: 0x%x\n", (unsigned int)foffset);
554
+		free(vba_project->name);
555
+		free(vba_project->dir);
556
+		free(vba_project->offset);
557
+		free(vba_project);
558
+		return NULL;
554 559
 	}
555
-	close(fd);
556
-	return vba_project;
557 560
 
558
-out_error:
559
-	/* Note: only to be called from the above loop
560
-	   when i == number of allocated stings */
561
-	for (j=0 ; j<i ; j++) {
562
-		free(vba_project->name[j]);
563
-	}
564
-	free(vba_project->name);
565
-	free(vba_project->dir);
566
-	free(vba_project->offset);
567
-	free(vba_project);
568
-	close(fd);
569
-	return NULL;
561
+	return vba_project;
570 562
 }
571 563
 
572 564
 #define VBA_COMPRESSION_WINDOW 4096
... ...
@@ -751,7 +713,7 @@ int cli_decode_ole_object(int fd, const char *dir)
751 751
 	sprintf(fullname, "%s/_clam_ole_object", dir);
752 752
 	ofd = open(fullname, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
753 753
 	free(fullname);
754
-        if (ofd < 0) {
754
+	if (ofd < 0) {
755 755
 		return -1;
756 756
 	}
757 757
 	ole_copy_file_data(fd, ofd, object_size);
... ...
@@ -781,8 +743,8 @@ static int ppt_read_atom_header(int fd, atom_header_t *atom_header)
781 781
 	}
782 782
 	atom_header->ver_inst = vba_endian_convert_16(atom_header->ver_inst, FALSE);
783 783
 	atom_header->version = (uint8_t)(atom_header->ver_inst & 0x000f);
784
-	atom_header->instance = atom_header->ver_inst >> 4;
785
-	if (cli_readn(fd, &atom_header->type, 2) != 2) {
784
+	atom_header->instance = (uint16_t)(atom_header->ver_inst >> 4);
785
+	if(cli_readn(fd, &atom_header->type, sizeof(uint16_t)) != sizeof(uint16_t)) {
786 786
 		cli_dbgmsg("read ppt_current_user failed\n");
787 787
 		return FALSE;
788 788
 	}
... ...
@@ -821,10 +783,10 @@ static int ppt_unlzw(const char *dir, int fd, uint32_t length)
821 821
 
822 822
 	ofd = open(fullname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600);
823 823
 	free(fullname);
824
-        if (ofd == -1) {
825
-                cli_dbgmsg("ppt_unlzw Open outfile failed\n");
826
-                return FALSE;
827
-        }
824
+	if (ofd == -1) {
825
+		cli_dbgmsg("ppt_unlzw Open outfile failed\n");
826
+		return FALSE;
827
+	}
828 828
 
829 829
 	stream.zalloc = Z_NULL;
830 830
 	stream.zfree = Z_NULL;
... ...
@@ -877,8 +839,7 @@ static int ppt_unlzw(const char *dir, int fd, uint32_t length)
877 877
 		return FALSE;
878 878
 	}
879 879
 	inflateEnd(&stream);
880
-	close(ofd);
881
-	return TRUE;
880
+	return close(ofd);
882 881
 }
883 882
 
884 883
 static char *ppt_stream_iter(int fd)
... ...
@@ -1407,7 +1368,7 @@ static macro_extnames_t *wm_read_macro_extnames(int fd)
1407 1407
 			goto abort;
1408 1408
 		}
1409 1409
 		macro_extname->numref = vba_endian_convert_16(macro_extname->numref, FALSE);
1410
-		cli_dbgmsg("ext name: %s\n", macro_extname->extname);
1410
+		cli_dbgmsg("ext name: %s\n", (char *)macro_extname->extname);
1411 1411
 	}
1412 1412
 	return macro_extnames;
1413 1413
 
... ...
@@ -1474,16 +1435,16 @@ static macro_intnames_t *wm_read_macro_intnames(int fd)
1474 1474
 		}
1475 1475
 		if (cli_readn(fd, macro_intname->intname, macro_intname->length) != macro_intname->length) {
1476 1476
 			cli_dbgmsg("read macro_intnames failed\n");
1477
-			macro_intnames->count = i+1;
1477
+			macro_intnames->count = (uint16_t)(i + 1);
1478 1478
 			goto abort;
1479 1479
 		}
1480 1480
 		macro_intname->intname[macro_intname->length] = '\0';
1481 1481
 		if (cli_readn(fd, &junk, 1) != 1) {
1482 1482
 			cli_dbgmsg("read macro_intnames failed\n");
1483
-			macro_intnames->count = i+1;
1483
+			macro_intnames->count = (uint16_t)(i + 1);
1484 1484
 			goto abort;
1485 1485
 		}
1486
-		cli_dbgmsg("int name: %s\n", macro_intname->intname);
1486
+		cli_dbgmsg("int name: %s\n", (char *)macro_intname->intname);
1487 1487
 	}
1488 1488
 	return macro_intnames;
1489 1489
 abort: