From e7db0ed098bcc030042aba0667d09da67c130ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 18 Jan 2017 10:51:45 +0100 Subject: [PATCH] test_mixer & mixer: use memmove instead of memcpy Both, src & dst use the same array, thus potentially overlapping. Behavior of memcpy in that case is undefined. --- src/modules/px4iofirmware/mixer.cpp | 2 +- src/systemcmds/tests/test_mixer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/px4iofirmware/mixer.cpp b/src/modules/px4iofirmware/mixer.cpp index 2633205f0c..48514799b3 100644 --- a/src/modules/px4iofirmware/mixer.cpp +++ b/src/modules/px4iofirmware/mixer.cpp @@ -532,7 +532,7 @@ mixer_handle_text(const void *buffer, size_t length) /* copy any leftover text to the base of the buffer for re-use */ if (resid > 0) { - memcpy(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid); + memmove(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid); /* enforce null termination */ mixer_text[resid] = '\0'; } diff --git a/src/systemcmds/tests/test_mixer.cpp b/src/systemcmds/tests/test_mixer.cpp index 2c3faa5c6e..33b33b3475 100644 --- a/src/systemcmds/tests/test_mixer.cpp +++ b/src/systemcmds/tests/test_mixer.cpp @@ -334,7 +334,7 @@ bool MixerTest::load_mixer(const char *filename, const char *buf, unsigned loade /* copy any leftover text to the base of the buffer for re-use */ if (resid > 0) { - memcpy(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid); + memmove(&mixer_text[0], &mixer_text[mixer_text_length - resid], resid); /* enforce null termination */ mixer_text[resid] = '\0'; }