From 66226fb75417225c8fe7eb9226f81db8dcd59f82 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 3 Jan 2017 09:27:18 +0100 Subject: [PATCH] Land detector: Harden string handling Due to known input this was not a real issue, but bad style. --- src/modules/land_detector/land_detector_main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/land_detector/land_detector_main.cpp b/src/modules/land_detector/land_detector_main.cpp index ff8f6f5c72..65f901f655 100644 --- a/src/modules/land_detector/land_detector_main.cpp +++ b/src/modules/land_detector/land_detector_main.cpp @@ -159,8 +159,9 @@ static int land_detector_start(const char *mode) } } - //Remember current active mode - strncpy(_currentMode, mode, 12); + // Remember current active mode + strncpy(_currentMode, mode, sizeof(_currentMode) - 1); + _currentMode[sizeof(_currentMode) - 1] = '\0'; return 0; }