diff options
author | Mathias Kresin <dev@kresin.me> | 2017-06-18 10:28:18 +0200 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2017-06-24 22:36:38 +0200 |
commit | 7e128632522988513c90e5fda44e6aab5b9f21cf (patch) | |
tree | f8c72b803a9dba1c405828c7e57dd815254af039 /package/utils | |
parent | 04063820e85831e4f623faf395323e3e48b18b7d (diff) | |
download | upstream-7e128632522988513c90e5fda44e6aab5b9f21cf.tar.gz upstream-7e128632522988513c90e5fda44e6aab5b9f21cf.tar.bz2 upstream-7e128632522988513c90e5fda44e6aab5b9f21cf.zip |
fritz_tffs_read: get tffs size from input file
Use the size of the input file as maximum tffs size instead of a fixed
value. The tffs on a AVM Fritz 300E can be up to 512KByte for example.
Fixes a read error for the AVM Fritz 3370 where the tffs partition size
is 64Kbyte and smaller than the former default value of 256KByte.
Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'package/utils')
-rw-r--r-- | package/utils/fritz-tools/src/fritz_tffs_read.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/package/utils/fritz-tools/src/fritz_tffs_read.c b/package/utils/fritz-tools/src/fritz_tffs_read.c index 7c311a90ca..d1b3038e63 100644 --- a/package/utils/fritz-tools/src/fritz_tffs_read.c +++ b/package/utils/fritz-tools/src/fritz_tffs_read.c @@ -36,14 +36,12 @@ #include <sys/stat.h> #include <arpa/inet.h> -#define DEFAULT_TFFS_SIZE (256 * 1024) - #define TFFS_ID_END 0xffff #define TFFS_ID_TABLE_NAME 0x01ff static char *progname; static char *input_file; -static unsigned long tffs_size = DEFAULT_TFFS_SIZE; +static unsigned long tffs_size; static char *name_filter = NULL; static bool show_all = false; static bool print_all_key_names = false; @@ -334,6 +332,12 @@ int main(int argc, char *argv[]) goto out; } + if (tffs_size == 0) { + fseek(fp, 0L, SEEK_END); + tffs_size = ftell(fp); + fseek(fp, 0L, SEEK_SET); + } + buffer = malloc(tffs_size); if (fread(buffer, 1, tffs_size, fp) != tffs_size) { |