Skip to content

Commit 73943ed

Browse files
committed
More error checking.
1 parent 33beb24 commit 73943ed

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/decode_aprs.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,15 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
14211421

14221422
strlcpy (A->g_data_type_desc, "MIC-E", sizeof(A->g_data_type_desc));
14231423

1424+
if (ilen < sizeof(struct aprs_mic_e_s)) {
1425+
if ( ! A->g_quiet) {
1426+
text_color_set(DW_COLOR_ERROR);
1427+
dw_printf("MIC-E format must have at least %d characters in the information part.\n", sizeof(struct aprs_mic_e_s));
1428+
}
1429+
return;
1430+
}
1431+
info[ilen] = '\0';\
1432+
14241433
p = (struct aprs_mic_e_s *)info;
14251434

14261435
/* Destination is really latitude of form ddmmhh. */
@@ -3875,7 +3884,7 @@ double get_longitude_9 (char *p, int quiet)
38753884
*
38763885
* Inputs: p - Pointer to first byte.
38773886
*
3878-
* Returns: time_t data type. (UTC)
3887+
* Returns: time_t data type. (UTC) Zero if error.
38793888
*
38803889
* Description:
38813890
*
@@ -3945,6 +3954,13 @@ time_t get_timestamp (decode_aprs_t *A, char *p)
39453954
/* h = UTC. */
39463955
} *phms;
39473956

3957+
if ( ! (isdigit(p[0]) && isdigit(p[1]) && isdigit(p[2]) && isdigit(p[3]) && isdigit(p[4]) && isdigit(p[5]) &&
3958+
(p[6] == 'z' || p[6] == '/' || p[6] == 'h'))) {
3959+
text_color_set(DW_COLOR_ERROR);
3960+
dw_printf("Timestamp must be 6 digits followed by z, h, or /.\n");
3961+
return ((time_t)0);
3962+
}
3963+
39483964
struct tm *ptm;
39493965

39503966
time_t ts;

0 commit comments

Comments
 (0)