From 068d0fa47a1873bf0dd497a100c8659b2add728e Mon Sep 17 00:00:00 2001 From: kpfleming Date: Tue, 4 Dec 2007 14:48:23 +0000 Subject: 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 --- tor2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tor2.c') diff --git a/tor2.c b/tor2.c index e4874fb..e3350e6 100644 --- a/tor2.c +++ b/tor2.c @@ -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; -- cgit v1.2.3