diff options
Diffstat (limited to 'utils/tcctool/tcctool.c')
-rw-r--r-- | utils/tcctool/tcctool.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/utils/tcctool/tcctool.c b/utils/tcctool/tcctool.c index 533f088555..c1d7a46553 100644 --- a/utils/tcctool/tcctool.c +++ b/utils/tcctool/tcctool.c | |||
@@ -258,7 +258,7 @@ void print_usage(void) | |||
258 | int main(int argc, char* argv[]) | 258 | int main(int argc, char* argv[]) |
259 | { | 259 | { |
260 | char* buf; | 260 | char* buf; |
261 | int n,len; | 261 | int n,len,padded_len; |
262 | int fd; | 262 | int fd; |
263 | int device; | 263 | int device; |
264 | 264 | ||
@@ -306,7 +306,10 @@ int main(int argc, char* argv[]) | |||
306 | return 5; | 306 | return 5; |
307 | } | 307 | } |
308 | 308 | ||
309 | buf = malloc(len); | 309 | /* Round len up to multiple of PACKET_SIZE */ |
310 | padded_len = (len + PACKET_SIZE) & ~(PACKET_SIZE-1); | ||
311 | |||
312 | buf = malloc(padded_len); | ||
310 | if (buf == NULL) | 313 | if (buf == NULL) |
311 | { | 314 | { |
312 | printf("[ERR] Could not allocate memory.\n"); | 315 | printf("[ERR] Could not allocate memory.\n"); |
@@ -323,7 +326,7 @@ int main(int argc, char* argv[]) | |||
323 | } | 326 | } |
324 | close(fd); | 327 | close(fd); |
325 | 328 | ||
326 | do_patching(device, buf, len); | 329 | do_patching(device, buf, padded_len); |
327 | 330 | ||
328 | return 0; | 331 | return 0; |
329 | } | 332 | } |