diff options
-rw-r--r-- | tools/mi4.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/mi4.c b/tools/mi4.c index 52f043469f..cf052be6eb 100644 --- a/tools/mi4.c +++ b/tools/mi4.c | |||
@@ -118,7 +118,7 @@ int mi4_encode(char *iname, char *oname, int version, int magic, | |||
118 | } | 118 | } |
119 | fseek(file,0,SEEK_END); | 119 | fseek(file,0,SEEK_END); |
120 | length = ftell(file); | 120 | length = ftell(file); |
121 | 121 | ||
122 | fseek(file,0,SEEK_SET); | 122 | fseek(file,0,SEEK_SET); |
123 | 123 | ||
124 | /* Add 4 bytes to length (for magic), the 0x200 byte header and | 124 | /* Add 4 bytes to length (for magic), the 0x200 byte header and |
@@ -150,15 +150,15 @@ int mi4_encode(char *iname, char *oname, int version, int magic, | |||
150 | int2le(length+4, &outbuf[0x2e8]); /* length plus 0xaa55aa55 */ | 150 | int2le(length+4, &outbuf[0x2e8]); /* length plus 0xaa55aa55 */ |
151 | 151 | ||
152 | int2le(0xaa55aa55, &outbuf[0x200+length]); /* More Magic */ | 152 | int2le(0xaa55aa55, &outbuf[0x200+length]); /* More Magic */ |
153 | 153 | ||
154 | strncpy((char *)outbuf+0x1f8, type, 4); /* type of binary (RBBL, RBOS) */ | 154 | strncpy((char *)outbuf+0x1f8, type, 4); /* type of binary (RBBL, RBOS) */ |
155 | strncpy((char *)outbuf+0x1fc, model, 4); /* 4 character model id */ | 155 | strncpy((char *)outbuf+0x1fc, model, 4); /* 4 character model id */ |
156 | 156 | ||
157 | /* Calculate CRC32 checksum */ | 157 | /* Calculate CRC32 checksum */ |
158 | chksum_crc32gentab (); | 158 | chksum_crc32gentab (); |
159 | crc = chksum_crc32 (outbuf+0x200,mi4length-0x200); | 159 | crc = chksum_crc32 (outbuf+0x200,mi4length-0x200); |
160 | 160 | ||
161 | strncpy((char *)outbuf, "PPOS", 4); /* Magic */ | 161 | memcpy(outbuf, "PPOS", 4); /* Magic */ |
162 | int2le(version, &outbuf[0x04]); /* .mi4 version */ | 162 | int2le(version, &outbuf[0x04]); /* .mi4 version */ |
163 | int2le(length+4, &outbuf[0x08]); /* Length of firmware plus magic */ | 163 | int2le(length+4, &outbuf[0x08]); /* Length of firmware plus magic */ |
164 | int2le(crc, &outbuf[0x0c]); /* CRC32 of mi4 file */ | 164 | int2le(crc, &outbuf[0x0c]); /* CRC32 of mi4 file */ |
@@ -168,7 +168,7 @@ int mi4_encode(char *iname, char *oname, int version, int magic, | |||
168 | 168 | ||
169 | /* v3 files require a dummy DSA signature */ | 169 | /* v3 files require a dummy DSA signature */ |
170 | if (version == 0x00010301) { | 170 | if (version == 0x00010301) { |
171 | outbuf[0x2f]=0x01; | 171 | outbuf[0x2f]=0x01; |
172 | } | 172 | } |
173 | 173 | ||
174 | file = fopen(oname, "wb"); | 174 | file = fopen(oname, "wb"); |
@@ -176,7 +176,7 @@ int mi4_encode(char *iname, char *oname, int version, int magic, | |||
176 | perror(oname); | 176 | perror(oname); |
177 | return -3; | 177 | return -3; |
178 | } | 178 | } |
179 | 179 | ||
180 | len = fwrite(outbuf, 1, mi4length, file); | 180 | len = fwrite(outbuf, 1, mi4length, file); |
181 | if(len < (size_t)length) { | 181 | if(len < (size_t)length) { |
182 | perror(oname); | 182 | perror(oname); |