- snprintf(file_name, sizeof(file_name), "%s/devices/%04x:%02x:%02x.%d/config",
- pcie_config.access_dir, dev->domain, dev->bus, dev->device,
- dev->function);
+ int ret =
+ snprintf(file_name, sizeof(file_name),
+ "%s/devices/%04x:%02x:%02x.%d/config", pcie_config.access_dir,
+ dev->domain, dev->bus, dev->device, dev->function);
+ if (ret < 1 || (size_t)ret >= sizeof(file_name)) {
+ ERROR(PCIE_ERRORS_PLUGIN ": Access dir `%s' is too long (%d)",
+ pcie_config.access_dir, ret);
+ return -EINVAL;
+ }