Merge remaining audit patch (save dlfcn.c)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-07-14 13:57:15 +00:00
parent 9cd917c42a
commit 044ad2e2e7
20 changed files with 123 additions and 116 deletions

View File

@@ -178,8 +178,8 @@ static struct event {
static int process_message(struct ast_mansession *s, struct message *m) static int process_message(struct ast_mansession *s, struct message *m)
{ {
int x; int x;
char event[80]; char event[80] = "";
strncpy(event, get_header(m, "Event"), sizeof(event)); strncpy(event, get_header(m, "Event"), sizeof(event) - 1);
if (!strlen(event)) { if (!strlen(event)) {
fprintf(stderr, "Missing event in request"); fprintf(stderr, "Missing event in request");
return 0; return 0;

View File

@@ -71,16 +71,16 @@ static char *name = "csv";
static FILE *mf = NULL; static FILE *mf = NULL;
static int append_string(char *buf, char *s, int len) static int append_string(char *buf, char *s, size_t bufsize)
{ {
int pos = strlen(buf); int pos = strlen(buf);
int spos = 0; int spos = 0;
int error = 0; int error = 0;
if (pos >= len - 4) if (pos >= bufsize - 4)
return -1; return -1;
buf[pos++] = '\"'; buf[pos++] = '\"';
error = -1; error = -1;
while(pos < len - 3) { while(pos < bufsize - 3) {
if (!s[spos]) { if (!s[spos]) {
error = 0; error = 0;
break; break;
@@ -96,87 +96,87 @@ static int append_string(char *buf, char *s, int len)
return error; return error;
} }
static int append_int(char *buf, int s, int len) static int append_int(char *buf, int s, size_t bufsize)
{ {
char tmp[32]; char tmp[32];
int pos = strlen(buf); int pos = strlen(buf);
snprintf(tmp, sizeof(tmp), "%d", s); snprintf(tmp, sizeof(tmp), "%d", s);
if (pos + strlen(tmp) > len - 3) if (pos + strlen(tmp) > bufsize - 3)
return -1; return -1;
strncat(buf, tmp, len); strncat(buf, tmp, bufsize - strlen(buf) - 1);
pos = strlen(buf); pos = strlen(buf);
buf[pos++] = ','; buf[pos++] = ',';
buf[pos++] = '\0'; buf[pos++] = '\0';
return 0; return 0;
} }
static int append_date(char *buf, struct timeval tv, int len) static int append_date(char *buf, struct timeval tv, size_t bufsize)
{ {
char tmp[80]; char tmp[80] = "";
struct tm tm; struct tm tm;
time_t t; time_t t;
t = tv.tv_sec; t = tv.tv_sec;
if (strlen(buf) > len - 3) if (strlen(buf) > bufsize - 3)
return -1; return -1;
if (!tv.tv_sec && !tv.tv_usec) { if (!tv.tv_sec && !tv.tv_usec) {
strncat(buf, ",", len); strncat(buf, ",", bufsize - strlen(buf) - 1);
return 0; return 0;
} }
localtime_r(&t,&tm); localtime_r(&t,&tm);
strftime(tmp, sizeof(tmp), DATE_FORMAT, &tm); strftime(tmp, sizeof(tmp), DATE_FORMAT, &tm);
return append_string(buf, tmp, len); return append_string(buf, tmp, bufsize);
} }
static int build_csv_record(char *buf, int len, struct ast_cdr *cdr) static int build_csv_record(char *buf, size_t bufsize, struct ast_cdr *cdr)
{ {
buf[0] = '\0'; buf[0] = '\0';
/* Account code */ /* Account code */
append_string(buf, cdr->accountcode, len); append_string(buf, cdr->accountcode, bufsize);
/* Source */ /* Source */
append_string(buf, cdr->src, len); append_string(buf, cdr->src, bufsize);
/* Destination */ /* Destination */
append_string(buf, cdr->dst, len); append_string(buf, cdr->dst, bufsize);
/* Destination context */ /* Destination context */
append_string(buf, cdr->dcontext, len); append_string(buf, cdr->dcontext, bufsize);
/* Caller*ID */ /* Caller*ID */
append_string(buf, cdr->clid, len); append_string(buf, cdr->clid, bufsize);
/* Channel */ /* Channel */
append_string(buf, cdr->channel, len); append_string(buf, cdr->channel, bufsize);
/* Destination Channel */ /* Destination Channel */
append_string(buf, cdr->dstchannel, len); append_string(buf, cdr->dstchannel, bufsize);
/* Last Application */ /* Last Application */
append_string(buf, cdr->lastapp, len); append_string(buf, cdr->lastapp, bufsize);
/* Last Data */ /* Last Data */
append_string(buf, cdr->lastdata, len); append_string(buf, cdr->lastdata, bufsize);
/* Start Time */ /* Start Time */
append_date(buf, cdr->start, len); append_date(buf, cdr->start, bufsize);
/* Answer Time */ /* Answer Time */
append_date(buf, cdr->answer, len); append_date(buf, cdr->answer, bufsize);
/* End Time */ /* End Time */
append_date(buf, cdr->end, len); append_date(buf, cdr->end, bufsize);
/* Duration */ /* Duration */
append_int(buf, cdr->duration, len); append_int(buf, cdr->duration, bufsize);
/* Billable seconds */ /* Billable seconds */
append_int(buf, cdr->billsec, len); append_int(buf, cdr->billsec, bufsize);
/* Disposition */ /* Disposition */
append_string(buf, ast_cdr_disp2str(cdr->disposition), len); append_string(buf, ast_cdr_disp2str(cdr->disposition), bufsize);
/* AMA Flags */ /* AMA Flags */
append_string(buf, ast_cdr_flags2str(cdr->amaflags), len); append_string(buf, ast_cdr_flags2str(cdr->amaflags), bufsize);
#ifdef CSV_LOGUNIQUEID #ifdef CSV_LOGUNIQUEID
/* Unique ID */ /* Unique ID */
append_string(buf, cdr->uniqueid, len); append_string(buf, cdr->uniqueid, bufsize);
#endif #endif
#ifdef CSV_LOGUSERFIELD #ifdef CSV_LOGUSERFIELD
/* append the user field */ /* append the user field */
append_string(buf, cdr->userfield,len); append_string(buf, cdr->userfield,bufsize);
#endif #endif
/* If we hit the end of our buffer, log an error */ /* If we hit the end of our buffer, log an error */
if (strlen(buf) < len - 5) { if (strlen(buf) < bufsize - 5) {
/* Trim off trailing comma */ /* Trim off trailing comma */
buf[strlen(buf) - 1] = '\0'; buf[strlen(buf) - 1] = '\0';
strncat(buf, "\n", len); strncat(buf, "\n", bufsize - strlen(buf) - 1);
return 0; return 0;
} }
return -1; return -1;
@@ -205,7 +205,7 @@ static int csv_log(struct ast_cdr *cdr)
/* Make sure we have a big enough buf */ /* Make sure we have a big enough buf */
char buf[1024]; char buf[1024];
char csvmaster[AST_CONFIG_MAX_PATH]; char csvmaster[AST_CONFIG_MAX_PATH];
snprintf((char *)csvmaster,sizeof(csvmaster)-1,"%s/%s/%s",(char *)ast_config_AST_LOG_DIR,CSV_LOG_DIR,CSV_MASTER); snprintf(csvmaster, sizeof(csvmaster),"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
#if 0 #if 0
printf("[CDR] %s ('%s' -> '%s') Dur: %ds Bill: %ds Disp: %s Flags: %s Account: [%s]\n", cdr->channel, cdr->src, cdr->dst, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), ast_cdr_flags2str(cdr->amaflags), cdr->accountcode); printf("[CDR] %s ('%s' -> '%s') Dur: %ds Bill: %ds Disp: %s Flags: %s Account: [%s]\n", cdr->channel, cdr->src, cdr->dst, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), ast_cdr_flags2str(cdr->amaflags), cdr->accountcode);
#endif #endif

View File

@@ -56,25 +56,25 @@ static int odbc_log(struct ast_cdr *cdr)
short int ODBC_mlen; short int ODBC_mlen;
int ODBC_res; int ODBC_res;
char ODBC_msg[200], ODBC_stat[10]; char ODBC_msg[200], ODBC_stat[10];
char sqlcmd[2048], timestr[128]; char sqlcmd[2048] = "", timestr[128];
int res = 0; int res = 0;
struct tm tm; struct tm tm;
localtime_r(&cdr->start.tv_sec,&tm); localtime_r(&cdr->start.tv_sec,&tm);
ast_mutex_lock(&odbc_lock); ast_mutex_lock(&odbc_lock);
strftime(timestr,128,DATE_FORMAT,&tm); strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
memset(sqlcmd,0,2048); memset(sqlcmd,0,2048);
if((loguniqueid != NULL) && ((strcmp(loguniqueid, "1") == 0) || (strcmp(loguniqueid, "yes") == 0))) if((loguniqueid != NULL) && ((strcmp(loguniqueid, "1") == 0) || (strcmp(loguniqueid, "yes") == 0)))
{ {
sprintf(sqlcmd,"INSERT INTO cdr " snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO cdr "
"(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp," "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,"
"lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) " "lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) "
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
} }
else else
{ {
sprintf(sqlcmd,"INSERT INTO cdr " snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO cdr "
"(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata," "(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,"
"duration,billsec,disposition,amaflags,accountcode) " "duration,billsec,disposition,amaflags,accountcode) "
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
@@ -264,8 +264,9 @@ static int odbc_load_module(void)
dsn = malloc(strlen(tmp) + 1); dsn = malloc(strlen(tmp) + 1);
if (dsn != NULL) if (dsn != NULL)
{ {
memset(dsn, 0, strlen(tmp) + 1);
dsn_alloc = 1; dsn_alloc = 1;
strcpy(dsn,tmp); strncpy(dsn, tmp, strlen(tmp));
} }
else else
{ {
@@ -285,8 +286,9 @@ static int odbc_load_module(void)
username = malloc(strlen(tmp) + 1); username = malloc(strlen(tmp) + 1);
if (username != NULL) if (username != NULL)
{ {
memset(username, 0, strlen(tmp) + 1);
username_alloc = 1; username_alloc = 1;
strcpy(username,tmp); strncpy(username, tmp, strlen(tmp));
} }
else else
{ {
@@ -306,8 +308,9 @@ static int odbc_load_module(void)
password = malloc(strlen(tmp) + 1); password = malloc(strlen(tmp) + 1);
if (password != NULL) if (password != NULL)
{ {
memset(password, 0, strlen(tmp) + 1);
password_alloc = 1; password_alloc = 1;
strcpy(password,tmp); strncpy(password, tmp, strlen(tmp));
} }
else else
{ {

View File

@@ -49,15 +49,13 @@ PGresult *result;
static int pgsql_log(struct ast_cdr *cdr) static int pgsql_log(struct ast_cdr *cdr)
{ {
struct tm tm; struct tm tm;
char sqlcmd[2048], timestr[128]; char sqlcmd[2048] = "", timestr[128];
char *pgerror; char *pgerror;
ast_mutex_lock(&pgsql_lock); ast_mutex_lock(&pgsql_lock);
memset(sqlcmd,0,2048);
localtime_r(&cdr->start.tv_sec,&tm); localtime_r(&cdr->start.tv_sec,&tm);
strftime(timestr,128,DATE_FORMAT,&tm); strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if ((!connected) && pghostname && pgdbuser && pgpassword && pgdbname) { if ((!connected) && pghostname && pgdbuser && pgpassword && pgdbname) {
conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword); conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
@@ -101,7 +99,7 @@ static int pgsql_log(struct ast_cdr *cdr)
ast_log(LOG_DEBUG,"cdr_pgsql: inserting a CDR record.\n"); ast_log(LOG_DEBUG,"cdr_pgsql: inserting a CDR record.\n");
sprintf(sqlcmd,"INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')",timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield); snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')",timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield);
ast_log(LOG_DEBUG,"cdr_pgsql: SQL command executed: %s\n",sqlcmd); ast_log(LOG_DEBUG,"cdr_pgsql: SQL command executed: %s\n",sqlcmd);
/* Test to be sure we're still connected... */ /* Test to be sure we're still connected... */
@@ -204,8 +202,9 @@ static int my_load_module(void)
if (tmp) { if (tmp) {
pghostname = malloc(strlen(tmp) + 1); pghostname = malloc(strlen(tmp) + 1);
if (pghostname != NULL) { if (pghostname != NULL) {
memset(pghostname, 0, strlen(tmp) + 1);
hostname_alloc = 1; hostname_alloc = 1;
strcpy(pghostname,tmp); strncpy(pghostname, tmp, strlen(tmp));
} else { } else {
ast_log(LOG_ERROR,"Out of memory error.\n"); ast_log(LOG_ERROR,"Out of memory error.\n");
return -1; return -1;
@@ -219,8 +218,9 @@ static int my_load_module(void)
if (tmp) { if (tmp) {
pgdbname = malloc(strlen(tmp) + 1); pgdbname = malloc(strlen(tmp) + 1);
if (pgdbname != NULL) { if (pgdbname != NULL) {
memset(pgdbname, 0, strlen(tmp) + 1);
dbname_alloc = 1; dbname_alloc = 1;
strcpy(pgdbname,tmp); strncpy(pgdbname, tmp, strlen(tmp));
} else { } else {
ast_log(LOG_ERROR,"Out of memory error.\n"); ast_log(LOG_ERROR,"Out of memory error.\n");
return -1; return -1;
@@ -234,8 +234,9 @@ static int my_load_module(void)
if (tmp) { if (tmp) {
pgdbuser = malloc(strlen(tmp) + 1); pgdbuser = malloc(strlen(tmp) + 1);
if (pgdbuser != NULL) { if (pgdbuser != NULL) {
memset(pgdbuser, 0, strlen(tmp) + 1);
dbuser_alloc = 1; dbuser_alloc = 1;
strcpy(pgdbuser,tmp); strncpy(pgdbuser, tmp, strlen(tmp));
} else { } else {
ast_log(LOG_ERROR,"Out of memory error.\n"); ast_log(LOG_ERROR,"Out of memory error.\n");
return -1; return -1;
@@ -249,8 +250,9 @@ static int my_load_module(void)
if (tmp) { if (tmp) {
pgpassword = malloc(strlen(tmp) + 1); pgpassword = malloc(strlen(tmp) + 1);
if (pgpassword != NULL) { if (pgpassword != NULL) {
memset(pgpassword, 0, strlen(tmp) + 1);
password_alloc = 1; password_alloc = 1;
strcpy(pgpassword,tmp); strncpy(pgpassword, tmp, strlen(tmp));
} else { } else {
ast_log(LOG_ERROR,"Out of memory error.\n"); ast_log(LOG_ERROR,"Out of memory error.\n");
return -1; return -1;
@@ -264,8 +266,9 @@ static int my_load_module(void)
if (tmp) { if (tmp) {
pgdbport = malloc(strlen(tmp) + 1); pgdbport = malloc(strlen(tmp) + 1);
if (pgdbport != NULL) { if (pgdbport != NULL) {
memset(pgdbport, 0, strlen(tmp) + 1);
dbport_alloc = 1; dbport_alloc = 1;
strcpy(pgdbport,tmp); strncpy(pgdbport, tmp, strlen(tmp));
} else { } else {
ast_log(LOG_ERROR,"Out of memory error.\n"); ast_log(LOG_ERROR,"Out of memory error.\n");
return -1; return -1;

View File

@@ -162,7 +162,7 @@ int load_module(void)
int res; int res;
/* is the database there? */ /* is the database there? */
snprintf((char *)fn,sizeof(fn)-1,"%s/cdr.db",(char *)ast_config_AST_LOG_DIR); snprintf(fn, sizeof(fn), "%s/cdr.db", ast_config_AST_LOG_DIR);
db = sqlite_open(fn, 0660, &zErr); db = sqlite_open(fn, 0660, &zErr);
if (!db) { if (!db) {
ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr); ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);

View File

@@ -79,8 +79,8 @@ dbm_open(file, flags, mode)
info.cachesize = 0; info.cachesize = 0;
info.hash = NULL; info.hash = NULL;
info.lorder = 0; info.lorder = 0;
(void)strcpy(path, file); (void)strncpy(path, file, len - 1);
(void)strcat(path, DBM_SUFFIX); (void)strncat(path, DBM_SUFFIX, len - strlen(path) - 1);
db = (DBM *)__hash_open(path, flags, mode, &info, 0); db = (DBM *)__hash_open(path, flags, mode, &info, 0);
#ifndef __GNUC__ #ifndef __GNUC__
free(path); free(path);

View File

@@ -676,7 +676,7 @@ ed_prev_history(EditLine *el, int c)
if (el->el_history.eventno == 0) { /* save the current buffer if (el->el_history.eventno == 0) { /* save the current buffer
* away */ * away */
(void) strncpy(el->el_history.buf, el->el_line.buffer, (void) strncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ); EL_BUFSIZ - 1);
el->el_history.last = el->el_history.buf + el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer); (el->el_line.lastchar - el->el_line.buffer);
} }
@@ -742,7 +742,7 @@ ed_search_prev_history(EditLine *el, int c)
} }
if (el->el_history.eventno == 0) { if (el->el_history.eventno == 0) {
(void) strncpy(el->el_history.buf, el->el_line.buffer, (void) strncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ); EL_BUFSIZ - 1);
el->el_history.last = el->el_history.buf + el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer); (el->el_line.lastchar - el->el_line.buffer);
} }

View File

@@ -106,7 +106,7 @@ hist_get(EditLine *el)
if (el->el_history.eventno == 0) { /* if really the current line */ if (el->el_history.eventno == 0) { /* if really the current line */
(void) strncpy(el->el_line.buffer, el->el_history.buf, (void) strncpy(el->el_line.buffer, el->el_history.buf,
el->el_history.sz); el->el_history.sz - 1);
el->el_line.lastchar = el->el_line.buffer + el->el_line.lastchar = el->el_line.buffer +
(el->el_history.last - el->el_history.buf); (el->el_history.last - el->el_history.buf);

View File

@@ -98,7 +98,7 @@ static void __verboser(const char *stuff, int opos, int replacelast, int complet
char *s2[2]; char *s2[2];
struct timeval tv; struct timeval tv;
int ms; int ms;
s2[0] = stuff; s2[0] = (char *)stuff;
s2[1] = NULL; s2[1] = NULL;
gtk_clist_freeze(GTK_CLIST(verb)); gtk_clist_freeze(GTK_CLIST(verb));
if (replacelast) if (replacelast)
@@ -232,7 +232,7 @@ static void file_ok_sel(GtkWidget *w, GtkFileSelection *fs)
char tmp[AST_CONFIG_MAX_PATH]; char tmp[AST_CONFIG_MAX_PATH];
char *module = gtk_file_selection_get_filename(fs); char *module = gtk_file_selection_get_filename(fs);
char buf[256]; char buf[256];
snprintf((char *)tmp,sizeof(tmp)-1,"%s/",(char *)ast_config_AST_MODULE_DIR); snprintf(tmp, sizeof(tmp), "%s/", ast_config_AST_MODULE_DIR);
if (!strncmp(module, (char *)tmp, strlen(tmp))) if (!strncmp(module, (char *)tmp, strlen(tmp)))
module += strlen(tmp); module += strlen(tmp);
gdk_threads_leave(); gdk_threads_leave();
@@ -251,7 +251,7 @@ static void add_module(void)
{ {
char tmp[AST_CONFIG_MAX_PATH]; char tmp[AST_CONFIG_MAX_PATH];
GtkWidget *filew; GtkWidget *filew;
snprintf((char *)tmp,sizeof(tmp)-1,"%s/*.so",(char *)ast_config_AST_MODULE_DIR); snprintf(tmp, sizeof(tmp), "%s/*.so", ast_config_AST_MODULE_DIR);
filew = gtk_file_selection_new("Load Module"); filew = gtk_file_selection_new("Load Module");
gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(filew)->ok_button), gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(filew)->ok_button),
"clicked", GTK_SIGNAL_FUNC(file_ok_sel), filew); "clicked", GTK_SIGNAL_FUNC(file_ok_sel), filew);
@@ -332,8 +332,8 @@ static void *consolethread(void *data)
static int cli_activate(void) static int cli_activate(void)
{ {
char buf[256]; char buf[256] = "";
strncpy(buf, gtk_entry_get_text(GTK_ENTRY(cli)), sizeof(buf)); strncpy(buf, gtk_entry_get_text(GTK_ENTRY(cli)), sizeof(buf) - 1);
gtk_entry_set_text(GTK_ENTRY(cli), ""); gtk_entry_set_text(GTK_ENTRY(cli), "");
if (strlen(buf)) { if (strlen(buf)) {
ast_cli_command(clipipe[1], buf); ast_cli_command(clipipe[1], buf);

View File

@@ -129,7 +129,7 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
strncpy(o->dest, c2, sizeof(o->dest) - 1); strncpy(o->dest, c2, sizeof(o->dest) - 1);
} else { } else {
ast_log(LOG_NOTICE, "Channel should be in form Tech/Dest at line %d of %s\n", lineno, fn); ast_log(LOG_NOTICE, "Channel should be in form Tech/Dest at line %d of %s\n", lineno, fn);
strcpy(o->tech, ""); o->tech[0] = '\0';
} }
} else if (!strcasecmp(buf, "callerid")) { } else if (!strcasecmp(buf, "callerid")) {
strncpy(o->callerid, c, sizeof(o->callerid) - 1); strncpy(o->callerid, c, sizeof(o->callerid) - 1);
@@ -375,7 +375,7 @@ int load_module(void)
{ {
pthread_t thread; pthread_t thread;
pthread_attr_t attr; pthread_attr_t attr;
snprintf((char *)qdir,sizeof(qdir)-1,"%s/%s",(char *)ast_config_AST_SPOOL_DIR,"outgoing"); snprintf(qdir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing");
if (mkdir(qdir, 0700) && (errno != EEXIST)) { if (mkdir(qdir, 0700) && (errno != EEXIST)) {
ast_log(LOG_WARNING, "Unable to create queue directory %s -- outgoing spool disabled\n", qdir); ast_log(LOG_WARNING, "Unable to create queue directory %s -- outgoing spool disabled\n", qdir);
return 0; return 0;

View File

@@ -259,7 +259,7 @@ int load_module(void)
{ {
int val; int val;
snprintf((char *)dialfile, sizeof(dialfile)-1,"%s/%s", (char *)ast_config_AST_RUN_DIR,"autodial.ctl"); snprintf((char *)dialfile, sizeof(dialfile), "%s/%s", ast_config_AST_RUN_DIR, "autodial.ctl");
if((val=mkfifo(dialfile, 0700))) { if((val=mkfifo(dialfile, 0700))) {
if(errno!=EEXIST){ if(errno!=EEXIST){
ast_log(LOG_ERROR, "Error:%d Creating Autodial FIFO\n",errno); ast_log(LOG_ERROR, "Error:%d Creating Autodial FIFO\n",errno);

View File

@@ -1006,13 +1006,13 @@ static void init_state(void)
for (x=0;x<ADSI_MAX_INTRO;x++) for (x=0;x<ADSI_MAX_INTRO;x++)
aligns[x] = ADSI_JUST_CENT; aligns[x] = ADSI_JUST_CENT;
strcpy(intro[0], "Welcome to the"); strncpy(intro[0], "Welcome to the", sizeof(intro[0]) - 1);
strcpy(intro[1], "Asterisk"); strncpy(intro[1], "Asterisk", sizeof(intro[1]) - 1);
strcpy(intro[2], "Open Source PBX"); strncpy(intro[2], "Open Source PBX", sizeof(intro[2]) - 1);
total = 3; total = 3;
speeds = 0; speeds = 0;
for (x=3;x<ADSI_MAX_INTRO;x++) for (x=3;x<ADSI_MAX_INTRO;x++)
strcpy(intro[x], ""); intro[x][0] = '\0';
memset(speeddial, 0, sizeof(speeddial)); memset(speeddial, 0, sizeof(speeddial));
alignment = ADSI_JUST_CENT; alignment = ADSI_JUST_CENT;
} }
@@ -1034,7 +1034,8 @@ static void adsi_load(void)
else if (!strcasecmp(v->name, "greeting")) { else if (!strcasecmp(v->name, "greeting")) {
if (x < ADSI_MAX_INTRO) { if (x < ADSI_MAX_INTRO) {
aligns[x] = alignment; aligns[x] = alignment;
strncpy(intro[x], v->value, 20); strncpy(intro[x], v->value, sizeof(intro[x]) - 1);
intro[x][sizeof(intro[x]) - 1] = '\0';
x++; x++;
} }
} else if (!strcasecmp(v->name, "maxretries")) { } else if (!strcasecmp(v->name, "maxretries")) {
@@ -1056,7 +1057,7 @@ static void adsi_load(void)
sname = name; sname = name;
if (x < ADSI_MAX_SPEED_DIAL) { if (x < ADSI_MAX_SPEED_DIAL) {
/* Up to 20 digits */ /* Up to 20 digits */
strncpy(speeddial[x][0], v->name, 20); strncpy(speeddial[x][0], v->name, sizeof(speeddial[x][0]) - 1);
strncpy(speeddial[x][1], name, 18); strncpy(speeddial[x][1], name, 18);
strncpy(speeddial[x][2], sname, 7); strncpy(speeddial[x][2], sname, 7);
x++; x++;

View File

@@ -38,16 +38,16 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
struct ast_config *config, *new; struct ast_config *config, *new;
struct ast_variable *v, *cur_v, *new_v; struct ast_variable *v, *cur_v, *new_v;
struct ast_category *cur_cat, *new_cat; struct ast_category *cur_cat, *new_cat;
char table[128]; char table[128] = "";
char connection[128]; char connection[128] = "";
int configured = 0, res = 0; int configured = 0, res = 0;
odbc_obj *obj; odbc_obj *obj;
SQLINTEGER err=0, commented=0, cat_metric=0, var_metric=0, last_cat_metric=0; SQLINTEGER err=0, commented=0, cat_metric=0, var_metric=0, last_cat_metric=0;
SQLBIGINT id; SQLBIGINT id;
char sql[255], filename[128], category[128], var_name[128], var_val[128]; char sql[255] = "", filename[128], category[128], var_name[128], var_val[128];
SQLSMALLINT rowcount=0; SQLSMALLINT rowcount=0;
SQLHSTMT stmt; SQLHSTMT stmt;
char last[80]; char last[80] = "";
int cat_started = 0; int cat_started = 0;
int var_started = 0; int var_started = 0;
@@ -68,10 +68,10 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
if (config) { if (config) {
for (v = ast_variable_browse (config, "settings"); v; v = v->next) { for (v = ast_variable_browse (config, "settings"); v; v = v->next) {
if (!strcmp (v->name, "table")) { if (!strcmp (v->name, "table")) {
strncpy (table, v->value, sizeof (table)); strncpy(table, v->value, sizeof(table) - 1);
configured++; configured++;
} else if (!strcmp (v->name, "connection")) { } else if (!strcmp (v->name, "connection")) {
strncpy (connection, v->value, sizeof (connection)); strncpy(connection, v->value, sizeof(connection) - 1);
configured++; configured++;
} }
} }
@@ -96,7 +96,7 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
SQLBindCol (stmt, 7, SQL_C_CHAR, &var_name, sizeof (var_name), &err); SQLBindCol (stmt, 7, SQL_C_CHAR, &var_name, sizeof (var_name), &err);
SQLBindCol (stmt, 8, SQL_C_CHAR, &var_val, sizeof (var_val), &err); SQLBindCol (stmt, 8, SQL_C_CHAR, &var_val, sizeof (var_val), &err);
sprintf (sql, "select * from %s where filename='%s' and commented=0 order by filename,cat_metric desc,var_metric asc,id", table, file); snprintf(sql, sizeof(sql), "select * from %s where filename='%s' and commented=0 order by filename,cat_metric desc,var_metric asc,id", table, file);
res = SQLExecDirect (stmt, sql, SQL_NTS); res = SQLExecDirect (stmt, sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -133,7 +133,7 @@ static struct ast_config *config_odbc (char *file, struct ast_config *new_config
); );
} else { } else {
if (strcmp (last, category) || last_cat_metric != cat_metric) { if (strcmp (last, category) || last_cat_metric != cat_metric) {
strcpy (last, category); strncpy(last, category, sizeof(last) - 1);
last_cat_metric = cat_metric; last_cat_metric = cat_metric;
new_cat = (struct ast_category *) ast_new_category (category); new_cat = (struct ast_category *) ast_new_category (category);
@@ -184,7 +184,7 @@ int unload_module (void)
int load_module (void) int load_module (void)
{ {
memset (&reg1, 0, sizeof (struct ast_config_reg)); memset (&reg1, 0, sizeof (struct ast_config_reg));
strcpy (reg1.name, "odbc"); strncpy(reg1.name, "odbc", sizeof(reg1.name) - 1);
reg1.func = config_odbc; reg1.func = config_odbc;
ast_cust_config_register (&reg1); ast_cust_config_register (&reg1);
ast_log (LOG_NOTICE, "res_config_odbc loaded.\n"); ast_log (LOG_NOTICE, "res_config_odbc loaded.\n");

View File

@@ -213,9 +213,9 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
if (found) if (found)
ast_mutex_lock(&keylock); ast_mutex_lock(&keylock);
/* First the filename */ /* First the filename */
strncpy(key->fn, ffname, sizeof(key->fn)); strncpy(key->fn, ffname, sizeof(key->fn) - 1);
/* Then the name */ /* Then the name */
strncpy(key->name, fname, sizeof(key->name)); strncpy(key->name, fname, sizeof(key->name) - 1);
key->ktype = ktype; key->ktype = ktype;
/* Yes, assume we're going to be deleted */ /* Yes, assume we're going to be deleted */
key->delme = 1; key->delme = 1;
@@ -444,14 +444,14 @@ static int init_keys(int fd, int argc, char *argv[])
struct ast_key *key; struct ast_key *key;
int ign; int ign;
char *kn; char *kn;
char tmp[256]; char tmp[256] = "";
key = keys; key = keys;
while(key) { while(key) {
/* Reload keys that need pass codes now */ /* Reload keys that need pass codes now */
if (key->ktype & KEY_NEEDS_PASSCODE) { if (key->ktype & KEY_NEEDS_PASSCODE) {
kn = key->fn + strlen(ast_config_AST_KEY_DIR) + 1; kn = key->fn + strlen(ast_config_AST_KEY_DIR) + 1;
strncpy(tmp, kn, sizeof(tmp)); strncpy(tmp, kn, sizeof(tmp) - 1);
try_load_key((char *)ast_config_AST_KEY_DIR, tmp, fd, fd, &ign); try_load_key((char *)ast_config_AST_KEY_DIR, tmp, fd, fd, &ign);
} }
key = key->next; key = key->next;

View File

@@ -163,7 +163,7 @@ static int handle_show_indications(int fd, int argc, char *argv[])
j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadance[i]); j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadance[i]);
} }
if (tz->nrringcadance) j--; if (tz->nrringcadance) j--;
strncpy(buf+j,"\n",sizeof(buf)-j); strncpy(buf+j,"\n",sizeof(buf)-j-1);
ast_cli(fd,buf); ast_cli(fd,buf);
for (ts=tz->tones; ts; ts=ts->next) for (ts=tz->tones; ts; ts=ts->next)
ast_cli(fd,"%-7.7s %-15.15s %s\n",tz->country,ts->name,ts->data); ast_cli(fd,"%-7.7s %-15.15s %s\n",tz->country,ts->name,ts->data);
@@ -241,7 +241,7 @@ static int ind_load_module(void)
return -1; return -1;
} }
memset(tones,0,sizeof(struct tone_zone)); memset(tones,0,sizeof(struct tone_zone));
strncpy(tones->country,cxt,sizeof(tones->country)); strncpy(tones->country,cxt,sizeof(tones->country) - 1);
v = ast_variable_browse(cfg, cxt); v = ast_variable_browse(cfg, cxt);
while(v) { while(v) {
@@ -282,7 +282,7 @@ static int ind_load_module(void)
return -1; return -1;
} }
memset(azone,0,sizeof(struct tone_zone)); memset(azone,0,sizeof(struct tone_zone));
strncpy(azone->country,country,sizeof(azone->country)); strncpy(azone->country, country, sizeof(azone->country) - 1);
strncpy(azone->alias, cxt, sizeof(azone->alias)-1); strncpy(azone->alias, cxt, sizeof(azone->alias)-1);
if (ast_register_indication_country(azone)) { if (ast_register_indication_country(azone)) {
ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno); ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno);

View File

@@ -153,7 +153,7 @@ static int spawn_mp3(struct mohclass *class)
files = 0; files = 0;
while((de = readdir(dir)) && (files < MAX_MP3S)) { while((de = readdir(dir)) && (files < MAX_MP3S)) {
if ((strlen(de->d_name) > 3) && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3")) { if ((strlen(de->d_name) > 3) && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3")) {
strncpy(fns[files], de->d_name, sizeof(fns[files])); strncpy(fns[files], de->d_name, sizeof(fns[files]) - 1);
argv[argc++] = fns[files]; argv[argc++] = fns[files];
files++; files++;
} }
@@ -340,7 +340,7 @@ static int moh2_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "SetMusicOnHold requires an argument (class)\n"); ast_log(LOG_WARNING, "SetMusicOnHold requires an argument (class)\n");
return -1; return -1;
} }
strncpy(chan->musicclass, data, sizeof(chan->musicclass)); strncpy(chan->musicclass, data, sizeof(chan->musicclass) - 1);
return 0; return 0;
} }

View File

@@ -61,7 +61,7 @@ static int odbc_write(struct odbc_list *registry, char *name, odbc_obj * obj)
int x = 0; int x = 0;
for (x = 0; x < MAX_ODBC_HANDLES; x++) { for (x = 0; x < MAX_ODBC_HANDLES; x++) {
if (!registry[x].used) { if (!registry[x].used) {
strncpy(registry[x].name, name, sizeof(registry[x].name)); strncpy(registry[x].name, name, sizeof(registry[x].name) - 1);
registry[x].obj = obj; registry[x].obj = obj;
registry[x].used = 1; registry[x].used = 1;
return 1; return 1;

View File

@@ -121,7 +121,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
osp->retrydelay = OSP_DEFAULT_RETRY_DELAY; osp->retrydelay = OSP_DEFAULT_RETRY_DELAY;
osp->retrylimit = OSP_DEFAULT_RETRY_LIMIT; osp->retrylimit = OSP_DEFAULT_RETRY_LIMIT;
osp->timeout = OSP_DEFAULT_TIMEOUT; osp->timeout = OSP_DEFAULT_TIMEOUT;
strcpy(osp->source, ""); osp->source[0] = '\0';
ast_log(LOG_DEBUG, "Building OSP Provider '%s'\n", cat); ast_log(LOG_DEBUG, "Building OSP Provider '%s'\n", cat);
v = ast_variable_browse(cfg, cat); v = ast_variable_browse(cfg, cat);
while(v) { while(v) {
@@ -138,7 +138,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
} else if (!strcasecmp(v->name, "cacert")) { } else if (!strcasecmp(v->name, "cacert")) {
if (osp->cacount < MAX_CERTS) { if (osp->cacount < MAX_CERTS) {
if (v->value[0] == '/') if (v->value[0] == '/')
strncpy(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0])); strncpy(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]) - 1);
else else
snprintf(osp->cacerts[osp->cacount], sizeof(osp->cacerts[0]), AST_KEY_DIR "/%s", v->value); snprintf(osp->cacerts[osp->cacount], sizeof(osp->cacerts[0]), AST_KEY_DIR "/%s", v->value);
osp->cacount++; osp->cacount++;
@@ -146,7 +146,7 @@ static int osp_build(struct ast_config *cfg, char *cat)
ast_log(LOG_WARNING, "Too many CA Certificates at line %d\n", v->lineno); ast_log(LOG_WARNING, "Too many CA Certificates at line %d\n", v->lineno);
} else if (!strcasecmp(v->name, "servicepoint")) { } else if (!strcasecmp(v->name, "servicepoint")) {
if (osp->spcount < MAX_SERVICEPOINTS) { if (osp->spcount < MAX_SERVICEPOINTS) {
strncpy(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0])); strncpy(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]) - 1);
osp->spcount++; osp->spcount++;
} else } else
ast_log(LOG_WARNING, "Too many Service points at line %d\n", v->lineno); ast_log(LOG_WARNING, "Too many Service points at line %d\n", v->lineno);
@@ -424,7 +424,7 @@ int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *tim
{ {
char tmp[256]="", *l, *n; char tmp[256]="", *l, *n;
char iabuf[INET_ADDRSTRLEN]; char iabuf[INET_ADDRSTRLEN];
char source[OSP_MAX]; /* Same length as osp->source */ char source[OSP_MAX] = ""; /* Same length as osp->source */
char *token2; char *token2;
int tokenlen; int tokenlen;
struct osp_provider *osp; struct osp_provider *osp;
@@ -459,7 +459,7 @@ int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *tim
if (OSPPTransactionNew(osp->handle, handle)) { if (OSPPTransactionNew(osp->handle, handle)) {
ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n"); ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
} else { } else {
strcpy(source, osp->source); strncpy(source, osp->source, sizeof(source) - 1);
res = 1; res = 1;
} }
break; break;
@@ -491,7 +491,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
unsigned int timelimit; unsigned int timelimit;
unsigned int callidlen; unsigned int callidlen;
struct osp_provider *osp; struct osp_provider *osp;
char source[OSP_MAX]; /* Same length as osp->source */ char source[OSP_MAX] = ""; /* Same length as osp->source */
char uniqueid[32] = ""; char uniqueid[32] = "";
char callednum[2048]=""; char callednum[2048]="";
char destination[2048]=""; char destination[2048]="";
@@ -502,9 +502,9 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
result->handle = -1; result->handle = -1;
result->numresults = 0; result->numresults = 0;
strcpy(result->tech, ""); result->tech[0] = '\0';
strcpy(result->dest, ""); result->dest[0] = '\0';
strcpy(result->token, ""); result->token[0] = '\0';
if (!provider || !strlen(provider)) if (!provider || !strlen(provider))
provider = "default"; provider = "default";
@@ -535,7 +535,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
if (OSPPTransactionNew(osp->handle, &result->handle)) { if (OSPPTransactionNew(osp->handle, &result->handle)) {
ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n"); ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
} else { } else {
strcpy(source, osp->source); strncpy(source, osp->source, sizeof(source) - 1);
res = 1; res = 1;
} }
break; break;
@@ -568,11 +568,11 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
destination[strlen(destination) - 1] = '\0'; destination[strlen(destination) - 1] = '\0';
switch(prot) { switch(prot) {
case OSPE_DEST_PROT_H323_SETUP: case OSPE_DEST_PROT_H323_SETUP:
strcpy(result->tech, "H323"); strncpy(result->tech, "H323", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1); snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break; break;
case OSPE_DEST_PROT_SIP: case OSPE_DEST_PROT_SIP:
strcpy(result->tech, "SIP"); strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1); snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break; break;
default: default:
@@ -626,9 +626,9 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
char token[2000]; char token[2000];
OSPE_DEST_PROT prot; OSPE_DEST_PROT prot;
strcpy(result->tech, ""); result->tech[0] = '\0';
strcpy(result->dest, ""); result->dest[0] = '\0';
strcpy(result->token, ""); result->token[0] = '\0';
if (result->handle > -1) { if (result->handle > -1) {
dummy = 0; dummy = 0;
@@ -646,11 +646,11 @@ int ast_osp_next(struct ast_osp_result *result, int cause)
destination[strlen(destination) - 1] = '\0'; destination[strlen(destination) - 1] = '\0';
switch(prot) { switch(prot) {
case OSPE_DEST_PROT_H323_SETUP: case OSPE_DEST_PROT_H323_SETUP:
strcpy(result->tech, "H323"); strncpy(result->tech, "H323", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1); snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break; break;
case OSPE_DEST_PROT_SIP: case OSPE_DEST_PROT_SIP:
strcpy(result->tech, "SIP"); strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1); snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
break; break;
default: default:

View File

@@ -235,7 +235,7 @@ register struct state * const sp;
** to hold the longest file name string that the implementation ** to hold the longest file name string that the implementation
** guarantees can be opened." ** guarantees can be opened."
*/ */
char fullname[FILENAME_MAX + 1]; char fullname[FILENAME_MAX + 1] = "";
if (name[0] == ':') if (name[0] == ':')
++name; ++name;
@@ -245,9 +245,9 @@ register struct state * const sp;
return -1; return -1;
if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname) if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname)
return -1; return -1;
(void) strcpy(fullname, p); (void) strncpy(fullname, p, sizeof(fullname) - 1);
(void) strcat(fullname, "/"); (void) strncat(fullname, "/", sizeof(fullname) - strlen(fullname) - 1);
(void) strcat(fullname, name); (void) strncat(fullname, name, sizeof(fullname) - strlen(fullname) - 1);
/* /*
** Set doaccess if '.' (as in "../") shows up in name. ** Set doaccess if '.' (as in "../") shows up in name.
*/ */
@@ -929,7 +929,7 @@ ast_tzset P((const char *name))
cur_state->timecnt = 0; cur_state->timecnt = 0;
cur_state->ttis[0].tt_gmtoff = 0; cur_state->ttis[0].tt_gmtoff = 0;
cur_state->ttis[0].tt_abbrind = 0; cur_state->ttis[0].tt_abbrind = 0;
(void) strcpy(cur_state->chars, gmt); (void) strncpy(cur_state->chars, gmt, sizeof(cur_state->chars) - 1);
} else if (tzload(name, cur_state) != 0) { } else if (tzload(name, cur_state) != 0) {
if (name[0] == ':') { if (name[0] == ':') {
(void) gmtload(cur_state); (void) gmtload(cur_state);
@@ -940,7 +940,7 @@ ast_tzset P((const char *name))
(void) gmtload(cur_state); (void) gmtload(cur_state);
} }
} }
strncpy(cur_state->name,name,sizeof(cur_state->name)); strncpy(cur_state->name, name, sizeof(cur_state->name) - 1);
if (last_lclptr) if (last_lclptr)
last_lclptr->next = cur_state; last_lclptr->next = cur_state;
else else

View File

@@ -178,8 +178,8 @@ static struct event {
static int process_message(struct ast_mansession *s, struct message *m) static int process_message(struct ast_mansession *s, struct message *m)
{ {
int x; int x;
char event[80]; char event[80] = "";
strncpy(event, get_header(m, "Event"), sizeof(event)); strncpy(event, get_header(m, "Event"), sizeof(event) - 1);
if (!strlen(event)) { if (!strlen(event)) {
fprintf(stderr, "Missing event in request"); fprintf(stderr, "Missing event in request");
return 0; return 0;