Remaining rgagnon source audit improvements (bug #2011)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3430 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-07-14 07:44:19 +00:00
parent 872685d088
commit 8ed49644a6
9 changed files with 169 additions and 135 deletions

15
enum.c
View File

@@ -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)