aboutsummaryrefslogtreecommitdiffstats
path: root/enum.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-21 17:47:44 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-21 17:47:44 +0000
commit3cec63b876c1892f2d672f14d0da13e179f995e0 (patch)
tree5eb15904009fb328f1cb0fa5cda55860658ac417 /enum.c
parentff4e44ae7c0587742f68c3f43dcbfcd3302e9fca (diff)
replace strncpy with ast_copy_string and fix the -1 offset which
is not needed now. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@22015 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/enum.c b/enum.c
index 9304c2228..731f03a39 100644
--- a/enum.c
+++ b/enum.c
@@ -412,11 +412,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
int i = 0;
int z = 0;
- if (number[0] == 'n') {
- strncpy(naptrinput, number+1, sizeof(naptrinput));
- } else {
- strncpy(naptrinput, number, sizeof(naptrinput));
- }
+ ast_copy_string(naptrinput, number[0] == 'n' ? number+1 : number, sizeof(naptrinput));
context.naptrinput = naptrinput; /* The number */
context.dst = dst; /* Return string */
@@ -487,11 +483,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
} else {
s = s->next;
}
- if (suffix != NULL) {
- strncpy(tmp + newpos, suffix, sizeof(tmp) - newpos - 1);
- } else if (s) {
- strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1);
- }
+ ast_copy_string(tmp + newpos, suffix ? suffix : s->toplev, sizeof(tmp) - newpos);
ast_mutex_unlock(&enumlock);
if (!s)
break;
@@ -600,7 +592,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst
s = s->next;
}
if (s) {
- strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1);
+ ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos);
}
ast_mutex_unlock(&enumlock);
if (!s)