Skip to content

Commit

Permalink
Fix MIC-E comment when device id is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
wb2osz committed Oct 22, 2024
1 parent 89029db commit 0d7e296
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/deviceid.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,18 @@ void deviceid_decode_dest (char *dest, char *device, size_t device_size)
*
* Inputs: comment - MIC-E comment that might have vendor/model encoded as
* a prefix and/or suffix.
* Any trailing CR has already been removed.
*
* trimmed_size - Amount of space available for result to avoid buffer overflow.
*
* device_size - Amount of space available for result to avoid buffer overflow.
*
* Outputs: trimmed - Final comment with device vendor/model removed.
* This would include any altitude.
*
* device - Vendor and model.
*
* Description: This has a tortured history.
* Description: MIC-E device identification has a tortured history.
*
* The Kenwood TH-D7A put ">" at the beginning of the comment.
* The Kenwood TM-D700 put "]" at the beginning of the comment.
Expand All @@ -593,7 +595,9 @@ void deviceid_decode_dest (char *dest, char *device, size_t device_size)
*
* References: http://www.aprs.org/aprs12/mic-e-types.txt
* http://www.aprs.org/aprs12/mic-e-examples.txt
*
* https://github.com/wb2osz/aprsspec containing:
* APRS Protocol Specification 1.2
* Understanding APRS Packets
*------------------------------------------------------------------*/

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

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

strlcpy (device, "UNKNOWN vendor/model", device_size);
strlcpy (trimmed, comment, sizeof(trimmed));

} // end deviceid_decode_mice

Expand Down

0 comments on commit 0d7e296

Please sign in to comment.