summaryrefslogtreecommitdiff
path: root/src/bin/embryo
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-08-27 14:29:21 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-08-27 14:29:21 +0900
commit3f97906d704863751aabf7ccb41ffe17ea33eebe (patch)
treebc952e4dc59555f642a1629c457bc2d847b458b2 /src/bin/embryo
parent33d39beac603ea52958817c9df7b8ee12ab9d247 (diff)
embryo_cc - fix bunch of unchecked fseeks
this fixes CID 996788
Diffstat (limited to 'src/bin/embryo')
-rw-r--r--src/bin/embryo/embryo_cc_sc6.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/bin/embryo/embryo_cc_sc6.c b/src/bin/embryo/embryo_cc_sc6.c
index 0ae8c4e52c..a6b299d9a4 100644
--- a/src/bin/embryo/embryo_cc_sc6.c
+++ b/src/bin/embryo/embryo_cc_sc6.c
@@ -830,7 +830,8 @@ assemble(FILE * fout, FILE * fin)
830 if (fseek(fout, publics + count * sizeof(FUNCSTUB), SEEK_SET) < 0) 830 if (fseek(fout, publics + count * sizeof(FUNCSTUB), SEEK_SET) < 0)
831 fprintf(stderr, "Error seeking\n"); 831 fprintf(stderr, "Error seeking\n");
832 sc_writebin(fout, &func, sizeof func); 832 sc_writebin(fout, &func, sizeof func);
833 fseek(fout, nameofs, SEEK_SET); 833 if (fseek(fout, nameofs, SEEK_SET) < 0)
834 fprintf(stderr, "Error seeking\n");
834 sc_writebin(fout, sym->name, strlen(sym->name) + 1); 835 sc_writebin(fout, sym->name, strlen(sym->name) + 1);
835 nameofs += strlen(sym->name) + 1; 836 nameofs += strlen(sym->name) + 1;
836 count++; 837 count++;
@@ -884,9 +885,11 @@ assemble(FILE * fout, FILE * fin)
884 align32(&func.address); 885 align32(&func.address);
885 align32(&func.nameofs); 886 align32(&func.nameofs);
886#endif 887#endif
887 fseek(fout, natives + count * sizeof(FUNCSTUB), SEEK_SET); 888 if (fseek(fout, natives + count * sizeof(FUNCSTUB), SEEK_SET) < 0)
889 fprintf(stderr, "Error seeking\n");
888 sc_writebin(fout, &func, sizeof func); 890 sc_writebin(fout, &func, sizeof func);
889 fseek(fout, nameofs, SEEK_SET); 891 if (fseek(fout, nameofs, SEEK_SET) < 0)
892 fprintf(stderr, "Error seeking\n");
890 sc_writebin(fout, alias, strlen(alias) + 1); 893 sc_writebin(fout, alias, strlen(alias) + 1);
891 nameofs += strlen(alias) + 1; 894 nameofs += strlen(alias) + 1;
892 count++; 895 count++;
@@ -908,9 +911,11 @@ assemble(FILE * fout, FILE * fin)
908 align32(&func.address); 911 align32(&func.address);
909 align32(&func.nameofs); 912 align32(&func.nameofs);
910#endif 913#endif
911 fseek(fout, libraries + count * sizeof(FUNCSTUB), SEEK_SET); 914 if (fseek(fout, libraries + count * sizeof(FUNCSTUB), SEEK_SET) < 0)
915 fprintf(stderr, "Error seeking\n");
912 sc_writebin(fout, &func, sizeof func); 916 sc_writebin(fout, &func, sizeof func);
913 fseek(fout, nameofs, SEEK_SET); 917 if (fseek(fout, nameofs, SEEK_SET) < 0)
918 fprintf(stderr, "Error seeking\n");
914 sc_writebin(fout, constptr->name, strlen(constptr->name) + 1); 919 sc_writebin(fout, constptr->name, strlen(constptr->name) + 1);
915 nameofs += strlen(constptr->name) + 1; 920 nameofs += strlen(constptr->name) + 1;
916 count++; 921 count++;
@@ -931,9 +936,11 @@ assemble(FILE * fout, FILE * fin)
931 align32(&func.address); 936 align32(&func.address);
932 align32(&func.nameofs); 937 align32(&func.nameofs);
933#endif 938#endif
934 fseek(fout, pubvars + count * sizeof(FUNCSTUB), SEEK_SET); 939 if (fseek(fout, pubvars + count * sizeof(FUNCSTUB), SEEK_SET) < 0)
940 fprintf(stderr, "Error seeking\n");
935 sc_writebin(fout, &func, sizeof func); 941 sc_writebin(fout, &func, sizeof func);
936 fseek(fout, nameofs, SEEK_SET); 942 if (fseek(fout, nameofs, SEEK_SET) < 0)
943 fprintf(stderr, "Error seeking\n");
937 sc_writebin(fout, sym->name, strlen(sym->name) + 1); 944 sc_writebin(fout, sym->name, strlen(sym->name) + 1);
938 nameofs += strlen(sym->name) + 1; 945 nameofs += strlen(sym->name) + 1;
939 count++; 946 count++;
@@ -954,9 +961,11 @@ assemble(FILE * fout, FILE * fin)
954 align32(&func.address); 961 align32(&func.address);
955 align32(&func.nameofs); 962 align32(&func.nameofs);
956#endif 963#endif
957 fseek(fout, tags + count * sizeof(FUNCSTUB), SEEK_SET); 964 if (fseek(fout, tags + count * sizeof(FUNCSTUB), SEEK_SET) < 0)
965 fprintf(stderr, "Error seeking\n");
958 sc_writebin(fout, &func, sizeof func); 966 sc_writebin(fout, &func, sizeof func);
959 fseek(fout, nameofs, SEEK_SET); 967 if (fseek(fout, nameofs, SEEK_SET) < 0)
968 fprintf(stderr, "Error seeking\n");
960 sc_writebin(fout, constptr->name, strlen(constptr->name) + 1); 969 sc_writebin(fout, constptr->name, strlen(constptr->name) + 1);
961 nameofs += strlen(constptr->name) + 1; 970 nameofs += strlen(constptr->name) + 1;
962 count++; 971 count++;
@@ -965,13 +974,15 @@ assemble(FILE * fout, FILE * fin)
965 974
966 /* write the "maximum name length" field in the name table */ 975 /* write the "maximum name length" field in the name table */
967 assert(nameofs == nametable + nametablesize); 976 assert(nameofs == nametable + nametablesize);
968 fseek(fout, nametable, SEEK_SET); 977 if (fseek(fout, nametable, SEEK_SET) < 0)
978 fprintf(stderr, "Error seeking\n");
969 count = sNAMEMAX; 979 count = sNAMEMAX;
970#ifdef WORDS_BIGENDIAN 980#ifdef WORDS_BIGENDIAN
971 align16(&count); 981 align16(&count);
972#endif 982#endif
973 sc_writebin(fout, &count, sizeof count); 983 sc_writebin(fout, &count, sizeof count);
974 fseek(fout, cod, SEEK_SET); 984 if (fseek(fout, cod, SEEK_SET) < 0)
985 fprintf(stderr, "Error seeking\n");
975 986
976 /* First pass: relocate all labels */ 987 /* First pass: relocate all labels */
977 /* This pass is necessary because the code addresses of labels is only known 988 /* This pass is necessary because the code addresses of labels is only known