aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-25 14:32:08 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-25 14:32:08 +0000
commit000e0986072e528276eb7ea9a37728b5b0e6be76 (patch)
treeb186c37b5085861c464a92debbf99dd8c2b71780 /main
parentc3ad9c9ef53aa9d4297f7c0f009da3c33f50bebc (diff)
apparently developers are still not aware that they should be use ast_copy_string instead of strncpy... fix up many more users, and fix some bugs in the process
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46200 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/cdr.c2
-rw-r--r--main/cli.c3
-rw-r--r--main/db.c3
-rw-r--r--main/image.c2
-rw-r--r--main/utils.c2
5 files changed, 5 insertions, 7 deletions
diff --git a/main/cdr.c b/main/cdr.c
index fb243ff49..ce525e20b 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -678,7 +678,7 @@ int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield)
int len = strlen(cdr->userfield);
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
- strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1);
+ ast_copy_string(cdr->userfield + len, userfield, sizeof(cdr->userfield) - len);
}
return 0;
diff --git a/main/cli.c b/main/cli.c
index d80738d66..5e2d2e180 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1705,8 +1705,7 @@ char **ast_cli_completion_matches(const char *text, const char *word)
if (!(retstr = ast_malloc(max_equal + 1)))
return NULL;
- strncpy(retstr, match_list[1], max_equal);
- retstr[max_equal] = '\0';
+ ast_copy_string(retstr, match_list[1], max_equal + 1);
match_list[0] = retstr;
/* ensure that the array is NULL terminated */
diff --git a/main/db.c b/main/db.c
index b9c9115c2..ed6fbc683 100644
--- a/main/db.c
+++ b/main/db.c
@@ -202,8 +202,7 @@ int ast_db_get(const char *family, const char *keys, char *value, int valuelen)
if (data.size) {
((char *)data.data)[data.size - 1] = '\0';
/* Make sure that we don't write too much to the dst pointer or we don't read too much from the source pointer */
- strncpy(value, data.data, (valuelen > data.size) ? data.size : valuelen);
- value[valuelen - 1] = '\0';
+ ast_copy_string(value, data.data, (valuelen > data.size) ? data.size : valuelen);
} else {
ast_log(LOG_NOTICE, "Strange, empty value for /%s/%s\n", family, keys);
}
diff --git a/main/image.c b/main/image.c
index 377ce9208..3d282428c 100644
--- a/main/image.c
+++ b/main/image.c
@@ -125,7 +125,7 @@ struct ast_frame *ast_read_image(char *filename, const char *preflang, int forma
AST_LIST_TRAVERSE(&imagers, i, list) {
if (i->format & format) {
char *stringp=NULL;
- strncpy(tmp, i->exts, sizeof(tmp)-1);
+ ast_copy_string(tmp, i->exts, sizeof(tmp));
stringp=tmp;
e = strsep(&stringp, "|");
while(e) {
diff --git a/main/utils.c b/main/utils.c
index ceb049f3a..6e1b4674f 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -449,7 +449,7 @@ char *ast_uri_encode(const char *string, char *outbuf, int buflen, int doreserve
char *out = NULL;
char *buf = NULL;
- strncpy(outbuf, string, buflen);
+ ast_copy_string(outbuf, string, buflen);
/* If there's no characters to convert, just go through and don't do anything */
while (*ptr) {