Fix APRS call sign padding and reading past end of source buffer

pull/11/head
Mikael Nousiainen 2022-02-18 10:38:43 +02:00
rodzic 591c5cb2d3
commit 8c13702598
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -81,12 +81,14 @@ uint16_t ax25_encode_packet_aprs(char *source, uint8_t source_ssid, char *destin
header->flag = AX25_PACKET_FLAG;
size_t call_length = strlen(source);
memset(header->source, ' ', sizeof(header->source));
memcpy(header->source, source, 6);
memcpy(header->source, source, call_length < 6 ? call_length : 6);
header->source_ssid = (uint8_t) (source_ssid >= 'A' ? source_ssid - 7 : source_ssid);;
call_length = strlen(destination);
memset(header->destination, ' ', sizeof(header->destination));
memcpy(header->destination, destination, 6);
memcpy(header->destination, destination, call_length < 6 ? call_length : 6);
header->destination_ssid = destination_ssid;
char *digipeater_addresses_start = ((char *) header) + 1 + 14;