Closed dwrobel closed 4 months ago
Could you add a printf of the argument past to strsetdir to see if it is garbage or if it is a very long string that overflows the static buffer.
Fwiw I have been working to harden the code, but have not got to the qt app yet. The console apps are now passing many tests. It my experimental code strsetdir() guards the destination buffer, see https://github.com/ourairquality/RTKLIB/blob/oaq-rewrite/src/stream.c#L3078 and might have reported a clearer error. But that can not protect against having been passed garbage. This experimental code is not adapted to the qt_gui branch, but the demo5 qt code runs, and an attempt has been made to apply respective changes to the windows code. There is a slight update to the qu_gui branch pending https://github.com/rtklibexplorer/RTKLIB/pull/271 There in one outstanding patch to the demo5 qt app code, see https://github.com/rtklibexplorer/RTKLIB/pull/273, but this was applied to the qt_gui branch.
Could you add a printf of the argument past to strsetdir to see if it is garbage or if it is a very long string that overflows the static buffer.
Actually, gdb
partially dumps its value, see arguments passed to __strcpy_chk()
in frame 7
:
(dest=0x7f8ea26bf8c0 <localdir.lto_priv> "", src=0x5570d6fcb6e8 '\377' <repeats 44 times>, "\370\366\366\377\232hh\377\225``\377\376\375\375", '\377' <repeats 17 times>, "\232hh\377\276\234\234\377\343\324\324\377ɭ\255\377з\267\377\365\360\360\377\376\376\376\377\377\377\377\377\376\376\376\377\377\377\377\377\376\377\377\377\246}~\377\253f^\377\277gU\377\255f\\\377\264\220\220\377\372\370\370\377\376\376\376\377\376\376\376", '\377' <repeats 13 times>, "\257\210\210\377\250~~\377\376\375\375\377\377\377\377\377\376\376\376\377\377\377\377\377\342\324\324\377\230ee\377\270\224\224\377"..., destlen=1024) at strcpy_chk.c:30
FYI, the strlen(optDialog->fileOptions.tempdir)
returns 3576
.
Might be initialized from the constructor in appcmn_qt/navi_post_opt.cpp
, can you check that the following is working:
if (options == NaviOptions)
strncpy(filopt.tempdir, qPrintable(ui->lELocalDirectory->text()), MAXSTRPATH-1);
Btw these uses of strncpy are also unsafe as they do not ensure that the string is nul terminated.
Also truncating a path may also not be great. Might consider adding a string-copy-or-default function to more gracefully fail.
Sorry, that was the load/save options code paths. As a work-around open the options and then close, before starting.
Might be initialized from the constructor in appcmn_qt/navi_post_opt.cpp, can you check that the following is working:
No, it doesn't. The following method:
(gdb) b OptDialog::save
Breakpoint 2 at 0x56046b4fc070: file ../appcmn_qt/navi_post_opt.cpp, line 935.
is not invoked at all in those two scenarios I'm using:
1) Launch the program, press Start
button (as a first operation).
2) Lauch the program, press I
button (Define input streams), then activate "(1) Rover" with Stream Type: "TCP Client", Stream Options: { Server Address: localhost, Port: 12345}, then press Start
button.
Once I go to "Options" and then use "Save..." then the OptDialog::save method is invoked:
(gdb) b 1094
Breakpoint 3 at 0x56466e7011a6: file ../appcmn_qt/navi_post_opt.cpp, line 1094.
(gdb) c
Continuing.
[Thread 0x7f6150e006c0 (LWP 2059826) exited]
[Thread 0x7f61522006c0 (LWP 2059825) exited]
[Thread 0x7f61320006c0 (LWP 2059824) exited]
[Thread 0x7f61518006c0 (LWP 2059823) exited]
Thread 1 "rtknavi_qt" hit Breakpoint 3, OptDialog::save (this=0x564670355b70,
file=...) at ../appcmn_qt/navi_post_opt.cpp:1094
1094 if (options == NaviOptions)
(gdb) p options
$1 = 0
(gdb) n
1095 strncpy(filopt.tempdir, qPrintable(ui->lELocalDirectory->text()), MAXSTRPATH-1);
(gdb) n
1100 time2str(utc2gpst(timeget()), s, 0);
(gdb) p filopt.tempdir
$2 = "C:\\Temp", '\000' <repeats 1016 times>
(gdb) c
Continuing.
and the "Start" button is working fine.
Please give the lastest version in the qt_gui branch a try. There was a missing initialization in the options dialog.
And: please keep reporting bugs. It is nearly impossible to test every functionality of such a big piece software alone.
Please give the lastest version in the qt_gui branch a try. There was a missing initialization in the options dialog.
Tested using 68a355b and it works fine. Thanks for the fix.
rtknavi_qt
compiled on Fedora 39, from latest sources bf9284d1daae00528f4dfbb890efc43d85bbfa17 _(qt_qui
branch), crashes as following when pressingStart
button (it's irrelevant if you've configured any "Input Stream" or not)_:It looks that
optDialog->fileOptions.tempdir
(see frame 8) contains a garbage.