diff options
-rw-r--r-- | tools/gigabeats.c | 13 | ||||
-rw-r--r-- | tools/scramble.c | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/tools/gigabeats.c b/tools/gigabeats.c index 49670a7dc3..2d2d489865 100644 --- a/tools/gigabeats.c +++ b/tools/gigabeats.c | |||
@@ -74,6 +74,7 @@ int gigabeat_s_code(char *infile, char *outfile) | |||
74 | unsigned int size; | 74 | unsigned int size; |
75 | unsigned int newsize; | 75 | unsigned int newsize; |
76 | unsigned char* buf; | 76 | unsigned char* buf; |
77 | size_t rc; | ||
77 | 78 | ||
78 | in = openinfile(infile); | 79 | in = openinfile(infile); |
79 | out = openoutfile(outfile); | 80 | out = openoutfile(outfile); |
@@ -87,13 +88,19 @@ int gigabeat_s_code(char *infile, char *outfile) | |||
87 | newsize = 15 + 16 + 12 + size + 12; | 88 | newsize = 15 + 16 + 12 + size + 12; |
88 | buf = malloc(newsize); | 89 | buf = malloc(newsize); |
89 | if(buf == NULL) { | 90 | if(buf == NULL) { |
90 | fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" ); | 91 | fprintf(stderr, |
91 | return 0; | 92 | "Not enough memory to perform the operation. Aborting.\n" ); |
93 | return 1; | ||
92 | } | 94 | } |
93 | fseek(in, 0, SEEK_SET); | 95 | fseek(in, 0, SEEK_SET); |
94 | fread(buf + 43, size, 1, in); | 96 | rc = fread(buf + 43, 1, size, in); |
95 | fclose(in); | 97 | fclose(in); |
96 | 98 | ||
99 | if(rc != size) { | ||
100 | /* failed to read the wanted amount */ | ||
101 | fprintf(stderr, "Failed reading from %s.\n", infile); | ||
102 | return 2; | ||
103 | } | ||
97 | /* Step 2: Create the file header */ | 104 | /* Step 2: Create the file header */ |
98 | sprintf((char *)buf, "B000FF\n"); | 105 | sprintf((char *)buf, "B000FF\n"); |
99 | put_uint32le(0x88200000, buf+7); | 106 | put_uint32le(0x88200000, buf+7); |
diff --git a/tools/scramble.c b/tools/scramble.c index a11a5d5263..a8bb9a9680 100644 --- a/tools/scramble.c +++ b/tools/scramble.c | |||
@@ -329,8 +329,7 @@ int main (int argc, char** argv) | |||
329 | else if(!strcmp(argv[1], "-gigabeats")) { | 329 | else if(!strcmp(argv[1], "-gigabeats")) { |
330 | iname = argv[2]; | 330 | iname = argv[2]; |
331 | oname = argv[3]; | 331 | oname = argv[3]; |
332 | gigabeat_s_code(iname, oname); | 332 | return gigabeat_s_code(iname, oname); |
333 | return 0; | ||
334 | } | 333 | } |
335 | else if(!strcmp(argv[1], "-iaudiox5")) { | 334 | else if(!strcmp(argv[1], "-iaudiox5")) { |
336 | iname = argv[2]; | 335 | iname = argv[2]; |