Magellan Linux

Contents of /trunk/pciutils/patches/pciutils-2.2.4-buf.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue May 8 20:52:56 2007 UTC (17 years ago) by niro
File size: 1611 byte(s)
-import

1 --- pciutils-2.2.4/lib/names.c.buf 2006-09-09 12:46:39.000000000 +0200
2 +++ pciutils-2.2.4/lib/names.c 2007-01-26 13:47:01.000000000 +0100
3 @@ -372,12 +372,27 @@
4 res = snprintf(buf, size, "%s", num);
5 else if (!name)
6 res = snprintf(buf, size, ((flags & PCI_LOOKUP_MIXED) ? "%s [%s]" : "%s %s"), unknown, num);
7 - else if (!(flags & PCI_LOOKUP_MIXED))
8 + else if (!(flags & PCI_LOOKUP_MIXED))
9 res = snprintf(buf, size, "%s", name);
10 else
11 res = snprintf(buf, size, "%s [%s]", name, num);
12 - if (res < 0 || res >= size)
13 + if (res < 0 || res >= size) {
14 + if (name && res >= size) {
15 + int nlen = strlen(name);
16 + if (nlen > (res - size) + 5) {
17 + char *nname = strdup(name);
18 + int off = nlen - (res - size) - 5;
19 + if (nname) {
20 + nname[off] = '.';
21 + nname[off+1] = '.';
22 + nname[off+2] = '.';
23 + nname[off+3] = 0;
24 + return format_name(buf, size, flags, nname, num, unknown);
25 + }
26 + }
27 + }
28 return "<pci_lookup_name: buffer too small>";
29 + }
30 else
31 return buf;
32 }
33 @@ -408,8 +423,24 @@
34 else /* v && !d */
35 res = snprintf(buf, size, "%s Unknown device %s", v, num+5);
36 }
37 - if (res < 0 || res >= size)
38 + if (res < 0 || res >= size) {
39 + if (d && res >= size) {
40 + int nlen = strlen(d);
41 + if (nlen > (res - size) + 5) {
42 + char *nname = strdup(d);
43 + int off = nlen - (res - size) - 5;
44 + if (nname) {
45 + nname[off] = '.';
46 + nname[off+1] = '.';
47 + nname[off+2] = '.';
48 + nname[off+3] = 0;
49 + return format_name_pair(buf, size, flags, v, nname, num);
50 + }
51 + }
52 + }
53 +
54 return "<pci_lookup_name: buffer too small>";
55 + }
56 else
57 return buf;
58 }