'dahdi_copy_string()' -> 'strlcpy()'
There is already a safe string copying function in all the kernels DAHDI currently supports. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Kinsey Moore <kmoore@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9585 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
25a8bb1abe
commit
2f3b2a4f62
@ -3038,7 +3038,7 @@ static int ioctl_load_zone(unsigned long data)
|
||||
ptr = (char *) ptr + sizeof(*z);
|
||||
space -= sizeof(*z);
|
||||
|
||||
dahdi_copy_string(z->name, work->th.name, sizeof(z->name));
|
||||
strlcpy(z->name, work->th.name, sizeof(z->name));
|
||||
|
||||
for (x = 0; x < DAHDI_MAX_CADENCE; x++)
|
||||
z->ringcadence[x] = work->th.ringcadence[x];
|
||||
@ -3855,7 +3855,7 @@ static int dahdi_ioctl_getparams(struct file *file, unsigned long data)
|
||||
param.pulsebreaktime = chan->pulsebreaktime;
|
||||
param.pulseaftertime = chan->pulseaftertime;
|
||||
param.spanno = (chan->span) ? chan->span->spanno : 0;
|
||||
dahdi_copy_string(param.name, chan->name, sizeof(param.name));
|
||||
strlcpy(param.name, chan->name, sizeof(param.name));
|
||||
param.chanpos = chan->chanpos;
|
||||
param.sigcap = chan->sigcap;
|
||||
/* Return current law */
|
||||
@ -3943,8 +3943,8 @@ static int dahdi_ioctl_spanstat(struct file *file, unsigned long data)
|
||||
|
||||
spaninfo.spanno = s->spanno; /* put the span # in here */
|
||||
spaninfo.totalspans = span_count();
|
||||
dahdi_copy_string(spaninfo.desc, s->desc, sizeof(spaninfo.desc));
|
||||
dahdi_copy_string(spaninfo.name, s->name, sizeof(spaninfo.name));
|
||||
strlcpy(spaninfo.desc, s->desc, sizeof(spaninfo.desc));
|
||||
strlcpy(spaninfo.name, s->name, sizeof(spaninfo.name));
|
||||
spaninfo.alarms = s->alarms; /* get alarm status */
|
||||
spaninfo.rxlevel = s->rxlevel; /* get rx level */
|
||||
spaninfo.txlevel = s->txlevel; /* get tx level */
|
||||
@ -3971,20 +3971,20 @@ static int dahdi_ioctl_spanstat(struct file *file, unsigned long data)
|
||||
spaninfo.lineconfig = s->lineconfig;
|
||||
spaninfo.irq = s->irq;
|
||||
spaninfo.linecompat = s->linecompat;
|
||||
dahdi_copy_string(spaninfo.lboname, dahdi_lboname(s->lbo),
|
||||
strlcpy(spaninfo.lboname, dahdi_lboname(s->lbo),
|
||||
sizeof(spaninfo.lboname));
|
||||
if (s->manufacturer) {
|
||||
dahdi_copy_string(spaninfo.manufacturer, s->manufacturer,
|
||||
strlcpy(spaninfo.manufacturer, s->manufacturer,
|
||||
sizeof(spaninfo.manufacturer));
|
||||
}
|
||||
if (s->devicetype) {
|
||||
dahdi_copy_string(spaninfo.devicetype, s->devicetype,
|
||||
strlcpy(spaninfo.devicetype, s->devicetype,
|
||||
sizeof(spaninfo.devicetype));
|
||||
}
|
||||
dahdi_copy_string(spaninfo.location, s->location,
|
||||
strlcpy(spaninfo.location, s->location,
|
||||
sizeof(spaninfo.location));
|
||||
if (s->spantype) {
|
||||
dahdi_copy_string(spaninfo.spantype, s->spantype,
|
||||
strlcpy(spaninfo.spantype, s->spantype,
|
||||
sizeof(spaninfo.spantype));
|
||||
}
|
||||
|
||||
@ -4031,10 +4031,10 @@ static int dahdi_ioctl_spanstat_v1(struct file *file, unsigned long data)
|
||||
spaninfo_v1.spanno = s->spanno; /* put the span # in here */
|
||||
spaninfo_v1.totalspans = 0;
|
||||
spaninfo_v1.totalspans = span_count();
|
||||
dahdi_copy_string(spaninfo_v1.desc,
|
||||
strlcpy(spaninfo_v1.desc,
|
||||
s->desc,
|
||||
sizeof(spaninfo_v1.desc));
|
||||
dahdi_copy_string(spaninfo_v1.name,
|
||||
strlcpy(spaninfo_v1.name,
|
||||
s->name,
|
||||
sizeof(spaninfo_v1.name));
|
||||
spaninfo_v1.alarms = s->alarms;
|
||||
@ -4056,28 +4056,28 @@ static int dahdi_ioctl_spanstat_v1(struct file *file, unsigned long data)
|
||||
spaninfo_v1.lineconfig = s->lineconfig;
|
||||
spaninfo_v1.irq = s->irq;
|
||||
spaninfo_v1.linecompat = s->linecompat;
|
||||
dahdi_copy_string(spaninfo_v1.lboname,
|
||||
strlcpy(spaninfo_v1.lboname,
|
||||
dahdi_lboname(s->lbo),
|
||||
sizeof(spaninfo_v1.lboname));
|
||||
|
||||
if (s->manufacturer) {
|
||||
dahdi_copy_string(spaninfo_v1.manufacturer,
|
||||
strlcpy(spaninfo_v1.manufacturer,
|
||||
s->manufacturer,
|
||||
sizeof(spaninfo_v1.manufacturer));
|
||||
}
|
||||
|
||||
if (s->devicetype) {
|
||||
dahdi_copy_string(spaninfo_v1.devicetype,
|
||||
strlcpy(spaninfo_v1.devicetype,
|
||||
s->devicetype,
|
||||
sizeof(spaninfo_v1.devicetype));
|
||||
}
|
||||
|
||||
dahdi_copy_string(spaninfo_v1.location,
|
||||
strlcpy(spaninfo_v1.location,
|
||||
s->location,
|
||||
sizeof(spaninfo_v1.location));
|
||||
|
||||
if (s->spantype) {
|
||||
dahdi_copy_string(spaninfo_v1.spantype,
|
||||
strlcpy(spaninfo_v1.spantype,
|
||||
s->spantype,
|
||||
sizeof(spaninfo_v1.spantype));
|
||||
}
|
||||
@ -4644,7 +4644,7 @@ static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long da
|
||||
size_t space = sizeof(vi.echo_canceller) - 1;
|
||||
|
||||
memset(&vi, 0, sizeof(vi));
|
||||
dahdi_copy_string(vi.version, DAHDI_VERSION, sizeof(vi.version));
|
||||
strlcpy(vi.version, DAHDI_VERSION, sizeof(vi.version));
|
||||
read_lock(&ecfactory_list_lock);
|
||||
list_for_each_entry(cur, &ecfactory_list, list) {
|
||||
strncat(vi.echo_canceller + strlen(vi.echo_canceller),
|
||||
@ -4818,7 +4818,8 @@ static int ioctl_dahdi_dial(struct dahdi_chan *chan, unsigned long data)
|
||||
rv = -EBUSY;
|
||||
break;
|
||||
}
|
||||
dahdi_copy_string(chan->txdialbuf + strlen(chan->txdialbuf), tdo->dialstr, DAHDI_MAX_DTMF_BUF - strlen(chan->txdialbuf));
|
||||
strlcpy(chan->txdialbuf + strlen(chan->txdialbuf), tdo->dialstr,
|
||||
DAHDI_MAX_DTMF_BUF - strlen(chan->txdialbuf));
|
||||
if (!chan->dialing) {
|
||||
chan->dialing = 1;
|
||||
__do_dtmf(chan);
|
||||
|
@ -210,7 +210,8 @@ static int dahdi_dummy_initialize(struct dahdi_dummy *ztd)
|
||||
sprintf(ztd->span.name, "DAHDI_DUMMY/1");
|
||||
snprintf(ztd->span.desc, sizeof(ztd->span.desc) - 1, "%s (source: " CLOCK_SRC ") %d", ztd->span.name, 1);
|
||||
sprintf(ztd->chan->name, "DAHDI_DUMMY/%d/%d", 1, 0);
|
||||
dahdi_copy_string(ztd->span.devicetype, "DAHDI Dummy Timing", sizeof(ztd->span.devicetype));
|
||||
strlcpy(ztd->span.devicetype, "DAHDI Dummy Timing",
|
||||
sizeof(ztd->span.devicetype));
|
||||
ztd->chan->chanpos = 1;
|
||||
ztd->span.chans = &ztd->chan;
|
||||
ztd->span.channels = 0; /* no channels on our span */
|
||||
|
@ -604,8 +604,8 @@ static int _create_dynamic(struct dahdi_dynamic_span *dds)
|
||||
}
|
||||
|
||||
/* Setup parameters properly assuming we're going to be okay. */
|
||||
dahdi_copy_string(d->dname, dds->driver, sizeof(d->dname));
|
||||
dahdi_copy_string(d->addr, dds->addr, sizeof(d->addr));
|
||||
strlcpy(d->dname, dds->driver, sizeof(d->dname));
|
||||
strlcpy(d->addr, dds->addr, sizeof(d->addr));
|
||||
d->timing = dds->timing;
|
||||
sprintf(d->span.name, "DYN/%s/%s", dds->driver, dds->addr);
|
||||
sprintf(d->span.desc, "Dynamic '%s' span at '%s'",
|
||||
|
@ -306,12 +306,12 @@ static int ztdeth_create(struct dahdi_dynamic *dyn, const char *addr)
|
||||
memset(z, 0, sizeof(struct ztdeth));
|
||||
|
||||
/* Address should be <dev>/<macaddr>[/subaddr] */
|
||||
dahdi_copy_string(tmp, addr, sizeof(tmp));
|
||||
strlcpy(tmp, addr, sizeof(tmp));
|
||||
tmp2 = strchr(tmp, '/');
|
||||
if (tmp2) {
|
||||
*tmp2 = '\0';
|
||||
tmp2++;
|
||||
dahdi_copy_string(z->ethdev, tmp, sizeof(z->ethdev));
|
||||
strlcpy(z->ethdev, tmp, sizeof(z->ethdev));
|
||||
} else {
|
||||
printk(KERN_NOTICE "Invalid TDMoE address (no device) '%s'\n", addr);
|
||||
kfree(z);
|
||||
|
@ -609,7 +609,7 @@ static int ztdethmf_create(struct dahdi_dynamic *dyn, const char *addr)
|
||||
z->rcvbuf = kmalloc(bufsize, GFP_KERNEL);
|
||||
|
||||
/* Address should be <dev>/<macaddr>/subaddr */
|
||||
dahdi_copy_string(src, addr, sizeof(src));
|
||||
strlcpy(src, addr, sizeof(src));
|
||||
/* replace all / with space; otherwise kernel sscanf does not work */
|
||||
src_ptr = src;
|
||||
while (*src_ptr) {
|
||||
|
@ -328,7 +328,7 @@ static long dahdi_tc_getinfo(unsigned long data)
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
dahdi_copy_string(info.name, tc->name, sizeof(info.name));
|
||||
strlcpy(info.name, tc->name, sizeof(info.name));
|
||||
info.numchannels = tc->numchannels;
|
||||
info.srcfmts = tc->srcfmts;
|
||||
info.dstfmts = tc->dstfmts;
|
||||
|
@ -284,7 +284,7 @@ static void init_spans(struct tor2 *tor)
|
||||
"Tormenta 2 (PCI) Quad %s Card %d Span %d",
|
||||
(tor->cardtype == TYPE_T1) ? "T1" : "E1", tor->num, x + 1);
|
||||
s->manufacturer = "Digium";
|
||||
dahdi_copy_string(s->devicetype, tor->type, sizeof(s->devicetype));
|
||||
strlcpy(s->devicetype, tor->type, sizeof(s->devicetype));
|
||||
snprintf(s->location, sizeof(s->location) - 1,
|
||||
"PCI Bus %02d Slot %02d", tor->pci->bus->number, PCI_SLOT(tor->pci->devfn) + 1);
|
||||
if (tor->cardtype == TYPE_T1) {
|
||||
|
@ -2492,7 +2492,8 @@ static void init_spans(struct b4xxp *b4)
|
||||
sprintf(bspan->span.name, "B4/%d/%d", b4->cardno, i+1);
|
||||
sprintf(bspan->span.desc, "B4XXP (PCI) Card %d Span %d", b4->cardno, i+1);
|
||||
bspan->span.manufacturer = "Digium";
|
||||
dahdi_copy_string(bspan->span.devicetype, b4->variety, sizeof(bspan->span.devicetype));
|
||||
strlcpy(bspan->span.devicetype, b4->variety,
|
||||
sizeof(bspan->span.devicetype));
|
||||
sprintf(bspan->span.location, "PCI Bus %02d Slot %02d",
|
||||
b4->pdev->bus->number, PCI_SLOT(b4->pdev->devfn) + 1);
|
||||
|
||||
|
@ -654,7 +654,7 @@ static int wcfxo_initialize(struct wcfxo *wc)
|
||||
snprintf(wc->span.location, sizeof(wc->span.location) - 1,
|
||||
"PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1);
|
||||
wc->span.manufacturer = "Digium";
|
||||
dahdi_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
strlcpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
wc->chan->sigcap = DAHDI_SIG_FXSKS | DAHDI_SIG_FXSLS | DAHDI_SIG_SF;
|
||||
wc->chan->chanpos = 1;
|
||||
wc->span.chans = &wc->chan;
|
||||
|
@ -771,7 +771,7 @@ static int t1xxp_software_init(struct t1xxp *wc)
|
||||
sprintf(wc->span.name, "WCT1/%d", wc->num);
|
||||
snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Card %d", wc->variety, wc->num);
|
||||
wc->span.manufacturer = "Digium";
|
||||
dahdi_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
strlcpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
snprintf(wc->span.location, sizeof(wc->span.location) - 1,
|
||||
"PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1);
|
||||
wc->span.irq = wc->dev->irq;
|
||||
|
@ -2016,7 +2016,8 @@ static void set_span_devicetype(struct t4 *wc)
|
||||
|
||||
for (x = 0; x < wc->numspans; x++) {
|
||||
ts = wc->tspans[x];
|
||||
dahdi_copy_string(ts->span.devicetype, wc->variety, sizeof(ts->span.devicetype));
|
||||
strlcpy(ts->span.devicetype, wc->variety,
|
||||
sizeof(ts->span.devicetype));
|
||||
if (wc->vpm == T4_VPM_PRESENT) {
|
||||
if (!wc->vpm450m)
|
||||
strncat(ts->span.devicetype, " (VPM400M)", sizeof(ts->span.devicetype) - 1);
|
||||
|
@ -2370,7 +2370,7 @@ static int wctdm_initialize(struct wctdm *wc)
|
||||
snprintf(wc->span.location, sizeof(wc->span.location) - 1,
|
||||
"PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1);
|
||||
wc->span.manufacturer = "Digium";
|
||||
dahdi_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
strlcpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
if (alawoverride) {
|
||||
printk(KERN_INFO "ALAW override parameter detected. Device will be operating in ALAW\n");
|
||||
wc->span.deflaw = DAHDI_LAW_ALAW;
|
||||
|
@ -978,7 +978,7 @@ static int t1xxp_software_init(struct t1 *wc)
|
||||
sprintf(wc->span.name, "WCT1/%d", wc->num);
|
||||
snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Card %d", wc->variety, wc->num);
|
||||
wc->span.manufacturer = "Digium";
|
||||
dahdi_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
strlcpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
|
||||
snprintf(wc->span.location, sizeof(wc->span.location) - 1,
|
||||
"PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1);
|
||||
wc->span.irq = wc->dev->irq;
|
||||
|
Loading…
Reference in New Issue
Block a user