Skip to content

Commit 0d7e296

Browse files
committed
Fix MIC-E comment when device id is missing.
1 parent 89029db commit 0d7e296

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/deviceid.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -568,16 +568,18 @@ void deviceid_decode_dest (char *dest, char *device, size_t device_size)
568568
*
569569
* Inputs: comment - MIC-E comment that might have vendor/model encoded as
570570
* a prefix and/or suffix.
571+
* Any trailing CR has already been removed.
571572
*
572573
* trimmed_size - Amount of space available for result to avoid buffer overflow.
573574
*
574575
* device_size - Amount of space available for result to avoid buffer overflow.
575576
*
576577
* Outputs: trimmed - Final comment with device vendor/model removed.
578+
* This would include any altitude.
577579
*
578580
* device - Vendor and model.
579581
*
580-
* Description: This has a tortured history.
582+
* Description: MIC-E device identification has a tortured history.
581583
*
582584
* The Kenwood TH-D7A put ">" at the beginning of the comment.
583585
* The Kenwood TM-D700 put "]" at the beginning of the comment.
@@ -593,7 +595,9 @@ void deviceid_decode_dest (char *dest, char *device, size_t device_size)
593595
*
594596
* References: http://www.aprs.org/aprs12/mic-e-types.txt
595597
* http://www.aprs.org/aprs12/mic-e-examples.txt
596-
*
598+
* https://github.com/wb2osz/aprsspec containing:
599+
* APRS Protocol Specification 1.2
600+
* Understanding APRS Packets
597601
*------------------------------------------------------------------*/
598602

599603
// The strncmp documentation doesn't mention behavior if length is zero.
@@ -612,6 +616,10 @@ static inline int strncmp_z (char *a, char *b, size_t len)
612616
void deviceid_decode_mice (char *comment, char *trimmed, size_t trimmed_size, char *device, size_t device_size)
613617
{
614618
strlcpy (device, "UNKNOWN vendor/model", device_size);
619+
strlcpy (trimmed, comment, sizeof(trimmed));
620+
if (strlen(comment) < 1) {
621+
return;
622+
}
615623

616624
if (ptocalls == NULL) {
617625
text_color_set(DW_COLOR_ERROR);
@@ -663,6 +671,7 @@ void deviceid_decode_mice (char *comment, char *trimmed, size_t trimmed_size, ch
663671
// Not found.
664672

665673
strlcpy (device, "UNKNOWN vendor/model", device_size);
674+
strlcpy (trimmed, comment, sizeof(trimmed));
666675

667676
} // end deviceid_decode_mice
668677

0 commit comments

Comments
 (0)