led: add null termination to name copy in led_open()

This commit is contained in:
Vanya A. Sergeev
2020-11-19 23:27:05 -06:00
parent a22369528b
commit ca5c0f1fda
+2 -1
View File
@@ -67,7 +67,8 @@ int led_open(led_t *led, const char *name) {
close(fd);
strncpy(led->name, name, sizeof(led->name));
strncpy(led->name, name, sizeof(led->name) - 1);
led->name[sizeof(led->name) - 1] = '\0';
if ((ret = led_get_max_brightness(led, &led->max_brightness)) < 0)
return ret;