diff --git a/daemon/governors-query.c b/daemon/governors-query.c index d357678..9e0af0f 100644 --- a/daemon/governors-query.c +++ b/daemon/governors-query.c @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "governors-query.h" #include "logging.h" +#include #include #include #include @@ -80,12 +81,13 @@ int fetch_governors(char governors[MAX_GOVERNORS][MAX_GOVERNOR_LENGTH]) /* Only add this governor if it is unique */ for (int j = 0; j < num_governors; j++) { - if (strncmp(fullpath, governors[i], MAX_GOVERNOR_LENGTH) == 0) { + if (strncmp(fullpath, governors[i], PATH_MAX) == 0) { continue; } } /* Copy this governor into the output set */ + static_assert(MAX_GOVERNOR_LENGTH > PATH_MAX, "possible string truncation"); strncpy(governors[num_governors], fullpath, MAX_GOVERNOR_LENGTH); num_governors++; }