E.g. on Edison they have LFs and that may cause problems
with downstream consumers of this data.
Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
if (fd > 0) {
len = read(fd, &name, 64);
if (len > 1) {
+ // remove any trailing CR/LF symbols
+ name[strcspn(name, "\r\n")] = '\0';
+ len = strlen(name);
// use strndup
device->name = malloc((sizeof(char) * len) + sizeof(char));
- strncpy(device->name, name, len);
+ strncpy(device->name, name, len+1);
}
close(fd);
}