[zaptel-commits] jpeeler: branch 1.4 r3846 - in /branches/1.4: ./ kernel/ kernel/hpec/ kernel/...
SVN commits to the Zaptel project
zaptel-commits at lists.digium.com
Mon Feb 18 11:32:27 CST 2008
Author: jpeeler
Date: Mon Feb 18 11:32:26 2008
New Revision: 3846
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3846
Log:
Fixes bug 11471. Replaced instances of strncpy with zap_copy_string (added to zaptel.h) to fix any off by one errors and ensure destination string is NULL terminated.
Modified:
branches/1.4/fxotune.c
branches/1.4/kernel/hpec/hpec_zaptel.h
branches/1.4/kernel/jpah.h
branches/1.4/kernel/kb1ec.h
branches/1.4/kernel/mg2ec.h
branches/1.4/kernel/sec-2.h
branches/1.4/kernel/sec.h
branches/1.4/kernel/tor2.c
branches/1.4/kernel/torisa.c
branches/1.4/kernel/wcfxo.c
branches/1.4/kernel/wct1xxp.c
branches/1.4/kernel/wct4xxp/base.c
branches/1.4/kernel/wct4xxp/wct4xxp-diag.c
branches/1.4/kernel/wctdm.c
branches/1.4/kernel/wctdm24xxp/base.c
branches/1.4/kernel/wcte11xp.c
branches/1.4/kernel/wcte12xp/base.c
branches/1.4/kernel/wcusb.c
branches/1.4/kernel/zaptel-base.c
branches/1.4/kernel/zaptel.h
branches/1.4/kernel/ztd-eth.c
branches/1.4/kernel/ztdummy.c
branches/1.4/kernel/ztdynamic.c
branches/1.4/kernel/zttranscode.c
branches/1.4/ppp/zaptel.c
branches/1.4/sethdlc-new.c
branches/1.4/sethdlc.c
branches/1.4/tonezone.c
branches/1.4/ztcfg-dude.c
branches/1.4/ztcfg.c
branches/1.4/ztmonitor.c
Modified: branches/1.4/fxotune.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/fxotune.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/fxotune.c (original)
+++ branches/1.4/fxotune.c Mon Feb 18 11:32:26 2008
@@ -167,7 +167,8 @@
memset(&dop, 0, sizeof(dop));
dop.op = ZT_DIAL_OP_REPLACE;
dop.dialstr[0] = 'T';
- strncpy(dop.dialstr + 1, info->dialstr, sizeof(dop.dialstr) - 1);
+ zap_copy_string(dop.dialstr + 1, info->dialstr, sizeof(dop.dialstr));
+
if (ioctl(info->device, ZT_DIAL, &dop)) {
fprintf(stderr, "Unable to dial!\n");
Modified: branches/1.4/kernel/hpec/hpec_zaptel.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/hpec/hpec_zaptel.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/hpec/hpec_zaptel.h (original)
+++ branches/1.4/kernel/hpec/hpec_zaptel.h Mon Feb 18 11:32:26 2008
@@ -67,7 +67,7 @@
static void echo_can_identify(char *buf, size_t len)
{
- strncpy(buf, "HPEC", len);
+ zap_copy_string(buf, "HPEC", len);
}
static void echo_can_shutdown(void)
Modified: branches/1.4/kernel/jpah.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/jpah.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/jpah.h (original)
+++ branches/1.4/kernel/jpah.h Mon Feb 18 11:32:26 2008
@@ -49,7 +49,7 @@
static void echo_can_identify(char *buf, size_t len)
{
- strncpy(buf, "JP1", len);
+ zap_copy_string(buf, "JP1", len);
}
static void echo_can_shutdown(void)
Modified: branches/1.4/kernel/kb1ec.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/kb1ec.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/kb1ec.h (original)
+++ branches/1.4/kernel/kb1ec.h Mon Feb 18 11:32:26 2008
@@ -140,7 +140,7 @@
static void echo_can_identify(char *buf, size_t len)
{
- strncpy(buf, "KB1", len);
+ zap_copy_string(buf, "KB1", len);
}
static void echo_can_shutdown(void)
Modified: branches/1.4/kernel/mg2ec.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/mg2ec.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/mg2ec.h (original)
+++ branches/1.4/kernel/mg2ec.h Mon Feb 18 11:32:26 2008
@@ -166,7 +166,7 @@
static void echo_can_identify(char *buf, size_t len)
{
- strncpy(buf, "MG2", len);
+ zap_copy_string(buf, "MG2", len);
}
static void echo_can_shutdown(void)
Modified: branches/1.4/kernel/sec-2.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/sec-2.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/sec-2.h (original)
+++ branches/1.4/kernel/sec-2.h Mon Feb 18 11:32:26 2008
@@ -107,7 +107,7 @@
static void echo_can_identify(char *buf, size_t len)
{
- strncpy(buf, "STEVE2", len);
+ zap_copy_string(buf, "STEVE2", len);
}
static void echo_can_shutdown(void)
Modified: branches/1.4/kernel/sec.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/sec.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/sec.h (original)
+++ branches/1.4/kernel/sec.h Mon Feb 18 11:32:26 2008
@@ -107,7 +107,7 @@
static void echo_can_identify(char *buf, size_t len)
{
- strncpy(buf, "STEVE", len);
+ zap_copy_string(buf, "STEVE", len);
}
static void echo_can_shutdown(void)
Modified: branches/1.4/kernel/tor2.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/tor2.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/tor2.c (original)
+++ branches/1.4/kernel/tor2.c Mon Feb 18 11:32:26 2008
@@ -272,7 +272,7 @@
"Tormenta 2 (PCI) fQuad %s Card %d Span %d",
(tor->cardtype == TYPE_T1) ? "T1" : "E1", tor->num, x + 1);
tor->spans[x].manufacturer = "Digium";
- strncpy(tor->spans[x].devicetype, tor->type, sizeof(tor->spans[x].devicetype) - 1);
+ zap_copy_string(tor->spans[x].devicetype, tor->type, sizeof(tor->spans[x].devicetype));
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;
Modified: branches/1.4/kernel/torisa.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/torisa.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/torisa.c (original)
+++ branches/1.4/kernel/torisa.c Mon Feb 18 11:32:26 2008
@@ -1077,9 +1077,9 @@
}
strcpy(spans[0].name, "TorISA/1");
- strncpy(spans[0].desc, "ISA Tormenta Span 1", sizeof(spans[0].desc) - 1);
+ zap_copy_string(spans[0].desc, "ISA Tormenta Span 1", sizeof(spans[0].desc));
spans[0].manufacturer = "Digium";
- strncpy(spans[0].devicetype, "Tormenta ISA", sizeof(spans[0].devicetype) - 1);
+ zap_copy_string(spans[0].devicetype, "Tormenta ISA", sizeof(spans[0].devicetype));
spans[0].spanconfig = torisa_spanconfig;
spans[0].chanconfig = torisa_chanconfig;
spans[0].startup = torisa_startup;
Modified: branches/1.4/kernel/wcfxo.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wcfxo.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wcfxo.c (original)
+++ branches/1.4/kernel/wcfxo.c Mon Feb 18 11:32:26 2008
@@ -666,7 +666,7 @@
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";
- strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
+ zap_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
wc->chan.sigcap = ZT_SIG_FXSKS | ZT_SIG_FXSLS | ZT_SIG_SF;
wc->chan.chanpos = 1;
wc->span.chans = &wc->chan;
Modified: branches/1.4/kernel/wct1xxp.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wct1xxp.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wct1xxp.c (original)
+++ branches/1.4/kernel/wct1xxp.c Mon Feb 18 11:32:26 2008
@@ -762,7 +762,7 @@
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";
- strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
+ zap_copy_string(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.spanconfig = t1xxp_spanconfig;
Modified: branches/1.4/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wct4xxp/base.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wct4xxp/base.c (original)
+++ branches/1.4/kernel/wct4xxp/base.c Mon Feb 18 11:32:26 2008
@@ -1535,7 +1535,7 @@
snprintf(ts->span.desc, sizeof(ts->span.desc) - 1,
"T%dXXP (PCI) Card %d Span %d", wc->numspans, wc->num, x+1);
ts->span.manufacturer = "Digium";
- strncpy(ts->span.devicetype, wc->variety, sizeof(ts->span.devicetype) - 1);
+ zap_copy_string(ts->span.devicetype, wc->variety, sizeof(ts->span.devicetype));
if (wc->vpm == T4_VPM_PRESENT) {
if (!wc->vpm450m)
strncat(ts->span.devicetype, " with VPM400M", sizeof(ts->span.devicetype) - 1);
Modified: branches/1.4/kernel/wct4xxp/wct4xxp-diag.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wct4xxp/wct4xxp-diag.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wct4xxp/wct4xxp-diag.c (original)
+++ branches/1.4/kernel/wct4xxp/wct4xxp-diag.c Mon Feb 18 11:32:26 2008
@@ -378,7 +378,7 @@
exit(1);
}
if (*(argv[1]) == '/')
- strncpy(fn, argv[1], sizeof(fn) - 1);
+ zap_copy_string(fn, argv[1], sizeof(fn));
else
snprintf(fn, sizeof(fn), "/dev/zap/%d", atoi(argv[1]));
fd = open(fn, O_RDWR);
Modified: branches/1.4/kernel/wctdm.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wctdm.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wctdm.c (original)
+++ branches/1.4/kernel/wctdm.c Mon Feb 18 11:32:26 2008
@@ -2098,7 +2098,7 @@
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";
- strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
+ zap_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
if (alawoverride) {
printk("ALAW override parameter detected. Device will be operating in ALAW\n");
wc->span.deflaw = ZT_LAW_ALAW;
Modified: branches/1.4/kernel/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wctdm24xxp/base.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wctdm24xxp/base.c (original)
+++ branches/1.4/kernel/wctdm24xxp/base.c Mon Feb 18 11:32:26 2008
@@ -3137,7 +3137,7 @@
"PCI%s Bus %02d Slot %02d", (wc->flags[0] & FLAG_EXPRESS) ? " Express" : "",
wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1);
wc->span.manufacturer = "Digium";
- strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
+ zap_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
if (alawoverride) {
printk("ALAW override parameter detected. Device will be operating in ALAW\n");
wc->span.deflaw = ZT_LAW_ALAW;
Modified: branches/1.4/kernel/wcte11xp.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wcte11xp.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wcte11xp.c (original)
+++ branches/1.4/kernel/wcte11xp.c Mon Feb 18 11:32:26 2008
@@ -972,7 +972,7 @@
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";
- strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
+ zap_copy_string(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.spanconfig = t1xxp_spanconfig;
Modified: branches/1.4/kernel/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wcte12xp/base.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wcte12xp/base.c (original)
+++ branches/1.4/kernel/wcte12xp/base.c Mon Feb 18 11:32:26 2008
@@ -1357,7 +1357,7 @@
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";
- strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
+ zap_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype));
#if defined(VPM_SUPPORT)
if (wc->vpm150m)
Modified: branches/1.4/kernel/wcusb.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/wcusb.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/wcusb.c (original)
+++ branches/1.4/kernel/wcusb.c Mon Feb 18 11:32:26 2008
@@ -1251,7 +1251,7 @@
snprintf(p->span.desc, sizeof(p->span.desc) - 1, "%s %d", p->span.name, x);
sprintf(p->chan.name, "WCUSB/%d/%d", x, 0);
p->span.manufacturer = "Digium";
- strncpy(p->span.devicetype, p->variety, sizeof(p->span.devicetype) - 1);
+ zap_copy_string(p->span.devicetype, p->variety, sizeof(p->span.devicetype));
p->chan.sigcap = ZT_SIG_FXOKS | ZT_SIG_FXOLS | ZT_SIG_FXOGS; /* We're capabable of both FXOKS and FXOLS */
p->chan.chanpos = 1;
Modified: branches/1.4/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel-base.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/zaptel-base.c (original)
+++ branches/1.4/kernel/zaptel-base.c Mon Feb 18 11:32:26 2008
@@ -1269,7 +1269,7 @@
/* Set up the path of the file/link itself */
tmp_offset = devfs_generate_path(zaptel_devfs_dir, tmp, sizeof(tmp) - 1);
sprintf(buf, "/%d", chan->channo);
- strncpy(path, tmp+tmp_offset, sizeof(path) - 1);
+ zap_copy_string(path, tmp+tmp_offset, sizeof(path));
strncat(path, buf, sizeof(path) - 1);
err = devfs_mk_symlink(NULL, path, DEVFS_FL_DEFAULT, link+link_offset, &chan->fhandle_symlink, NULL);
@@ -2638,7 +2638,7 @@
ptr += sizeof(*z);
space -= sizeof(*z);
- strncpy(z->name, th.name, sizeof(z->name) - 1);
+ zap_copy_string(z->name, th.name, sizeof(z->name));
for (x = 0; x < ZT_MAX_CADENCE; x++)
z->ringcadence[x] = th.ringcadence[x];
@@ -3101,7 +3101,7 @@
stack.param.pulseaftertime = chan->pulseaftertime;
if (chan->span) stack.param.spanno = chan->span->spanno;
else stack.param.spanno = 0;
- strncpy(stack.param.name, chan->name, sizeof(stack.param.name) - 1);
+ zap_copy_string(stack.param.name, chan->name, sizeof(stack.param.name));
stack.param.chanpos = chan->chanpos;
stack.param.sigcap = chan->sigcap;
/* Return current law */
@@ -3236,8 +3236,8 @@
stack.spaninfo.spanno = i; /* put the span # in here */
stack.spaninfo.totalspans = 0;
if (maxspans) stack.spaninfo.totalspans = maxspans - 1; /* put total number of spans here */
- strncpy(stack.spaninfo.desc, spans[i]->desc, sizeof(stack.spaninfo.desc) - 1);
- strncpy(stack.spaninfo.name, spans[i]->name, sizeof(stack.spaninfo.name) - 1);
+ zap_copy_string(stack.spaninfo.desc, spans[i]->desc, sizeof(stack.spaninfo.desc));
+ zap_copy_string(stack.spaninfo.name, spans[i]->name, sizeof(stack.spaninfo.name));
stack.spaninfo.alarms = spans[i]->alarms; /* get alarm status */
stack.spaninfo.bpvcount = spans[i]->bpvcount; /* get BPV count */
stack.spaninfo.rxlevel = spans[i]->rxlevel; /* get rx level */
@@ -3259,15 +3259,15 @@
/* version 3 fields */
stack.spaninfo.irq = spans[i]->irq;
stack.spaninfo.linecompat = spans[i]->linecompat;
- strncpy(stack.spaninfo.lboname, zt_lboname(spans[i]->lbo), sizeof(stack.spaninfo.lboname) - 1);
+ zap_copy_string(stack.spaninfo.lboname, zt_lboname(spans[i]->lbo), sizeof(stack.spaninfo.lboname));
if (spans[i]->manufacturer)
- strncpy(stack.spaninfo.manufacturer, spans[i]->manufacturer,
- sizeof(stack.spaninfo.manufacturer) - 1);
+ zap_copy_string(stack.spaninfo.manufacturer, spans[i]->manufacturer,
+ sizeof(stack.spaninfo.manufacturer));
if (spans[i]->devicetype)
- strncpy(stack.spaninfo.devicetype, spans[i]->devicetype, sizeof(stack.spaninfo.devicetype) - 1);
- strncpy(stack.spaninfo.location, spans[i]->location, sizeof(stack.spaninfo.location) - 1);
+ zap_copy_string(stack.spaninfo.devicetype, spans[i]->devicetype, sizeof(stack.spaninfo.devicetype));
+ zap_copy_string(stack.spaninfo.location, spans[i]->location, sizeof(stack.spaninfo.location));
if (spans[i]->spantype)
- strncpy(stack.spaninfo.spantype, spans[i]->spantype, sizeof(stack.spaninfo.spantype) - 1);
+ zap_copy_string(stack.spaninfo.spantype, spans[i]->spantype, sizeof(stack.spaninfo.spantype));
if (copy_to_user((struct zt_spaninfo *) data, &stack.spaninfo, size_to_copy))
return -EFAULT;
@@ -3722,7 +3722,7 @@
break;
case ZT_GETVERSION:
memset(&vi, 0, sizeof(vi));
- strncpy(vi.version, ZAPTEL_VERSION, sizeof(vi.version) - 1);
+ zap_copy_string(vi.version, ZAPTEL_VERSION, sizeof(vi.version));
echo_can_identify(vi.echo_canceller, sizeof(vi.echo_canceller) - 1);
if (copy_to_user((struct zt_versioninfo *) data, &vi, sizeof(vi)))
return -EFAULT;
@@ -3840,7 +3840,7 @@
rv = -EBUSY;
break;
}
- strncpy(chan->txdialbuf + strlen(chan->txdialbuf), stack.tdo.dialstr, ZT_MAX_DTMF_BUF - strlen(chan->txdialbuf) - 1);
+ zap_copy_string(chan->txdialbuf + strlen(chan->txdialbuf), stack.tdo.dialstr, ZT_MAX_DTMF_BUF - strlen(chan->txdialbuf));
if (!chan->dialing) {
chan->dialing = 1;
__do_dtmf(chan);
Modified: branches/1.4/kernel/zaptel.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel.h?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/zaptel.h (original)
+++ branches/1.4/kernel/zaptel.h Mon Feb 18 11:32:26 2008
@@ -2006,4 +2006,30 @@
/* Special torisa ioctl */
#define TORISA_GETDEBUG _IOW (ZT_CODE, 60, struct torisa_debug)
+/*!
+ \brief Size-limited null-terminating string copy.
+ \param dst The destination buffer
+ \param src The source string
+ \param size The size of the destination buffer
+ \return Nothing.
+
+ This is similar to \a strncpy, with two important differences:
+ - the destination buffer will \b always be null-terminated
+ - the destination buffer is not filled with zeros past the copied string length
+ These differences make it slightly more efficient, and safer to use since it will
+ not leave the destination buffer unterminated. There is no need to pass an artificially
+ reduced buffer size to this function (unlike \a strncpy), and the buffer does not need
+ to be initialized to zeroes prior to calling this function.
+*/
+static inline void zap_copy_string(char *dst, const char *src, unsigned int size)
+{
+ while (*src && size) {
+ *dst++ = *src++;
+ size--;
+ }
+ if (__builtin_expect(!size, 0))
+ dst--;
+ *dst = '\0';
+}
+
#endif /* _LINUX_ZAPTEL_H */
Modified: branches/1.4/kernel/ztd-eth.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/ztd-eth.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/ztd-eth.c (original)
+++ branches/1.4/kernel/ztd-eth.c Mon Feb 18 11:32:26 2008
@@ -316,12 +316,12 @@
memset(z, 0, sizeof(struct ztdeth));
/* Address should be <dev>/<macaddr>[/subaddr] */
- strncpy(tmp, addr, sizeof(tmp) - 1);
+ zap_copy_string(tmp, addr, sizeof(tmp));
tmp2 = strchr(tmp, '/');
if (tmp2) {
*tmp2 = '\0';
tmp2++;
- strncpy(z->ethdev, tmp, sizeof(z->ethdev) - 1);
+ zap_copy_string(z->ethdev, tmp, sizeof(z->ethdev));
} else {
printk("Invalid TDMoE address (no device) '%s'\n", addr);
kfree(z);
Modified: branches/1.4/kernel/ztdummy.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/ztdummy.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/ztdummy.c (original)
+++ branches/1.4/kernel/ztdummy.c Mon Feb 18 11:32:26 2008
@@ -262,7 +262,7 @@
sprintf(ztd->span.name, "ZTDUMMY/1");
snprintf(ztd->span.desc, sizeof(ztd->span.desc) - 1, "%s (source: " CLOCK_SRC ") %d", ztd->span.name, 1);
sprintf(ztd->chan.name, "ZTDUMMY/%d/%d", 1, 0);
- strncpy(ztd->span.devicetype, "Zaptel Dummy Timing Driver", sizeof(ztd->span.devicetype) - 1);
+ zap_copy_string(ztd->span.devicetype, "Zaptel Dummy Timing Driver", sizeof(ztd->span.devicetype));
ztd->chan.chanpos = 1;
ztd->span.chans = &ztd->chan;
ztd->span.channels = 0; /* no channels on our span */
Modified: branches/1.4/kernel/ztdynamic.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/ztdynamic.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/ztdynamic.c (original)
+++ branches/1.4/kernel/ztdynamic.c Mon Feb 18 11:32:26 2008
@@ -611,8 +611,8 @@
memset(z->msgbuf, 0, bufsize);
/* Setup parameters properly assuming we're going to be okay. */
- strncpy(z->dname, zds->driver, sizeof(z->dname) - 1);
- strncpy(z->addr, zds->addr, sizeof(z->addr) - 1);
+ zap_copy_string(z->dname, zds->driver, sizeof(z->dname));
+ zap_copy_string(z->addr, zds->addr, sizeof(z->addr));
z->timing = zds->timing;
sprintf(z->span.name, "ZTD/%s/%s", zds->driver, zds->addr);
sprintf(z->span.desc, "Dynamic '%s' span at '%s'", zds->driver, zds->addr);
Modified: branches/1.4/kernel/zttranscode.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zttranscode.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/kernel/zttranscode.c (original)
+++ branches/1.4/kernel/zttranscode.c Mon Feb 18 11:32:26 2008
@@ -314,7 +314,7 @@
if (!tc)
return -ENOSYS;
- strncpy(info.name, tc->name, sizeof(info.name) - 1);
+ zap_copy_string(info.name, tc->name, sizeof(info.name));
info.numchannels = tc->numchannels;
info.srcfmts = tc->srcfmts;
info.dstfmts = tc->dstfmts;
Modified: branches/1.4/ppp/zaptel.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/ppp/zaptel.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/ppp/zaptel.c (original)
+++ branches/1.4/ppp/zaptel.c Mon Feb 18 11:32:26 2008
@@ -223,7 +223,7 @@
}
}
- strncpy(devnam, cp, sizeof(devnam) - 1);
+ zap_copy_string(devnam, cp, sizeof(devnam));
info("Using zaptel device '%s'\n", devnam);
Modified: branches/1.4/sethdlc-new.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/sethdlc-new.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/sethdlc-new.c (original)
+++ branches/1.4/sethdlc-new.c Mon Feb 18 11:32:26 2008
@@ -673,7 +673,7 @@
if (sock < 0)
error("Unable to create socket: %s\n", strerror(errno));
- strncpy(req.ifr_name, argv[1], sizeof(req.ifr_name) - 1); /* Device name */
+ zap_copy_string(req.ifr_name, argv[1], sizeof(req.ifr_name)); /* Device name */
if (argc == 2)
show_port();
Modified: branches/1.4/sethdlc.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/sethdlc.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/sethdlc.c (original)
+++ branches/1.4/sethdlc.c Mon Feb 18 11:32:26 2008
@@ -293,7 +293,7 @@
if (sock<0)
error("Unable to create socket: %s\n", strerror(errno));
- strncpy(req.ifr_name, argv[1], sizeof(req.ifr_name) - 1); /* Device name */
+ zap_copy_string(req.ifr_name, argv[1], sizeof(req.ifr_name)); /* Device name */
if (argc == 2) {
show_port(sock);
Modified: branches/1.4/tonezone.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/tonezone.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/tonezone.c (original)
+++ branches/1.4/tonezone.c Mon Feb 18 11:32:26 2008
@@ -323,7 +323,7 @@
space -= sizeof(*h);
h->zone = z->zone;
- strncpy(h->name, z->description, sizeof(h->name) - 1);
+ zap_copy_string(h->name, z->description, sizeof(h->name));
for (x = 0; x < ZT_MAX_CADENCE; x++)
h->ringcadence[x] = z->ringcadence[x];
Modified: branches/1.4/ztcfg-dude.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/ztcfg-dude.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/ztcfg-dude.c (original)
+++ branches/1.4/ztcfg-dude.c Mon Feb 18 11:32:26 2008
@@ -187,8 +187,8 @@
}
- strncpy(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver));
- strncpy(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr));
+ zap_copy_string(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver));
+ zap_copy_string(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr));
zds[numdynamic].numchans = chans;
zds[numdynamic].timing = timing;
@@ -296,7 +296,7 @@
for (x=0;x<res;x++) {
if (strchr(args[x], '-')) {
/* It's a range */
- strncpy(argcopy, args[x], sizeof(argcopy));
+ zap_copy_string(argcopy, args[x], sizeof(argcopy));
res2 = parseargs(argcopy, range, 2, '-');
if (res2 != 2) {
error("Syntax error in range '%s'. Should be <val1>-<val2>.\n", args[x]);
@@ -571,7 +571,7 @@
error("Too many tone zones specified\n");
return 0;
}
- strncpy(zonestoload[numzones++], args, sizeof(zonestoload[0]));
+ zap_copy_string(zonestoload[numzones++], args, sizeof(zonestoload[0]));
return 0;
}
Modified: branches/1.4/ztcfg.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/ztcfg.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/ztcfg.c (original)
+++ branches/1.4/ztcfg.c Mon Feb 18 11:32:26 2008
@@ -268,8 +268,8 @@
}
- strncpy(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver));
- strncpy(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr));
+ zap_copy_string(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver));
+ zap_copy_string(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr));
zds[numdynamic].numchans = chans;
zds[numdynamic].timing = timing;
@@ -377,7 +377,7 @@
for (x=0;x<res;x++) {
if (strchr(args[x], '-')) {
/* It's a range */
- strncpy(argcopy, args[x], sizeof(argcopy));
+ zap_copy_string(argcopy, args[x], sizeof(argcopy));
res2 = parseargs(argcopy, range, 2, '-');
if (res2 != 2) {
error("Syntax error in range '%s'. Should be <val1>-<val2>.\n", args[x]);
@@ -571,7 +571,7 @@
} else {
cc[x].sigtype = ZT_SIG_HDLCNET;
if (idle) {
- strncpy(cc[x].netdev_name, idle, sizeof(cc[x].netdev_name) - 1);
+ zap_copy_string(cc[x].netdev_name, idle, sizeof(cc[x].netdev_name));
}
master = x;
}
@@ -631,7 +631,7 @@
error("Too many tone zones specified\n");
return 0;
}
- strncpy(zonestoload[numzones++], args, sizeof(zonestoload[0]));
+ zap_copy_string(zonestoload[numzones++], args, sizeof(zonestoload[0]));
return 0;
}
@@ -967,7 +967,7 @@
for (x=0;x<res;x++) {
if (strchr(args[x], '-')) {
/* It's a range */
- strncpy(argcopy, args[x], sizeof(argcopy));
+ zap_copy_string(argcopy, args[x], sizeof(argcopy));
res2 = parseargs(argcopy, range, 2, '-');
if (res2 != 2) {
error("Syntax error in range '%s'. Should be <val1>-<val2>.\n", args[x]);
Modified: branches/1.4/ztmonitor.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/ztmonitor.c?view=diff&rev=3846&r1=3845&r2=3846
==============================================================================
--- branches/1.4/ztmonitor.c (original)
+++ branches/1.4/ztmonitor.c Mon Feb 18 11:32:26 2008
@@ -165,10 +165,10 @@
memset(bar+barlen+2, '>', 1);
memset(bar+barlen+3, '\0', 1);
- strncpy(bar+(barlen/2), "(RX)", 4);
+ zap_copy_string(bar+(barlen/2), "(RX)", 4);
printf("%s", bar);
- strncpy(bar+(barlen/2), "(TX)", 4);
+ zap_copy_string(bar+(barlen/2), "(TX)", 4);
printf(" %s\n", bar);
}
More information about the zaptel-commits
mailing list