diff options
author | kpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-12-04 14:48:23 +0000 |
---|---|---|
committer | kpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-12-04 14:48:23 +0000 |
commit | 068d0fa47a1873bf0dd497a100c8659b2add728e (patch) | |
tree | da0740abcb22011024e7eaf344301ff202e5f666 /tor2.c | |
parent | 69d38492938f1a7c4d02a1dc63b9af5d6319e661 (diff) |
use a buffer for the span's device type instead of a string pointer, so each spans can have dynamically set device types instead of constant strings
also fix up some string creation and copying to be safe against buffer overflows
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@3281 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'tor2.c')
-rw-r--r-- | tor2.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -270,10 +270,13 @@ static void init_spans(struct tor2 *tor) int x, y, c; for (x = 0; x < SPANS_PER_CARD; x++) { sprintf(tor->spans[x].name, "Tor2/%d/%d", tor->num, x + 1); - sprintf(tor->spans[x].desc, "Tormenta 2 (PCI) Quad %s Card %d Span %d", (tor->cardtype == TYPE_T1) ? "T1" : "E1", tor->num, x + 1); + snprintf(tor->spans[x].desc, sizeof(tor->spans[x].desc) - 1, + "Tormenta 2 (PCI) fQuad %s Card %d Span %d", + (tor->cardtype == TYPE_T1) ? "T1" : "E1", tor->num, x + 1); tor->spans[x].manufacturer = "Digium"; - tor->spans[x].devicetype = tor->type; - sprintf(tor->spans[x].location, "PCI Bus %02d Slot %02d", tor->pci->bus->number, PCI_SLOT(tor->pci->devfn) + 1); + strncpy(tor->spans[x].devicetype, tor->type, sizeof(tor->spans[x].devicetype) - 1); + snprintf(tor->spans[x].location, sizeof(tor->spans[x].location) - 1, + "PCI Bus %02d Slot %02d", tor->pci->bus->number, PCI_SLOT(tor->pci->devfn) + 1); tor->spans[x].spanconfig = tor2_spanconfig; tor->spans[x].chanconfig = tor2_chanconfig; tor->spans[x].startup = tor2_startup; |