diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-14 07:44:19 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-14 07:44:19 +0000 |
commit | 65ae377f3de37edbcb16041701b36a45c4ff65f6 (patch) | |
tree | 8c674c26fc4a65f5fb0b8a2719e3e95929336928 /enum.c | |
parent | 4e18ef688947854313b99f35aa30c0e7d8ae29cd (diff) |
Remaining rgagnon source audit improvements (bug #2011)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3430 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'enum.c')
-rwxr-xr-x | enum.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -94,7 +94,7 @@ static int parse_naptr(unsigned char *dst, int dstsize, char *tech, int techsize regmatch_t pmatch[9]; - strcpy(dst, ""); + dst[0] = '\0'; if (len < sizeof(struct naptr)) { ast_log(LOG_WARNING, "Length too short\n"); @@ -151,7 +151,7 @@ static int parse_naptr(unsigned char *dst, int dstsize, char *tech, int techsize } /* DEDBUGGING STUB - strcpy(regexp, "!^\\+43(.*)$!\\1@bla.fasel!"); + strncpy(regexp, "!^\\+43(.*)$!\\1@bla.fasel!", sizeof(regexp) - 1); */ regexp_len = strlen(regexp); @@ -222,7 +222,8 @@ static int parse_naptr(unsigned char *dst, int dstsize, char *tech, int techsize } } *d = 0; - strncpy(dst, temp, dstsize); + strncpy(dst, temp, dstsize - 1); + dst[dstsize - 1] = '\0'; return 0; } @@ -245,8 +246,8 @@ static int txt_callback(void *context, u_char *answer, int len, u_char *fullansw if (answer != NULL) { c->txtlen = strlen(answer); - strncpy(c->txt, answer, 255); - c->txt[c->txtlen] = 0; + strncpy(c->txt, answer, sizeof(c->txt) - 1); + c->txt[sizeof(c->txt) - 1] = 0; return 1; } else { c->txt = NULL; @@ -309,7 +310,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds s = s->next; } if (s) { - strcpy(tmp + newpos, s->toplev); + strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1); } ast_mutex_unlock(&enumlock); if (!s) @@ -368,7 +369,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst s = s->next; } if (s) { - strcpy(tmp + newpos, s->toplev); + strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1); } ast_mutex_unlock(&enumlock); if (!s) |