mirror of
https://github.com/vsergeev/c-periphery.git
synced 2026-08-20 21:28:32 +08:00
led: add null termination to name copy in led_open()
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user