From 59d780973e0c1aab681be9dcba1baa2706caf92f Mon Sep 17 00:00:00 2001 From: markster Date: Wed, 14 Jul 2004 07:22:30 +0000 Subject: Merge rgagnon's pedantic string checks (apps a-m, bug #2035) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3428 f38db490-d61c-443f-a65b-d21fe96a405b --- apps/app_alarmreceiver.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'apps/app_alarmreceiver.c') diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c index 91317ae36..2d9c264c0 100755 --- a/apps/app_alarmreceiver.c +++ b/apps/app_alarmreceiver.c @@ -122,7 +122,7 @@ static void database_increment( char *key ) if(option_verbose >= 4) ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: New value for %s: %u\n", key, v); - snprintf(value, sizeof(value) - 1, "%u", v); + snprintf(value, sizeof(value), "%u", v); res = ast_db_put(db_family, key, value); @@ -389,7 +389,7 @@ static int log_events(struct ast_channel *chan, char *signalling_type, event_no { int res = 0; - char workstring[sizeof(event_spool_dir)+sizeof(event_file)]; + char workstring[sizeof(event_spool_dir)+sizeof(event_file)] = ""; int fd; FILE *logfile; event_node_t *elp = event; @@ -398,8 +398,8 @@ static int log_events(struct ast_channel *chan, char *signalling_type, event_no /* Make a template */ - strcpy(workstring, event_spool_dir); - strcat(workstring, event_file); + strncpy(workstring, event_spool_dir, sizeof(workstring) - 1); + strncat(workstring, event_file, sizeof(workstring) - strlen(workstring) - 1); /* Make the temporary file */ @@ -586,9 +586,11 @@ static int receive_ademco_contact_id( struct ast_channel *chan, void *data, int res = -1; break; } + + memset(enew, 0, sizeof(event_node_t)); enew->next = NULL; - strncpy(enew->data, event, sizeof(enew->data)); + strncpy(enew->data, event, sizeof(enew->data) - 1); /* * Insert event onto end of list @@ -638,7 +640,7 @@ static int alarmreceiver_exec(struct ast_channel *chan, void *data) int res = 0; struct localuser *u; event_node_t *elp, *efree; - char signalling_type[64]; + char signalling_type[64] = ""; event_node_t *event_head = NULL; @@ -661,7 +663,7 @@ static int alarmreceiver_exec(struct ast_channel *chan, void *data) /* Set default values for this invokation of the application */ - strcpy(signalling_type, ADEMCO_CONTACT_ID); + strncpy(signalling_type, ADEMCO_CONTACT_ID, sizeof(signalling_type) - 1); /* Answer the channel if it is not already */ -- cgit v1.2.3