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
diff --git a/rbutil/mkamsboot/dualboot/bin2c.c b/rbutil/mkamsboot/dualboot/bin2c.c
index 830224c..856bcbe 100644
--- a/rbutil/mkamsboot/dualboot/bin2c.c
+++ b/rbutil/mkamsboot/dualboot/bin2c.c
@@ -97,6 +97,8 @@ int main (int argc, char* argv[])
     for(i=0; i < argc - 2; i++) {
         unsigned char* buf;
         off_t len;
+        off_t orig_len;
+        int j;
         char *ext;
         char *array = argv[2+i];

@@ -108,14 +110,21 @@ int main (int argc, char* argv[])
             return 4;
         }

-        len = filesize(fd);
+        orig_len = filesize(fd);
+        /* pad to 32bit */
+        len = (orig_len + 3) & ~3;

         buf = malloc(len);
-        if (read(fd,buf,len) < len) {
+        if (read(fd,buf,orig_len) < orig_len) {
             fprintf(stderr,"Short read, aborting\n");
             return 5;
         }

+        /* pad to 32bit with zeros */
+        for(j = orig_len; j < len; j++)
+            buf[j] = 0;
+        
+        /* append 0
         /* remove file extension */
         ext = strchr (array, '.');
         if (ext != NULL)