device has either PCI-X or PCI Express capability in its normal capability
list.
- * lib/dump.c (dump_init): Reading of dumps works again.
+ * lib/dump.c (dump_init): Reading of dumps works again. The dump reader
+ now also remembers how much data it has read and refuses attempts to
+ access more than that.
* setpci.man, lspci.c, README: prefer spelling "buses" over "busses".
/*
* The PCI Library -- Reading of Bus Dumps
*
- * Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ * Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "internal.h"
struct dump_data {
- int len;
+ int len, allocated;
byte data[1];
};
dump_alloc_data(struct pci_dev *dev, int len)
{
struct dump_data *dd = pci_malloc(dev->access, sizeof(struct dump_data) + len - 1);
- dd->len = len;
+ dd->allocated = len;
+ dd->len = 0;
memset(dd->data, 0xff, len);
dev->aux = dd;
}
a->error("dump: Malformed line");
if (i >= 4096)
break;
- if (i > dd->len) /* Need to re-allocate the buffer */
+ if (i > dd->allocated) /* Need to re-allocate the buffer */
{
dump_alloc_data(dev, 4096);
memcpy(((struct dump_data *) dev->aux)->data, dd->data, 256);
dd = dev->aux;
}
dd->data[i++] = j;
+ if (i > dd->len)
+ dd->len = i;
z += 2;
}
}