Closed dforsi closed 2 years ago
Good point, I setup CodeQL on GitHub, but running this tool is good too! I should include it in the pipeline.
But these errors are related to a some decoding options (ex. usehashtable), and I got some issues in the past, on Raspberry Pi devices, but not on regular x86 devices. RaspberryPi FS is based on low performance SD-Card, and I'm not sure what is going on. It could be related to this finding ('"hashtable.txt"' is opened for read and write access at the same time) but I'm not sure. Anyway I will fix it.
Thanks for this report! 73
@dforsi I created this MR : https://github.com/Guenael/rtlsdr-wsprd/pull/45
but some additional tests are required.
I will also do some code reformat with clang-format
, cannot read this code ^^
I guess I missing something on the call6=strtok(NULL," ");
...
I could created some impact/issue
I guess I missing something on the call6=strtok(NULL," "); ... I could created some impact/issue
I think that the problem is that memory is allocated here:
wsprd/wsprsim_utils.c:91: call6 = malloc(sizeof(char) * 6);
and that pointer is overwritten here:
wsprd/wsprsim_utils.c:122: call6 = strtok(pfx, " "); // FIXME-CHECK
so you can't free the memory allocated.
This would be easiest fix, but I only compile-tested it an cppcheck'ed:
diff --git a/wsprd/wsprsim_utils.c b/wsprd/wsprsim_utils.c index 41d2c40..d99c9d5 100644 --- a/wsprd/wsprsim_utils.c +++ b/wsprd/wsprsim_utils.c @@ -88,7 +88,9 @@ long unsigned int pack_call(char callsign) { void pack_prefix(char callsign, int32_t n, int32_t m, int32_t nadd) { int i; char call6;
@@ -147,6 +149,7 @@ void pack_prefix(char callsign, int32_t n, int32_t m, int32_t nadd) { *nadd = 1; } }
void interleave(unsigned char *sym) {
I didn't open a PR because I didn't understand why in pack_call() a "call6" is an array allocated on the stack and here in pack_prefix() it is allocated with malloc().
-- Daniele Forsi
should be fixed now, but I will rework a part of the backend with a more recent version of wsprd.
Running cppcheck *c in the rtlsdr-wsprd directory shows the following warnings and errors: