Skip to content

Commit

Permalink
Make parse_qtcline more robust
Browse files Browse the repository at this point in the history
- preinit callsign field
- terminate scanning for space at field length
  • Loading branch information
dl1jbe committed Sep 26, 2024
1 parent b4e027d commit 0e8b180
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/qtcutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ void parse_qtcline(char *logline, char callsign[QTC_CALL_SIZE], int direction) {

int i = 0;

memset(callsign, 0, QTC_CALL_SIZE);

if (direction == RECV) {
strncpy(callsign, logline + 30, QTC_CALL_SIZE - 1);
}
if (direction == SEND) {
strncpy(callsign, logline + 35, QTC_CALL_SIZE - 1);
}
while (callsign[i] != ' ') {
while (i < QTC_CALL_SIZE - 1 && callsign[i] != ' ') {
i++;
}
callsign[i] = '\0';
Expand Down

0 comments on commit 0e8b180

Please sign in to comment.