diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-10 02:05:59 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-10 02:05:59 +0000 |
commit | a06d9b22bc8d407780bd904e4081339b16c2cbc9 (patch) | |
tree | f22efcedf14edd3bb1a01cdf6d5e34ed4672fb2f /res/res_config_pgsql.c | |
parent | 70f8d1c38bc7ca0f2b82aee87b0ea4a0b98e65ac (diff) |
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.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@18721 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_config_pgsql.c')
-rw-r--r-- | res/res_config_pgsql.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index b890e49b1..d7a20e8bd 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -651,17 +651,17 @@ int parse_config(void) 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 @@ int parse_config(void) "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 @@ int parse_config(void) 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); |