res = snprintf(buf, size, "%s", name);
else
res = snprintf(buf, size, "%s [%s]", name, num);
- if (res < 0 || res >= size)
+ if (res >= size && size >= 4)
+ buf[size-2] = buf[size-3] = buf[size-4] = '.';
+ else if (res < 0 || res >= size)
return "<pci_lookup_name: buffer too small>";
- else
- return buf;
+ return buf;
}
static char *
else /* v && !d */
res = snprintf(buf, size, "%s Device %s", v, num+5);
}
- if (res < 0 || res >= size)
+ if (res >= size && size >= 4)
+ buf[size-2] = buf[size-3] = buf[size-4] = '.';
+ else if (res < 0 || res >= size)
return "<pci_lookup_name: buffer too small>";
- else
- return buf;
+ return buf;
}
char *