summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-10-12 18:10:39 +0000
committerDave Chapman <dave@dchapman.com>2008-10-12 18:10:39 +0000
commit3d30029883e7e2a862bceede967d95d0bfbd93bb (patch)
tree73044460826fdd8c2312f30e6281a11b766f9dd1
parent80cdc34a54a358b13e9bc2d8eb9b9a83b24868a2 (diff)
downloadrockbox-3d30029883e7e2a862bceede967d95d0bfbd93bb.tar.gz
rockbox-3d30029883e7e2a862bceede967d95d0bfbd93bb.tar.bz2
rockbox-3d30029883e7e2a862bceede967d95d0bfbd93bb.zip
Fix a nasty bug spotted by Rob Purchase - the uploaded file was being truncated to a multiple of 64 bytes (PACKET_SIZE).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18787 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/tcctool/tcctool.c9
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)
int main(int argc, char* argv[])
{
char* buf;
- int n,len;
+ int n,len,padded_len;
int fd;
int device;
@@ -306,7 +306,10 @@ int main(int argc, char* argv[])
return 5;
}
- buf = malloc(len);
+ /* Round len up to multiple of PACKET_SIZE */
+ padded_len = (len + PACKET_SIZE) & ~(PACKET_SIZE-1);
+
+ buf = malloc(padded_len);
if (buf == NULL)
{
printf("[ERR] Could not allocate memory.\n");
@@ -323,7 +326,7 @@ int main(int argc, char* argv[])
}
close(fd);
- do_patching(device, buf, len);
+ do_patching(device, buf, padded_len);
return 0;
}