logger: don't use uint8_t buffer[msg_size]; (it's C99 not C++)

Also, it's not clear where the allocation was. It looks like it was on
the heap, but the compiler could decide to put it on the stack. This is
very bad for us because we use fixed size stacks with tights bounds. So if
a user specifies a large topic to log, it could have crashed.

Now the allocation is on the heap and the user can specify any size of
topic to log (as long as there is enough memory).
This commit is contained in:
Beat Küng
2016-06-06 23:27:16 +02:00
committed by Lorenz Meier
parent 8ef493c82d
commit febe75bb12
2 changed files with 40 additions and 17 deletions
+2
View File
@@ -195,6 +195,8 @@ private:
static constexpr const char *LOG_ROOT = PX4_ROOTFSDIR"/fs/microsd/log";
#endif
uint8_t *_msg_buffer = nullptr;
int _msg_buffer_len = 0;
bool _task_should_exit = true;
char _log_dir[64];
bool _has_log_dir = false;