Package: sword / 1.7.3+dfsg-2

12_fix_compiler_warnings.diff 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
Remove compiler warnings so SWORD will compile with -Wall -Werror
--- a/src/mgr/filemgr.cpp
+++ b/src/mgr/filemgr.cpp
@@ -409,7 +409,7 @@
 
 
 int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
-	int sfd, dfd, len;
+  int sfd, dfd, len;
 	char buf[4096];
 
 	if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1)
--- a/src/utilfuns/zlib/untgz.c
+++ b/src/utilfuns/zlib/untgz.c
@@ -262,7 +262,7 @@
 	int    remaining = 0;
 	FILE   *outfile = NULL;
 	char   fname[BLOCKSIZE];
-	time_t tartime;
+	time_t tartime = 0;
   
 	while (1) {
 		len = gzread(in, &buffer, BLOCKSIZE);
--- a/tests/testblocks.cpp
+++ b/tests/testblocks.cpp
@@ -34,14 +34,18 @@
 void addEntry(EntriesBlock *eb) {
 	string input;
 	string body;
-	char line[1024];
+	char line[1024], *c;
 	std::cout << "\nEnter new Entry's text. '.' on an empty line to finish:\n";
 	do {
 		std::cout << "> ";
-		fgets(line, 1000, stdin);
-		input = line;
-		if (input.compare("."))
-			body.append(input);
+		c = fgets(line, 1000, stdin);
+		if (c == NULL) {
+			std::cerr << "ERROR: fgets failed during addEntry\n";
+		} else {
+			input = line;
+			if (input.compare("."))
+				body.append(input);
+		}
 	}
 	while (input.compare("."));
 	std::cout << "Adding new entry.  Index is: " << eb->addEntry(body.c_str()) << "\n\n";
@@ -77,29 +81,33 @@
 
 	EntriesBlock *eb = new EntriesBlock();
 	string input;
-	char line[1024];
+	char line[1024], *c;
 
 	std::cout << "Initial entry count should be 0: " << eb->getCount() << "\n";
 
 	do {
 		std::cout << "[" << eb->getCount() << "] > ";
-		fgets(line, 1000, stdin);
-		input = line;
-		if (input.length() > 0) {
-			switch (input[0]) {
-				case 'a': addEntry(eb); break;
-				case 'p':	printEntry(eb, atoi(input.c_str()+1)); break;
-				case 'r':	removeEntry(eb, atoi(input.c_str()+1)); break;
-				case 's': printSize(eb); break;
-				case 'q': break;
-				case '?':
-				default:
-					std::cout << "\n a - add a new entry\n";
-					std::cout << " p <entry_index> - print entry\n";
-					std::cout << " r <entry_index> - remove entry\n";
-					std::cout << " s - print size of raw data\n";
-					std::cout << " q - quit\n\n";
-					break;
+		c = fgets(line, 1000, stdin);
+		if (c == NULL) {
+			std::cerr << "ERROR: fgets failed in main\n";
+		} else {
+			input = line;
+			if (input.length() > 0) {
+				switch (input[0]) {
+					case 'a': addEntry(eb); break;
+					case 'p':	printEntry(eb, atoi(input.c_str()+1)); break;
+					case 'r':	removeEntry(eb, atoi(input.c_str()+1)); break;
+					case 's': printSize(eb); break;
+					case 'q': break;
+					case '?':
+					default:
+						std::cout << "\n a - add a new entry\n";
+						std::cout << " p <entry_index> - print entry\n";
+						std::cout << " r <entry_index> - remove entry\n";
+						std::cout << " s - print size of raw data\n";
+						std::cout << " q - quit\n\n";
+						break;
+				}
 			}
 		}
 	}
--- a/utilities/stepdump.cpp
+++ b/utilities/stepdump.cpp
@@ -163,33 +163,56 @@
 
 
 void readVersion(int fd, Version *versionRecord) {
+	int r;
 
 	cout << "\n\nReading Version Record (" << 16/*sizeof(struct Version)*/ << " bytes)\n\n";
 // DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS
 //	read(fd, &versionRecord, sizeof(struct Version));
 
 	cout << "Version Record Information\n";
-	read(fd, &(versionRecord->versionRecordSize), 2);
+	r = read(fd, &(versionRecord->versionRecordSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tversionRecordSize: " << versionRecord->versionRecordSize << "\n";
-	read(fd, &(versionRecord->publisherID), 2);
+	r = read(fd, &(versionRecord->publisherID), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tpublisherID: " << versionRecord->publisherID << "\n";
-	read(fd, &(versionRecord->bookID), 2);
+	r = read(fd, &(versionRecord->bookID), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tbookID: " << versionRecord->bookID << "\n";
-	read(fd, &(versionRecord->setID), 2);
+	r = read(fd, &(versionRecord->setID), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tsetID: " << versionRecord->setID << "\n";
-	read(fd, &(versionRecord->conversionProgramVerMajor), 1);
+	r = read(fd, &(versionRecord->conversionProgramVerMajor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tconversionProgramVerMajor: " << (int)versionRecord->conversionProgramVerMajor << "\n";
-	read(fd, &(versionRecord->conversionProgramVerMinor), 1);
+	r = read(fd, &(versionRecord->conversionProgramVerMinor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tconversionProgramVerMinor: " << (int)versionRecord->conversionProgramVerMinor << "\n";
-	read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
+	r = read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tleastCompatSTEPVerMajor: " << (int)versionRecord->leastCompatSTEPVerMajor << "\n";
-	read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
+	r = read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tleastCompatSTEPVerMinor: " << (int)versionRecord->leastCompatSTEPVerMinor << "\n";
-	read(fd, &(versionRecord->encryptionType), 1);
+	r = read(fd, &(versionRecord->encryptionType), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tencryptionType: " << (int)versionRecord->encryptionType << "\n";
-	read(fd, &(versionRecord->editionID), 1);
+	r = read(fd, &(versionRecord->editionID), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
 	cout << "\teditionID: " << (int)versionRecord->editionID << "\n";
-	read(fd, &(versionRecord->modifiedBy), 2);
+	r = read(fd, &(versionRecord->modifiedBy), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
 	cout << "\tmodifiedBy: " << versionRecord->modifiedBy << "\n";
 
 	int skip = versionRecord->versionRecordSize - 16/*sizeof(struct Version*/;
@@ -197,33 +220,49 @@
 	if (skip) {
 		cout << "\nSkipping " << skip << " unknown bytes.\n";
 		char *skipbuf = new char[skip];
-		read(fd, skipbuf, skip);
+		r = read(fd, skipbuf, skip);
+		if (r != skip)
+			perror("ERROR: read failed in readVersion");
 		delete [] skipbuf;
 	}
 }
 
 
 void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord) {
-
+	int r;
 	cout << "\n\nReading Viewable Header Record (" << 16/*sizeof(struct ViewableHeader)*/ << " bytes)\n\n";
 
 // DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS
 //	read(fd, &viewableHeaderRecord, sizeof(struct ViewableHeader));
 
 	cout << "Viewable Header Record Information\n";
-	read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
+	r = read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\tviewableHeaderRecordSize: " << viewableHeaderRecord->viewableHeaderRecordSize << "\n";
-	read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
+	r = read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\tviewableBlocksCount: " << viewableHeaderRecord->viewableBlocksCount << "\n";
-	read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
+	r = read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\tglossBlocksCount: " << viewableHeaderRecord->glossBlocksCount << "\n";
-	read(fd, &(viewableHeaderRecord->compressionType), 1);
+	r = read(fd, &(viewableHeaderRecord->compressionType), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\tcompressionType: " << (int)viewableHeaderRecord->compressionType << "(0 - none; 1 - LZSS)\n";
-	read(fd, &(viewableHeaderRecord->reserved1), 1);
+	r = read(fd, &(viewableHeaderRecord->reserved1), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\treserved1: " << (int)viewableHeaderRecord->reserved1 << "\n";
-	read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
+	r = read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\tblockEntriesSize: " << viewableHeaderRecord->blockEntriesSize << "\n";
-	read(fd, &(viewableHeaderRecord->reserved2), 2);
+	r = read(fd, &(viewableHeaderRecord->reserved2), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readViewableHeader");
 	cout << "\treserved2: " << viewableHeaderRecord->reserved2 << "\n";
 
 	int skip = viewableHeaderRecord->viewableHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/;
@@ -231,18 +270,23 @@
 	if (skip) {
 		cout << "\nSkipping " << skip << " unknown bytes.\n";
 		char *skipbuf = new char[skip];
-		read(fd, skipbuf, skip);
+		r = read(fd, skipbuf, skip);
+		if (r != skip)
+			perror("ERROR: read failed in readViewableHeader");
 		delete [] skipbuf;
 	}
 }
 
 
 void readViewableBlockText(int fd, ViewableBlock *vb, char **buf) {
+	int r;
 	unsigned long size = vb->size;
 
 	*buf = new char [ ((vb->size > vb->uncompressedSize) ? vb->size : vb->uncompressedSize) + 1 ];
 	lseek(fd, vb->offset, SEEK_SET);
-	read(fd, *buf, vb->size);
+	r = read(fd, *buf, vb->size);
+	if (r != vb->size)
+		perror("ERROR: read failed in readViewableBlocktext");
 
 	compress->zBuf(&size, *buf);
 	strcpy(*buf, compress->Buf());
@@ -252,30 +296,41 @@
 
 
 void readViewableBlock(int fd, ViewableBlock *vb) {
-
+	int r;
 	cout << "\n\nReading Viewable Block (" << 12/*sizeof(struct ViewableHeader)*/ << " bytes)\n\n";
 
 // DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS
 //	read(fd, &vb, sizeof(struct ViewableBlock));
 
 	cout << "Viewable Block Information\n";
-	read(fd, &(vb->offset), 4);
+	r = read(fd, &(vb->offset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableBlock");
 	cout << "\toffset: " << vb->offset << "\n";
-	read(fd, &(vb->uncompressedSize), 4);
+	r = read(fd, &(vb->uncompressedSize), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableBlock");
 	cout << "\tuncompressedSize: " << vb->uncompressedSize << "\n";
-	read(fd, &(vb->size), 4);
+	r = read(fd, &(vb->size), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableBlock");
 	cout << "\tsize: " << vb->size << "\n";
 }
 
 
 void readHeaderControlWordAreaText(int fd, char **buf) {
+	int r;
 	long headerControlWordAreaSize;
-	read(fd, &headerControlWordAreaSize, 4);
+	r = read(fd, &headerControlWordAreaSize, 4);
+	if (r != 4)
+		perror("ERROR: read failed in readHeaderControlWordAreaText");
 	cout << "Reading Header Control Word Area (" << headerControlWordAreaSize << " bytes)\n\n";
 
 	*buf = new char [headerControlWordAreaSize + 1];
 
-	read(fd, *buf, headerControlWordAreaSize);
+	r = read(fd, *buf, headerControlWordAreaSize);
+	if (r != headerControlWordAreaSize)
+		perror("ERROR: read failed in readHeaderControlWordAreaText");
 	(*buf)[headerControlWordAreaSize] = 0;
 
 	cout << "headerControlWordArea:\n" << *buf << "\n";
--- a/utilities/treeidxutil.cpp
+++ b/utilities/treeidxutil.cpp
@@ -58,27 +58,33 @@
 
 
 void setLocalName(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter New Node Name: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in setLocalName\n";
 	treeKey->setLocalName(buf);
 	treeKey->save();
 }
 
 
 void assurePath(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter path: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in assurePath\n";
 	treeKey->assureKeyPath(buf);
 }
 
 
 void appendSibbling(TreeKeyIdx *treeKey) {
 	if (treeKey->getOffset()) {
-		char buf[1023];
+	  char buf[1023], *c;
 		std::cout << "Enter New Sibbling Name: ";
-		fgets(buf, 1000, stdin);
+		c = fgets(buf, 1000, stdin);
+		if (c == NULL)
+			std::cerr << "ERROR: fgets failed in appendSibbling\n";
 		treeKey->append();
 		treeKey->setLocalName(buf);
 		treeKey->save();
@@ -88,9 +94,11 @@
 
 
 void appendChild(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter New Child Name: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in appendChild\n";
 	treeKey->appendChild();
 	treeKey->setLocalName(buf);
 	treeKey->save();
@@ -123,11 +131,13 @@
 	TreeKeyIdx root = *treeKey;
 
 	std::string input;
-	char line[1024];
+	char line[1024], *c;
 
 	do {
 		std::cout << "[" << treeKey->getText() << "] > ";
-		fgets(line, 1000, stdin);
+		c = fgets(line, 1000, stdin);
+		if (c == NULL)
+			std::cerr << "ERROR: fgets failed in main\n";
 		input = line;
 		if (input.length() > 0) {
 			switch (input[0]) {
--- a/utilities/gbfidx.cpp
+++ b/utilities/gbfidx.cpp
@@ -55,7 +55,7 @@
 int main(int argc, char **argv)
 {
 	long pos, offset;
-	int num1, num2, rangemax;
+	int num1, num2, rangemax, w;
 	char startflag = 0;
 	short size;
 
@@ -67,18 +67,30 @@
 	num1 = key1.getChapter();
 	num2 = key1.getVerse();
 	pos  = 0;
-	write(bfp, &pos, 4);  /* Book    offset for testament intros */
+	w = write(bfp, &pos, 4);  /* Book    offset for testament intros */
+	if (w != 4)
+		perror("ERROR: write failed in main");
 	pos = 4;
-	write(cfp, &pos, 4);  /* Chapter offset for testament intro */
+	w = write(cfp, &pos, 4);  /* Chapter offset for testament intro */
+	if (w != 4)
+		perror("ERROR: write failed in main");
 
 
 /*	Right now just zero out intros until parsing correctly */
 	pos = 0;
 	size = 0;
-	write(vfp, &pos, 4);  /* Module intro */
-	write(vfp, &size, 2);
-	write(vfp, &pos, 4);  /* Testament intro */
-	write(vfp, &size, 2);
+	w = write(vfp, &pos, 4);  /* Module intro */
+	if (w != 4)
+		perror("ERROR: write failed in main");
+	w = write(vfp, &size, 2);
+	if (w != 2)
+		perror("ERROR: write failed in main");
+	w = write(vfp, &pos, 4);  /* Testament intro */
+	if (w != 4)
+		perror("ERROR: write failed in main");
+	w = write(vfp, &size, 2);
+	if (w != 2)
+		perror("ERROR: write failed in main");
 
 	while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
 		if (!startflag) {
@@ -122,6 +134,7 @@
 
 void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
 {
+	int w;
 	long pos;
 	short tmp;
 
@@ -129,26 +142,48 @@
 		if (key1.getVerse() == 1) {	// new chapter
 			if (key1.getChapter() == 1) {	// new book
 				pos = lseek(cfp, 0, SEEK_CUR);
-				write(bfp, &pos, 4);
+				w = write(bfp, &pos, 4);
+				if (w != 2)
+					perror("ERROR: write failed in writeidx");
 				pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
-				write(cfp, &pos, 4);
-				write(vfp, &chapoffset, 4);  /* Book intro (vss)  set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
-				write(vfp, &chapsize, 2);
+				w = write(cfp, &pos, 4);
+				if (w != 2)
+					perror("ERROR: write failed in writeidx");
+				w = write(vfp, &chapoffset, 4);  /* Book intro (vss)  set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
+				if (w != 2)
+					perror("ERROR: write failed in writeidx");
+				w = write(vfp, &chapsize, 2);
+				if (w != 2)
+					perror("ERROR: write failed in writeidx");
 			}
 			pos = lseek(vfp, 0, SEEK_CUR);
-			write(cfp, &pos, 4);
-			write(vfp, &chapoffset, 4);  /* Chapter intro */
-			write(vfp, &chapsize, 2);
+			w = write(cfp, &pos, 4);
+			if (w != 4)
+				perror("ERROR: write failed in writeidx");
+			w = write(vfp, &chapoffset, 4);  /* Chapter intro */
+			if (w != 4)
+				perror("ERROR: write failed in writeidx");
+			w = write(vfp, &chapsize, 2);
+			if (w != 2)
+				perror("ERROR: write failed in writeidx");
 		}
 		if (key1 >= key2) {
-			write(vfp, &offset, 4);
-			write(vfp, &size, 2);
+			w = write(vfp, &offset, 4);
+			if (w != 4)
+				perror("ERROR: write failed in writeidx");
+			w = write(vfp, &size, 2);
+			if (w != 2)
+				perror("ERROR: write failed in writeidx");
 		}
 		else	{
 			pos = 0;
 			tmp = 0;
-			write(vfp, &pos, 4);
-			write(vfp, &tmp, 2);
+			w = write(vfp, &pos, 4);
+			if (w != 4)
+				perror("ERROR: write failed in writeidx");
+			w = write(vfp, &tmp, 2);
+			if (w != 2)
+				perror("ERROR: write failed in writeidx");
 		}
 	}
 }
--- a/utilities/genbookutil.cpp
+++ b/utilities/genbookutil.cpp
@@ -58,9 +58,11 @@
 
 
 void setLocalName(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter New Node Name: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in setLocalName\n";
 	SWBuf name = buf;
 	treeKey->setLocalName(name.trim());
 	treeKey->save();
@@ -68,18 +70,22 @@
 
 
 void gotoPath(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter Path: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in gotoPath\n";
 	SWBuf path = buf;
 	(*treeKey) = path.trim();
 }
 
 
 void assurePath(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter Path: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in assurePath\n";
 	SWBuf path = buf;
 	treeKey->assureKeyPath(path.trim());
 }
@@ -96,10 +102,12 @@
 	SWBuf body;
 	TreeKeyIdx *treeKey = (TreeKeyIdx *)(SWKey *)(*book);
 	if (treeKey->getOffset()) {
-		char buf[1023];
+	  char buf[1023], *c;
 		std::cout << "Enter New Entry Text ('.' on a line by itself to end): \n";
 		do {
-			fgets(buf, 1000, stdin);
+			c = fgets(buf, 1000, stdin);
+			if (c == NULL)
+				std::cerr << "ERROR: fgets failed in setEntryText\n";
 			SWBuf text = buf;
 			text.trim();
 			if ((text[0] == '.') && (text[1] == 0))
@@ -116,9 +124,11 @@
 
 void appendSibbling(TreeKeyIdx *treeKey) {
 	if (treeKey->getOffset()) {
-		char buf[1023];
+	  char buf[1023], *c;
 		std::cout << "Enter New Sibbling Name: ";
-		fgets(buf, 1000, stdin);
+		c = fgets(buf, 1000, stdin);
+		if (c == NULL)
+			std::cerr << "ERROR: fgets failed in appendSibbling\n";
 		SWBuf name = buf;
 		treeKey->append();
 		treeKey->setLocalName(name.trim());
@@ -129,9 +139,11 @@
 
 
 void appendChild(TreeKeyIdx *treeKey) {
-	char buf[1023];
+  char buf[1023], *c;
 	std::cout << "Enter New Child Name: ";
-	fgets(buf, 1000, stdin);
+	c = fgets(buf, 1000, stdin);
+	if (c == NULL)
+		std::cerr << "ERROR: fgets failed in appendChild\n";
 	SWBuf name = buf;
 	treeKey->appendChild();
 	treeKey->setLocalName(name.trim());
@@ -173,11 +185,13 @@
 	treeKey = (TreeKeyIdx *)(SWKey *)(*book);
 
 	SWBuf input;
-	char line[1024];
+	char line[1024], *c;
 
 	do {
 		std::cout << "[" << treeKey->getText() << "] > ";
-		fgets(line, 1000, stdin);
+		c = fgets(line, 1000, stdin);
+		if (c == NULL)
+			std::cerr << "ERROR: fgets failed in main\n";
 		input = line;
 		input.trim();
 		if (input.length() > 0) {
--- a/utilities/vpl2mod.cpp
+++ b/utilities/vpl2mod.cpp
@@ -76,14 +76,18 @@
 			break;
 	}
 	
-	int size = (lseek(fd, 0, SEEK_CUR) - index) - 1;
+	int r, size = (lseek(fd, 0, SEEK_CUR) - index) - 1;
 
 	*buf = new char [ size + 1 ];
 
 	if (size > 0) {
 		lseek(fd, index, SEEK_SET);
-		read(fd, *buf, size);
-		read(fd, &ch, 1);   //pop terminating char
+		r = read(fd, *buf, size);
+		if (r != size)
+			std::cerr <<"ERROR: short read in readline\n";
+		r = read(fd, &ch, 1);   //pop terminating char
+		if (r != size)
+			std::cerr <<"ERROR: short read of terminating char in readline\n";
 		(*buf)[size] = 0;
 
 		// clean up any trailing junk on buf
--- a/utilities/installmgr.cpp
+++ b/utilities/installmgr.cpp
@@ -74,8 +74,10 @@
 		cout << "then type yes at the prompt\n\n";
 		cout << "enable? [no] ";
 
-		char prompt[10];
-		fgets(prompt, 9, stdin);
+		char prompt[10], *c;
+		c = fgets(prompt, 9, stdin);
+		if (c == NULL)
+			std::cerr <<"ERROR: fgets failed in isUserDisclaimerConfirmed\n";
 		confirmed = (!strcmp(prompt, "yes\n"));
 		cout << "\n";
 	}
--- a/utilities/step2vpl.cpp
+++ b/utilities/step2vpl.cpp
@@ -228,93 +228,169 @@
 
 
 void readVersion(int fd, Version *versionRecord) {
+	int r;
 
-	read(fd, &(versionRecord->versionRecordSize), 2);
-	read(fd, &(versionRecord->publisherID), 2);
-	read(fd, &(versionRecord->bookID), 2);
-	read(fd, &(versionRecord->setID), 2);
-	read(fd, &(versionRecord->conversionProgramVerMajor), 1);
-	read(fd, &(versionRecord->conversionProgramVerMinor), 1);
-	read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
-	read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
-	read(fd, &(versionRecord->encryptionType), 1);
-	read(fd, &(versionRecord->editionID), 1);
-	read(fd, &(versionRecord->modifiedBy), 2);
+	r = read(fd, &(versionRecord->versionRecordSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
+
+	r = read(fd, &(versionRecord->publisherID), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->bookID), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->setID), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->conversionProgramVerMajor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->conversionProgramVerMinor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->encryptionType), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->editionID), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readVersion");
+	r = read(fd, &(versionRecord->modifiedBy), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVersion");
 
 	int skip = versionRecord->versionRecordSize - 16/*sizeof(struct Version*/;
 
 	if (skip) {
 		char *skipbuf = new char[skip];
-		read(fd, skipbuf, skip);
+		r = read(fd, skipbuf, skip);
+		if (r != skip)
+			perror("ERROR: read failed in readVersion");
 		delete [] skipbuf;
 	}
 }
 
 
 void readSectionsHeader(int fd, SectionsHeader *sectionsHeaderRecord) {
+	int r;
 
-	read(fd, &(sectionsHeaderRecord->sectionsHeaderRecordSize), 2);
-	read(fd, &(sectionsHeaderRecord->levelEntriesCount), 4);
-	read(fd, &(sectionsHeaderRecord->glossEntriesCount), 4);
-	read(fd, &(sectionsHeaderRecord->levelEntriesSize), 2);
-	read(fd, &(sectionsHeaderRecord->reserved), 4);
+	r = read(fd, &(sectionsHeaderRecord->sectionsHeaderRecordSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readSectionsHeader");
+	r = read(fd, &(sectionsHeaderRecord->levelEntriesCount), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionsHeader");
+	r = read(fd, &(sectionsHeaderRecord->glossEntriesCount), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionsHeader");
+	r = read(fd, &(sectionsHeaderRecord->levelEntriesSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readSectionsHeader");
+	r = read(fd, &(sectionsHeaderRecord->reserved), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionsHeader");
 
 	int skip = sectionsHeaderRecord->sectionsHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/;
 
 	if (skip) {
 		char *skipbuf = new char[skip];
-		read(fd, skipbuf, skip);
+		r = read(fd, skipbuf, skip);
+		if (r != skip)
+			perror("ERROR: read failed in readSectionsHeader");
 		delete [] skipbuf;
 	}
 }
 
 
 void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord) {
+	int r;
 
-	read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
-	read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
-	read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
-	read(fd, &(viewableHeaderRecord->compressionType), 1);
-	read(fd, &(viewableHeaderRecord->reserved1), 1);
-	read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
-	read(fd, &(viewableHeaderRecord->reserved2), 2);
+	r = read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readViewableHeader");
+	r = read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableHeader");
+	r = read(fd, &(viewableHeaderRecord->glossBlocksCount), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableHeader");
+	r = read(fd, &(viewableHeaderRecord->compressionType), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readViewableHeader");
+	r = read(fd, &(viewableHeaderRecord->reserved1), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readViewableHeader");
+	r = read(fd, &(viewableHeaderRecord->blockEntriesSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readViewableHeader");
+	r = read(fd, &(viewableHeaderRecord->reserved2), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readViewableHeader");
 
 	int skip = viewableHeaderRecord->viewableHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/;
 
 	if (skip) {
 		char *skipbuf = new char[skip];
-		read(fd, skipbuf, skip);
+		r = read(fd, skipbuf, skip);
+		if (r != skip)
+			perror("ERROR: read failed in readViewableHeader");
 		delete [] skipbuf;
 	}
 }
 
 
 void readVSyncHeader(int fd, VSyncHeader *vSyncHeaderRecord) {
+	int r;
 
-	read(fd, &(vSyncHeaderRecord->vSyncHeaderRecordSize), 2);
-	read(fd, &(vSyncHeaderRecord->startBookNumber), 2);
-	read(fd, &(vSyncHeaderRecord->endBookNumber), 2);
-	read(fd, &(vSyncHeaderRecord->bookPointerEntriesSize), 2);
-	read(fd, &(vSyncHeaderRecord->syncPointEntriesSize), 2);
-	read(fd, &(vSyncHeaderRecord->reserved1_1), 4);
-	read(fd, &(vSyncHeaderRecord->reserved1_2), 2);
+	r = read(fd, &(vSyncHeaderRecord->vSyncHeaderRecordSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVSyncHeader");
+	r = read(fd, &(vSyncHeaderRecord->startBookNumber), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVSyncHeader");
+	r = read(fd, &(vSyncHeaderRecord->endBookNumber), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVSyncHeader");
+	r = read(fd, &(vSyncHeaderRecord->bookPointerEntriesSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVSyncHeader");
+	r = read(fd, &(vSyncHeaderRecord->syncPointEntriesSize), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVSyncHeader");
+	r = read(fd, &(vSyncHeaderRecord->reserved1_1), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readVSyncHeader");
+	r = read(fd, &(vSyncHeaderRecord->reserved1_2), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readVSyncHeader");
 
 	int skip = vSyncHeaderRecord->vSyncHeaderRecordSize - 16/*sizeof(VSyncHeader)*/;
 
 	if (skip) {
 		char *skipbuf = new char[skip];
-		read(fd, skipbuf, skip);
+		r = read(fd, skipbuf, skip);
+		if (r != skip)
+			perror("ERROR: read failed in readVSyncHeader");
 		delete [] skipbuf;
 	}
 }
 
 
 void readViewableBlockText(int fd, ViewableBlock *vb, char **buf) {
+	int r;
 	unsigned long size = vb->size;
 
 	*buf = new char [ ((vb->size > vb->uncompressedSize) ? vb->size : vb->uncompressedSize) + 1 ];
 	lseek(fd, vb->offset, SEEK_SET);
-	read(fd, *buf, vb->size);
+	r = read(fd, *buf, vb->size);
+	if (r != vb->size)
+		perror("ERROR: read failed in readViewableBlockText");
 
 	compress->zBuf(&size, *buf);
 	strcpy(*buf, compress->Buf());
@@ -322,35 +398,53 @@
 
 
 void readViewableBlock(int fd, ViewableBlock *vb) {
+	int r;
 
-	read(fd, &(vb->offset), 4);
-	read(fd, &(vb->uncompressedSize), 4);
-	read(fd, &(vb->size), 4);
+	r = read(fd, &(vb->offset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableBlock");
+	r = read(fd, &(vb->uncompressedSize), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableBlock");
+	r = read(fd, &(vb->size), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readViewableBlock");
 }
 
 
 void readHeaderControlWordAreaText(int fd, char **buf) {
+	int r;
 	long headerControlWordAreaSize;
-	read(fd, &headerControlWordAreaSize, 4);
+	r = read(fd, &headerControlWordAreaSize, 4);
+	if (r != 4)
+		perror("ERROR: read failed in readHeaderControlWordAreaText");
 
 	*buf = new char [headerControlWordAreaSize + 1];
 
-	read(fd, *buf, headerControlWordAreaSize);
+	r = read(fd, *buf, headerControlWordAreaSize);
+	if (r != headerControlWordAreaSize)
+		perror("ERROR: read failed in readHeaderControlWordAreaText");
 	(*buf)[headerControlWordAreaSize] = 0;
 
 }
 
 void readVSyncBooksInfo(int fd, VSyncHeader *vSyncHeaderRecord, VSyncBooksInfo **vSyncBooksInfo) {
 
+	int r;
 	int bookCount = vSyncHeaderRecord->endBookNumber - vSyncHeaderRecord->startBookNumber;
 	*vSyncBooksInfo = new VSyncBooksInfo[bookCount];
 	for (int i = 0; i <= bookCount; i++) {
-		read(fd, &(*vSyncBooksInfo)[i].offset, 4);
-		read(fd, &(*vSyncBooksInfo)[i].count, 2);
+		r = read(fd, &(*vSyncBooksInfo)[i].offset, 4);
+		if (r != 4)
+			perror("ERROR: read failed in readVSyncBooksInfo");
+		r = read(fd, &(*vSyncBooksInfo)[i].count, 2);
+		if (r != 2)
+			perror("ERROR: read failed in readVSyncBooksInfo");
 	}
 }
 
 void displayBook(int fdbook, int fdviewable, int fdvsync, int fdsections, VSyncBooksInfo *vSyncBooksInfo) {
+	int r;
 	VSyncPoint vSyncPoint;
 
 	lseek(fdvsync, vSyncBooksInfo->offset, SEEK_SET);
@@ -361,9 +455,15 @@
 		char *sectionName;
 		char *verseText;
 
-		read(fdvsync, &(vSyncPoint.chapter), 2);
-		read(fdvsync, &(vSyncPoint.verse), 2);
-		read(fdvsync, &(vSyncPoint.offset), 4);
+		r = read(fdvsync, &(vSyncPoint.chapter), 2);
+		if (r != 2)
+			perror("ERROR: read failed in displayBook");
+		r = read(fdvsync, &(vSyncPoint.verse), 2);
+		if (r != 2)
+			perror("ERROR: read failed in displayBook");
+		r = read(fdvsync, &(vSyncPoint.offset), 4);
+		if (r != 4)
+			perror("ERROR: read failed in displayBook");
 		vSyncPoint.offset = SECTIONSLEVELSTART + (vSyncPoint.offset * SECTIONSLEVELSIZE);
 		lseek(fdsections, vSyncPoint.offset, SEEK_SET);
 		readSectionLevelInfo(fdsections, &sectionLevelInfo);
@@ -418,26 +518,50 @@
 
 
 void readSectionName(int fd, SectionLevelInfo *sli, char **name) {
+	int r;
 	short size;
 	lseek(fd, sli->nameOffset, SEEK_SET);
-	read(fd, &size, 2);
+	r = read(fd, &size, 2);
+	if (r != 2)
+		perror("ERROR: read failed in readSectionName");
 	*name = new char [ size + 1 ];
-	read(fd, *name, size);
+	r = read(fd, *name, size);
+	if (r != size)
+		perror("ERROR: read failed in readSectionName");
 	(*name)[size] = 0;
 }
 
 void readSectionLevelInfo(int fd, SectionLevelInfo *sli) {
+	int r;
 
-	read(fd, &(sli->parentOffset), 4);
-	read(fd, &(sli->previousOffset), 4);
-	read(fd, &(sli->nextOffset), 4);
-	read(fd, &(sli->viewableOffset), 4);
+	r = read(fd, &(sli->parentOffset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->previousOffset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->nextOffset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->viewableOffset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionLevelInfo");
 	sli->viewableOffset = VIEWABLEBLOCKSTART + (VIEWABLEBLOCKSIZE * sli->viewableOffset);
-	read(fd, &(sli->startLevel), 2);
-	read(fd, &(sli->level), 1);
-	read(fd, &(sli->nameOffset), 4);
-	read(fd, &(sli->outSync_1), 4);
-	read(fd, &(sli->outSync_2), 2);
+	r = read(fd, &(sli->startLevel), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->level), 1);
+	if (r != 1)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->nameOffset), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->outSync_1), 4);
+	if (r != 4)
+		perror("ERROR: read failed in readSectionLevelInfo");
+	r = read(fd, &(sli->outSync_2), 2);
+	if (r != 2)
+		perror("ERROR: read failed in readSectionLevelInfo");
 }
 
 void cleanBuf(char *buf) {
--- a/utilities/cipherraw.cpp
+++ b/utilities/cipherraw.cpp
@@ -53,7 +53,7 @@
 	SWCipher *zobj;
 	VerseKey key;
 	RawVerse *rawdrv;
-	int ofd[2], oxfd[2];
+	int ofd[2], oxfd[2], w;
 	long tmpoff = 0, offset, loffset = 0, lzoffset = 0;
 	unsigned short size, lsize = 0, lzsize;
 	char *tmpbuf;
@@ -79,10 +79,18 @@
 	delete [] tmpbuf;
 
 	printf("\n");
-	write(oxfd[0], &lzoffset, 4);
-	write(oxfd[0], &lzsize, 2);
-	write(oxfd[1], &lzoffset, 4);
-	write(oxfd[1], &lzsize, 2);
+	w = write(oxfd[0], &lzoffset, 4);
+	if (w < 0)
+		perror("ERROR: write failed in main");
+	w = write(oxfd[0], &lzsize, 2);
+	if (w < 0)
+		perror("ERROR: write failed in main");
+	w = write(oxfd[1], &lzoffset, 4);
+	if (w < 0)
+		perror("ERROR: write failed in main");
+	w = write(oxfd[1], &lzsize, 2);
+	if (w < 0)
+		perror("ERROR: write failed in main");
 
 	key.setAutoNormalize(false);
 	key.setIntros(true);
@@ -94,8 +102,10 @@
 			printf("using previous offset,size %d\n", size);
 			offset = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR);
 			printf("%ld %ld %d \n", offset, lzoffset, lzsize);
-			write(oxfd[key.getTestament() - 1], &lzoffset, 4);
-			write(oxfd[key.getTestament() - 1], &lzsize, 2);
+			if (write(oxfd[key.getTestament() - 1], &lzoffset, 4) < 0)
+                            perror("ERROR: write failed in main");
+			if (write(oxfd[key.getTestament() - 1], &lzsize, 2) < 0)
+                            perror("ERROR: write failed in main");
 		}
 		else {
 			lsize   = size;
@@ -112,13 +122,17 @@
 			offset = lseek(ofd[key.getTestament() - 1], 0, SEEK_CUR);
 			tmpoff = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR);
 			printf("%s: (%ld) NEW offset: %ld; size: %d\n", (const char *)key, tmpoff, offset, size);
-			write(oxfd[key.getTestament() - 1], &offset, 4);
+			if (write(oxfd[key.getTestament() - 1], &offset, 4) < 0)
+                            perror("ERROR: write failed in main");
 			unsigned long ulSize = size;
-			if (size) 
-				write(ofd[key.getTestament() - 1], zobj->cipherBuf(&ulSize), size);
+			if (size) {
+                            if (write(ofd[key.getTestament() - 1], zobj->cipherBuf(&ulSize), size) < 0)
+                            perror("ERROR: write failed in main");
+                        }
 			size = (unsigned int)ulSize;
 			lzoffset = offset;
-			write(oxfd[key.getTestament() - 1], &size, 2);
+			if (write(oxfd[key.getTestament() - 1], &size, 2) < 0)
+                            perror("ERROR: write failed in main");
 			lzsize = size;
 		}
 	}
--- a/utilities/lexdump.c
+++ b/utilities/lexdump.c
@@ -45,7 +45,7 @@
 
 int main(int argc, char **argv) {
 	char *tmpbuf;
-	int idxfd, datfd;
+	int idxfd, datfd, r;
 	long offset;
 	unsigned int size;
 	char datbuf[255];
@@ -64,11 +64,17 @@
 
 	offset = atoi(argv[2]) * 6;
 	lseek(idxfd, offset, SEEK_SET);
-	read(idxfd, &offset, 4);
-	read(idxfd, &size, 2);
+	r = read(idxfd, &offset, 4);
+	if (r != 4)
+		perror("ERROR: read failed in main");
+	r = read(idxfd, &size, 2);
+	if (r != 2)
+		perror("ERROR: read failed in main");
 	printf("offset: %ld; size: %d\n", offset, size);
 	lseek(datfd, offset, SEEK_SET);
-	read(datfd, datbuf, 40);
+	r = read(datfd, datbuf, 40);
+	if (r != 40)
+		perror("ERROR: read failed in main");
 	datbuf[40] = 0;
 	printf("%s\n", datbuf);
 	close(datfd);