otrx: bump buffer size in otrx_create_append_file
[openwrt/openwrt.git] / package / utils / otrx / src / otrx.c
index 7e117c6e0db7ab97933cd9cc220a09765c6b6349..0d99cd39e3e21321236522a2e50e9016be29d15d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * otrx
  *
- * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
+ * Copyright (C) 2015-2017 Rafał Miłecki <zajec5@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -228,14 +228,11 @@ out:
  * Create
  **************************************************/
 
-static void otrx_create_parse_options(int argc, char **argv) {
-}
-
 static ssize_t otrx_create_append_file(FILE *trx, const char *in_path) {
        FILE *in;
        size_t bytes;
        ssize_t length = 0;
-       uint8_t buf[128];
+       uint8_t buf[1024];
 
        in = fopen(in_path, "r");
        if (!in) {
@@ -334,9 +331,6 @@ static int otrx_create(int argc, char **argv) {
        }
        trx_path = argv[2];
 
-       optind = 3;
-       otrx_create_parse_options(argc, argv);
-
        trx = fopen(trx_path, "w+");
        if (!trx) {
                fprintf(stderr, "Couldn't open %s\n", trx_path);
@@ -408,6 +402,12 @@ static int otrx_create(int argc, char **argv) {
                        break;
        }
 
+       sbytes = otrx_create_align(trx, curr_offset, 0x1000);
+       if (sbytes < 0)
+               fprintf(stderr, "Failed to append zeros\n");
+       else
+               curr_offset += sbytes;
+
        hdr.length = curr_offset;
        otrx_create_write_hdr(trx, &hdr);
 err_close: