diff options
Diffstat (limited to 'tools/gigabeats.c')
-rw-r--r-- | tools/gigabeats.c | 13 |
1 files changed, 10 insertions, 3 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); |