X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/8100977aad24afb940692c4b3ab94b5f3f43fcd3..85dd88a3c6f86d2ecd5c2233aca50752b5ccafbc:/tools/firmware-utils/src/motorola-bin.c diff --git a/tools/firmware-utils/src/motorola-bin.c b/tools/firmware-utils/src/motorola-bin.c index 680249c00..fecb4ce95 100644 --- a/tools/firmware-utils/src/motorola-bin.c +++ b/tools/firmware-utils/src/motorola-bin.c @@ -6,7 +6,6 @@ * D. Hugh Redelmeier * OpenWrt.org * - * $Id$ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -170,7 +169,7 @@ int main(int argc, char **argv) exit(3); } else { // all is well, write the file without the prefix - if ((fd = open(argv[3], O_CREAT|O_WRONLY,0644)) < 0 + if ((fd = open(argv[3], O_CREAT|O_WRONLY|O_TRUNC,0644)) < 0 || write(fd, trx + sizeof(struct motorola), len - sizeof(struct motorola)) != len - sizeof(struct motorola) || close(fd) < 0) { @@ -211,7 +210,7 @@ int main(int argc, char **argv) firmware->crc = htonl(crc32buf((unsigned char *)&firmware->flags, sizeof(firmware->flags) + len)); // write the firmware - if ((fd = open(argv[3], O_CREAT|O_WRONLY,0644)) < 0 + if ((fd = open(argv[3], O_CREAT|O_WRONLY|O_TRUNC,0644)) < 0 || write(fd, firmware, sizeof(struct motorola) + len) != sizeof(struct motorola) + len || close(fd) < 0) {