nput_events.c:171:19: error: '%s' directive output may be truncated
writing up to 255 bytes into a region of size 117 [-Werror=format-truncation=]
171 | "/dev/input/%s", d->d_name);
| ^~
input_events.c:170:5: note: 'snprintf' output between 12 and 267 bytes
into a destination of size 128
170 | snprintf(dev[count].fileName, MAX_FILENAME,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171 | "/dev/input/%s", d->d_name);
ui_viewer_data.c:303:3: error: 'strncpy' specified bound depends on the length
of the source argument [-Werror=stringop-overflow=]
303 | strncpy(to, str, len);
| ^~~~~~~~~~~~~~~~~~~~~
ui_viewer_data.c:302:16: note: length computed here
302 | size_t len = strlen(str) + 1;
| ^~~~~~~~~~~
Change-Id: Ib009b0d1fb99bfd70f9936546d388fd5b29e80f4
Signed-off-by: Mikhail Kashkarov <m.kashkarov@partner.samsung.com>
// start with "event"
// event file
if (!check_input(d->d_name, input_id)) {
- snprintf(dev[count].fileName, MAX_FILENAME,
- "/dev/input/%s", d->d_name);
+ if (snprintf(dev[count].fileName, MAX_FILENAME,
+ "/dev/input/%s",
+ d->d_name) >= MAX_FILENAME) {
+ LOGE("too long filename, truncated!");
+ break;
+ }
dev[count].fd = open(dev[count].fileName,
O_RDWR | O_NONBLOCK);
count++;
return to + 1;
} else {
size_t len = strlen(str) + 1;
- strncpy(to, str, len);
+ memcpy(to, str, len);
return to + len;
}
}