From 511ed5cfe3da9be7d6f656b6a7f0b719d9b7ab45 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 17 Sep 2019 19:55:54 -0700 Subject: [PATCH] Fix #37: crash when updating a callsign database on MD-2017, and it does not fit. --- d868uv.c | 5 +++-- uv380.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/d868uv.c b/d868uv.c index ba61fdf..8f3ecc5 100644 --- a/d868uv.c +++ b/d868uv.c @@ -2863,8 +2863,9 @@ static void d868uv_write_csv(radio_device_t *radio, FILE *csv) // Add map record. if (sz.count >= NCALLSIGNS) { - fprintf(stderr, "Too many contacts!\n"); - return; + fprintf(stderr, "WARNING: Too many callsigns!\n"); + fprintf(stderr, "Skipping the rest.\n"); + break; } callsign_map_t *m = &map[sz.count]; sz.count++; diff --git a/uv380.c b/uv380.c index 3b3cee5..3e5fe29 100644 --- a/uv380.c +++ b/uv380.c @@ -2454,6 +2454,11 @@ static void uv380_write_csv(radio_device_t *radio, FILE *csv) } cs = GET_CALLSIGN(mem, nrecords); + if ((uint8_t*) (cs + 1) > &mem[nbytes]) { + fprintf(stderr, "WARNING: Too many callsigns!\n"); + fprintf(stderr, "Skipping the rest.\n"); + break; + } nrecords++; // Fill callsign structure.