Skip to content

Commit

Permalink
Fix buffer overflow if 6 char locator is used for MYQRA (#450)
Browse files Browse the repository at this point in the history
* Furthermore drop trailing '\n'
  • Loading branch information
dl1jbe authored Dec 23, 2024
1 parent 7d38334 commit 7486277
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,8 @@ static int cfg_rttymode(const cfg_arg_t arg) {
}

static int cfg_myqra(const cfg_arg_t arg) {
strcpy(my.qra, parameter);
g_strlcpy(my.qra, parameter, sizeof(my.qra));
g_strchomp(my.qra);

if (check_qra(my.qra) == 0) {
return PARSE_WRONG_PARAMETER;
Expand Down
8 changes: 7 additions & 1 deletion test/test_parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,13 @@ void test_digimodem(void **state) {
void test_myqra(void **state) {
int rc = call_parse_logcfg("MYQRA=JN97\n");
assert_int_equal(rc, PARSE_OK);
assert_string_equal(my.qra, "JN97\n"); // FIXME NL...
assert_string_equal(my.qra, "JN97");
}

void test_myqra2(void **state) {
int rc = call_parse_logcfg("MYQRA=JN97LA\n");
assert_int_equal(rc, PARSE_OK);
assert_string_equal(my.qra, "JN97LA");
}

void test_powermult(void **state) {
Expand Down

0 comments on commit 7486277

Please sign in to comment.