Private
Public Access
2
0

x86.c: sanitize data read from sysfs during board detection

Fixes #771.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Alex Tereschenko
2017-06-24 11:22:28 +02:00
committed by Brendan Le Foll
parent d544e3c2f6
commit 3f932ac952

View File

@@ -51,6 +51,9 @@ mraa_x86_platform()
FILE* fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
if (fh != NULL) {
if (getline(&line, &len, fh) != -1) {
// Sanitize input by terminating at any of possible end of line chars
line[strcspn(line, "\r\n")] = 0;
if (strncmp(line, "GalileoGen2", strlen("GalileoGen2") + 1) == 0 ||
strncmp(line, "SIMATIC IOT2000", strlen("SIMATIC IOT2000") + 1) == 0) {
platform_type = MRAA_INTEL_GALILEO_GEN2;