[asterisk-commits] trunk r18721 - /trunk/res/res_config_pgsql.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Apr 9 19:06:00 MST 2006
Author: russell
Date: Sun Apr 9 21:05:59 2006
New Revision: 18721
URL: http://svn.digium.com/view/asterisk?rev=18721&view=rev
Log:
Instead of using strncpy, use ast_copy_string. Also, in the case of copying a
constant string into a buffer that we know is big enough, don't use a length
limited copy at all, use strcpy.
... as stated in the coding guidelines.
Modified:
trunk/res/res_config_pgsql.c
Modified: trunk/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_pgsql.c?rev=18721&r1=18720&r2=18721&view=diff
==============================================================================
--- trunk/res/res_config_pgsql.c (original)
+++ trunk/res/res_config_pgsql.c Sun Apr 9 21:05:59 2006
@@ -651,17 +651,17 @@
if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
- strncpy(dbuser, "asterisk", sizeof(dbuser) - 1);
+ strcpy(dbuser, "asterisk");
} else {
- strncpy(dbuser, s, sizeof(dbuser) - 1);
+ ast_copy_string(dbuser, s, sizeof(dbuser));
}
if (!(s = ast_variable_retrieve(config, "general", "dbpass"))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: No database password found, using 'asterisk' as default.\n");
- strncpy(dbpass, "asterisk", sizeof(dbpass) - 1);
+ strcpy(dbpass, "asterisk");
} else {
- strncpy(dbpass, s, sizeof(dbpass) - 1);
+ ast_copy_string(dbpass, s, sizeof(dbpass));
}
if (!(s = ast_variable_retrieve(config, "general", "dbhost"))) {
@@ -669,15 +669,15 @@
"Postgresql RealTime: No database host found, using localhost via socket.\n");
dbhost[0] = '\0';
} else {
- strncpy(dbhost, s, sizeof(dbhost) - 1);
+ ast_copy_string(dbhost, s, sizeof(dbhost));
}
if (!(s = ast_variable_retrieve(config, "general", "dbname"))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: No database name found, using 'asterisk' as default.\n");
- strncpy(dbname, "asterisk", sizeof(dbname) - 1);
+ strcpy(dbname, "asterisk");
} else {
- strncpy(dbname, s, sizeof(dbname) - 1);
+ ast_copy_string(dbname, s, sizeof(dbname));
}
if (!(s = ast_variable_retrieve(config, "general", "dbport"))) {
@@ -691,9 +691,9 @@
if (dbhost && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
- strncpy(dbsock, "/tmp/pgsql.sock", sizeof(dbsock) - 1);
+ strcpy(dbsock, "/tmp/pgsql.sock");
} else {
- strncpy(dbsock, s, sizeof(dbsock) - 1);
+ ast_copy_string(dbsock, s, sizeof(dbsock));
}
}
ast_config_destroy(config);
More information about the asterisk-commits
mailing list