@@ -1428,7 +1428,7 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
1428
1428
}
1429
1429
return ;
1430
1430
}
1431
- info [ilen ] = '\0' ;\
1431
+ info [ilen ] = '\0' ;
1432
1432
1433
1433
p = (struct aprs_mic_e_s * )info ;
1434
1434
@@ -1658,12 +1658,26 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
1658
1658
1659
1659
// The rest is a comment which can have other information cryptically embedded.
1660
1660
// Remove any trailing CR, which I would argue, violates the protocol spec.
1661
- // It is essential to keep trailing spaces. e.g. VX-8 suffix is "_ "
1661
+ // It is essential to keep trailing spaces. e.g. VX-8 device id suffix is "_ "
1662
+
1663
+ if (ilen <= sizeof (struct aprs_mic_e_s )) {
1664
+ // Too short for a comment. We are finished.
1665
+ strlcpy (A -> g_mfr , "UNKNOWN vendor/model" , sizeof (A -> g_mfr ));
1666
+ return ;
1667
+ }
1662
1668
1663
1669
char mcomment [256 ];
1664
1670
strlcpy (mcomment , ((char * )info ) + sizeof (struct aprs_mic_e_s ), sizeof (mcomment ));
1671
+
1672
+ assert (strlen (mcomment ) > 0 );
1673
+
1665
1674
if (mcomment [strlen (mcomment )- 1 ] == '\r' ) {
1666
1675
mcomment [strlen (mcomment )- 1 ] = '\0' ;
1676
+ if (strlen (mcomment ) == 0 ) {
1677
+ // Nothing left after removing trailing CR.
1678
+ strlcpy (A -> g_mfr , "UNKNOWN vendor/model" , sizeof (A -> g_mfr ));
1679
+ return ;
1680
+ }
1667
1681
}
1668
1682
1669
1683
/* Now try to pick out manufacturer and other optional items. */
@@ -1678,7 +1692,7 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
1678
1692
// Three base 91 characters followed by }
1679
1693
1680
1694
1681
- if (strlen (trimmed ) >=4 &&
1695
+ if (strlen (trimmed ) >= 4 &&
1682
1696
isdigit91 (trimmed [0 ]) &&
1683
1697
isdigit91 (trimmed [1 ]) &&
1684
1698
isdigit91 (trimmed [2 ]) &&
0 commit comments