From 890f4784c1483bbf9d4fbc83d9dd210b5b93d43e Mon Sep 17 00:00:00 2001 From: jpeeler Date: Fri, 15 Feb 2008 23:33:44 +0000 Subject: Fixes bug 11471. Replaced all 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. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3833 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel-base.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'zaptel-base.c') diff --git a/zaptel-base.c b/zaptel-base.c index 94843b9..1d44752 100644 --- a/zaptel-base.c +++ b/zaptel-base.c @@ -1212,7 +1212,7 @@ static devfs_handle_t register_devfs_channel(struct zt_chan *chan, devfs_handle_ /* 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); @@ -2514,7 +2514,7 @@ ioctl_load_zone(unsigned long data) memset(slab, 0, size); /* Grab the zone */ z = (struct zt_zone *)slab; - strncpy(z->name, th.name, sizeof(z->name) - 1); + zap_copy_string(z->name, th.name, sizeof(z->name)); for (x=0;xringcadence[x] = th.ringcadence[x]; data += sizeof(struct zt_tone_def_header); @@ -2928,7 +2928,7 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c 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; /* Return current law */ if (chan->xlaw == __zt_alaw) @@ -3037,8 +3037,8 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c stack.span.spanno = i; /* put the span # in here */ stack.span.totalspans = 0; if (maxspans) stack.span.totalspans = maxspans - 1; /* put total number of spans here */ - strncpy(stack.span.desc, spans[i]->desc, sizeof(stack.span.desc) - 1); - strncpy(stack.span.name, spans[i]->name, sizeof(stack.span.name) - 1); + zap_copy_string(stack.span.desc, spans[i]->desc, sizeof(stack.span.desc)); + zap_copy_string(stack.span.name, spans[i]->name, sizeof(stack.span.name)); stack.span.alarms = spans[i]->alarms; /* get alarm status */ stack.span.bpvcount = spans[i]->bpvcount; /* get BPV count */ stack.span.rxlevel = spans[i]->rxlevel; /* get rx level */ @@ -3577,7 +3577,7 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign rv = -EBUSY; break; } - strncpy(chan->txdialbuf + strlen(chan->txdialbuf), stack.tdo.dialstr, ZT_MAX_DTMF_BUF - strlen(chan->txdialbuf)); + zap_copy_string(chan->txdialbuf + strlen(chan->txdialbuf), stack.tdo.dialstr, ZT_MAX_DTMF_BUF - strlen(chan->txdialbuf)); if (!chan->dialing) { chan->dialing = 1; -- cgit v1.2.3