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>
#include <sys/stat.h>
#include <arpa/inet.h>
#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;
#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;
static char *name_filter = NULL;
static bool show_all = false;
static bool print_all_key_names = false;
+ 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) {
buffer = malloc(tffs_size);
if (fread(buffer, 1, tffs_size, fp) != tffs_size) {