[asterisk-commits] twilson: trunk r362635 - in /trunk: addons/ apps/ channels/ res/snmp/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 19 14:05:21 CDT 2012
Author: twilson
Date: Thu Apr 19 14:05:17 2012
New Revision: 362635
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=362635
Log:
Convert some strncpys to ast_copy_string
Review: https://reviewboard.asterisk.org/r/1732/
Modified:
trunk/addons/chan_ooh323.c
trunk/apps/app_alarmreceiver.c
trunk/channels/iax2-provision.c
trunk/res/snmp/agent.c
Modified: trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/chan_ooh323.c?view=diff&rev=362635&r1=362634&r2=362635
==============================================================================
--- trunk/addons/chan_ooh323.c (original)
+++ trunk/addons/chan_ooh323.c Thu Apr 19 14:05:17 2012
@@ -1800,7 +1800,7 @@
number[0] = '\0';
if(ooCallGetCalledPartyNumber(call, number, OO_MAX_NUMBER_LENGTH)== OO_OK) {
- strncpy(p->exten, number, sizeof(p->exten)-1);
+ ast_copy_string(p->exten, number, sizeof(p->exten));
} else {
update_our_aliases(call, p);
if (!ast_strlen_zero(p->callee_dialedDigits)) {
@@ -2296,8 +2296,7 @@
if (user->incominglimit < 0)
user->incominglimit = 0;
} else if (!strcasecmp(v->name, "accountcode")) {
- strncpy(user->accountcode, v->value,
- sizeof(user->accountcode)-1);
+ ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
} else if (!strcasecmp(v->name, "roundtrip")) {
sscanf(v->value, "%d,%d", &user->rtdrcount, &user->rtdrinterval);
} else if (!strcasecmp(v->name, "faststart")) {
@@ -2832,12 +2831,12 @@
gRasGkMode = RasDiscoverGatekeeper;
} else {
gRasGkMode = RasUseSpecificGatekeeper;
- strncpy(gGatekeeper, v->value, sizeof(gGatekeeper)-1);
+ ast_copy_string(gGatekeeper, v->value, sizeof(gGatekeeper));
}
} else if (!strcasecmp(v->name, "logfile")) {
- strncpy(gLogFile, v->value, sizeof(gLogFile)-1);
+ ast_copy_string(gLogFile, v->value, sizeof(gLogFile));
} else if (!strcasecmp(v->name, "context")) {
- strncpy(gContext, v->value, sizeof(gContext)-1);
+ ast_copy_string(gContext, v->value, sizeof(gContext));
ast_verb(3, " == Setting default context to %s\n", gContext);
} else if (!strcasecmp(v->name, "nat")) {
gNat = ast_true(v->value);
@@ -4307,7 +4306,7 @@
}
/* figure out our local RTP port and tell the H.323 stack about it*/
ast_rtp_instance_get_local_address(p->rtp, &tmp);
- strncpy(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
+ ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
lport = ast_sockaddr_stringify_port(&tmp);
if (p->rtptimeout) {
@@ -4351,7 +4350,7 @@
if (p->udptl) {
ast_udptl_get_us(p->udptl, &tmp);
- strncpy(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
+ ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
lport = ast_sockaddr_stringify_port(&tmp);
ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP));
mediaInfo.lMediaPort = atoi(lport);
Modified: trunk/apps/app_alarmreceiver.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_alarmreceiver.c?view=diff&rev=362635&r1=362634&r2=362635
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Thu Apr 19 14:05:17 2012
@@ -663,7 +663,6 @@
p = ast_variable_retrieve(cfg, "general", "eventcmd");
if (p) {
ast_copy_string(event_app, p, sizeof(event_app));
- event_app[sizeof(event_app) - 1] = '\0';
}
p = ast_variable_retrieve(cfg, "general", "loudness");
if (p) {
@@ -698,19 +697,16 @@
p = ast_variable_retrieve(cfg, "general", "eventspooldir");
if (p) {
ast_copy_string(event_spool_dir, p, sizeof(event_spool_dir));
- event_spool_dir[sizeof(event_spool_dir) - 1] = '\0';
}
p = ast_variable_retrieve(cfg, "general", "timestampformat");
if (p) {
ast_copy_string(time_stamp_format, p, sizeof(time_stamp_format));
- time_stamp_format[sizeof(time_stamp_format) - 1] = '\0';
}
p = ast_variable_retrieve(cfg, "general", "db-family");
if (p) {
ast_copy_string(db_family, p, sizeof(db_family));
- db_family[sizeof(db_family) - 1] = '\0';
}
ast_config_destroy(cfg);
}
Modified: trunk/channels/iax2-provision.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/iax2-provision.c?view=diff&rev=362635&r1=362634&r2=362635
==============================================================================
--- trunk/channels/iax2-provision.c (original)
+++ trunk/channels/iax2-provision.c Thu Apr 19 14:05:17 2012
@@ -311,7 +311,7 @@
ast_mutex_unlock(&provlock);
}
if (def)
- strncpy(cur->src, def, sizeof(cur->src) - 1);
+ ast_copy_string(cur->src, def, sizeof(cur->src));
else
cur->src[0] = '\0';
v = ast_variable_browse(cfg, s);
@@ -347,15 +347,15 @@
if (ast_str2tos(v->value, &cur->tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "user")) {
- strncpy(cur->user, v->value, sizeof(cur->user) - 1);
+ ast_copy_string(cur->user, v->value, sizeof(cur->user));
if (strcmp(cur->user, v->value))
ast_log(LOG_WARNING, "Truncating username from '%s' to '%s' for '%s' at line %d\n", v->value, cur->user, s, v->lineno);
} else if (!strcasecmp(v->name, "pass")) {
- strncpy(cur->pass, v->value, sizeof(cur->pass) - 1);
+ ast_copy_string(cur->pass, v->value, sizeof(cur->pass));
if (strcmp(cur->pass, v->value))
ast_log(LOG_WARNING, "Truncating password from '%s' to '%s' for '%s' at line %d\n", v->value, cur->pass, s, v->lineno);
} else if (!strcasecmp(v->name, "language")) {
- strncpy(cur->lang, v->value, sizeof(cur->lang) - 1);
+ ast_copy_string(cur->lang, v->value, sizeof(cur->lang));
if (strcmp(cur->lang, v->value))
ast_log(LOG_WARNING, "Truncating language from '%s' to '%s' for '%s' at line %d\n", v->value, cur->lang, s, v->lineno);
} else if (!strcasecmp(v->name, "flags")) {
@@ -391,7 +391,7 @@
return -1;
}
/* Initialize entry */
- strncpy(cur->name, s, sizeof(cur->name) - 1);
+ ast_copy_string(cur->name, s, sizeof(cur->name));
cur->dead = 1;
}
if (!iax_template_parse(cur, cfg, s, def))
Modified: trunk/res/snmp/agent.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/snmp/agent.c?view=diff&rev=362635&r1=362634&r2=362635
==============================================================================
--- trunk/res/snmp/agent.c (original)
+++ trunk/res/snmp/agent.c Thu Apr 19 14:05:17 2012
@@ -269,54 +269,47 @@
break;
case ASTCHANNAME:
if (!ast_strlen_zero(ast_channel_name(chan))) {
- strncpy(string_ret, ast_channel_name(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_name(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANLANGUAGE:
if (!ast_strlen_zero(ast_channel_language(chan))) {
- strncpy(string_ret, ast_channel_language(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_language(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANTYPE:
- strncpy(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
case ASTCHANMUSICCLASS:
if (!ast_strlen_zero(ast_channel_musicclass(chan))) {
- strncpy(string_ret, ast_channel_musicclass(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_musicclass(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANBRIDGE:
if ((bridge = ast_bridged_channel(chan)) != NULL) {
- strncpy(string_ret, ast_channel_name(bridge), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_name(bridge), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANMASQ:
if (ast_channel_masq(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masq(chan)))) {
- strncpy(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANMASQR:
if (ast_channel_masqr(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masqr(chan)))) {
- strncpy(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
@@ -330,35 +323,30 @@
break;
case ASTCHANAPP:
if (ast_channel_appl(chan)) {
- strncpy(string_ret, ast_channel_appl(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_appl(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANDATA:
if (ast_channel_data(chan)) {
- strncpy(string_ret, ast_channel_data(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_data(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANCONTEXT:
- strncpy(string_ret, ast_channel_context(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_context(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
case ASTCHANMACROCONTEXT:
- strncpy(string_ret, ast_channel_macrocontext(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_macrocontext(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
case ASTCHANMACROEXTEN:
- strncpy(string_ret, ast_channel_macroexten(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_macroexten(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
@@ -367,8 +355,7 @@
ret = (u_char *)&long_ret;
break;
case ASTCHANEXTEN:
- strncpy(string_ret, ast_channel_exten(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_exten(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
@@ -378,23 +365,20 @@
break;
case ASTCHANACCOUNTCODE:
if (!ast_strlen_zero(ast_channel_accountcode(chan))) {
- strncpy(string_ret, ast_channel_accountcode(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_accountcode(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANFORWARDTO:
if (!ast_strlen_zero(ast_channel_call_forward(chan))) {
- strncpy(string_ret, ast_channel_call_forward(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_call_forward(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANUNIQUEID:
- strncpy(string_ret, ast_channel_uniqueid(chan), sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_uniqueid(chan), sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
break;
@@ -420,40 +404,35 @@
break;
case ASTCHANCIDDNID:
if (ast_channel_dialed(chan)->number.str) {
- strncpy(string_ret, ast_channel_dialed(chan)->number.str, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_dialed(chan)->number.str, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANCIDNUM:
if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) {
- strncpy(string_ret, ast_channel_caller(chan)->id.number.str, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_caller(chan)->id.number.str, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANCIDNAME:
if (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) {
- strncpy(string_ret, ast_channel_caller(chan)->id.name.str, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_caller(chan)->id.name.str, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANCIDANI:
if (ast_channel_caller(chan)->ani.number.valid && ast_channel_caller(chan)->ani.number.str) {
- strncpy(string_ret, ast_channel_caller(chan)->ani.number.str, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_caller(chan)->ani.number.str, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
break;
case ASTCHANCIDRDNIS:
if (ast_channel_redirecting(chan)->from.number.valid && ast_channel_redirecting(chan)->from.number.str) {
- strncpy(string_ret, ast_channel_redirecting(chan)->from.number.str, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_redirecting(chan)->from.number.str, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
@@ -484,8 +463,7 @@
break;
case ASTCHANTONEZONE:
if (ast_channel_zone(chan)) {
- strncpy(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret));
- string_ret[sizeof(string_ret) - 1] = '\0';
+ ast_copy_string(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret));
*var_len = strlen(string_ret);
ret = (u_char *)string_ret;
}
More information about the asterisk-commits
mailing list