diff options
41 files changed, 179 insertions, 144 deletions
@@ -228,7 +228,13 @@ endif ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) ifeq ($(AST_DEVMODE),yes) - ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2 + ASTCFLAGS+=-Werror + ASTCFLAGS+=-Wunused + ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT) + ASTCFLAGS+=$(AST_FORTIFY_SOURCE) + ASTCFLAGS+=-Wundef + ASTCFLAGS+=-Wmissing-format-attribute + ASTCFLAGS+=-Wformat=2 endif ifneq ($(findstring BSD,$(OSARCH)),) diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c index d96c11235..ea4515cb3 100644 --- a/cdr/cdr_tds.c +++ b/cdr/cdr_tds.c @@ -103,7 +103,7 @@ static char *anti_injection(const char *, int); static void get_date(char *, size_t len, struct timeval); static int execute_and_consume(DBPROCESS *dbproc, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); static int mssql_connect(void); static int mssql_disconnect(void); diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 9e93d9d08..ebfa11147 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -1012,7 +1012,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state) } #endif if (p->pending) - tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/P%s-%d", p->agent, ast_random() & 0xffff); + tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/P%s-%d", p->agent, (int) ast_random() & 0xffff); else tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/%s", p->agent); if (!tmp) { diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index 47b48beeb..772b48a9c 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -285,7 +285,7 @@ static pthread_t misdn_tasks_thread; static int *misdn_ports; static void chan_misdn_log(int level, int port, char *tmpl, ...) - __attribute__ ((format (printf, 3, 4))); + __attribute__((format(printf, 3, 4))); static struct ast_channel *misdn_new(struct chan_list *cl, int state, char *exten, char *callerid, int format, int port, int c); static void send_digit_to_chan(struct chan_list *cl, char digit ); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 61588db4d..a2a9217be 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2331,7 +2331,7 @@ static struct ast_udptl_protocol sip_udptl = { }; static void append_history_full(struct sip_pvt *p, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); /*! \brief Convert transfer status to string */ @@ -2628,9 +2628,9 @@ static void build_via(struct sip_pvt *p) /* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */ ast_string_field_build(p, via, "SIP/2.0/%s %s:%d;branch=z9hG4bK%08x%s", - get_transport_pvt(p), - ast_inet_ntoa(p->ourip.sin_addr), - ntohs(p->ourip.sin_port), p->branch, rport); + get_transport_pvt(p), + ast_inet_ntoa(p->ourip.sin_addr), + ntohs(p->ourip.sin_port), (int) p->branch, rport); } /*! \brief NAT fix - decide which IP address to use for Asterisk server? @@ -2691,7 +2691,7 @@ static void ast_sip_ouraddrfor(struct in_addr *them, struct sockaddr_in *us) } /*! \brief Append to SIP dialog history with arg list */ -static __attribute__((format (printf, 2, 0))) void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap) +static __attribute__((format(printf, 2, 0))) void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap) { char buf[80], *c = buf; /* max history length */ struct sip_history *hist; diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc index df7dfc2aa..92b2919a4 100644 --- a/channels/chan_vpb.cc +++ b/channels/chan_vpb.cc @@ -2486,7 +2486,7 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st } ast_verb(4, "%s: New call for context [%s]\n", me->dev, context); - tmp = ast_channel_alloc(1, state, 0, 0, "", me->ext, me->context, 0, me->dev); + tmp = ast_channel_alloc(1, state, 0, 0, "", me->ext, me->context, 0, "%s", me->dev); if (tmp) { if (use_ast_ind == 1){ tmp->tech = &vpb_tech_indicate; diff --git a/channels/misdn/ie.c b/channels/misdn/ie.c index fbd06d163..dc9802845 100644 --- a/channels/misdn/ie.c +++ b/channels/misdn/ie.c @@ -1347,7 +1347,7 @@ static void enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, ch i = 0; while(i < user_len) { - if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", user[i]); + if (MISDN_IE_DEBG) sprintf(debug+(i*3), " %02x", user[i]); i++; } @@ -1393,7 +1393,7 @@ static void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, ch i = 0; while(i < *user_len) { - if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", user[i]); + if (MISDN_IE_DEBG) sprintf(debug+(i*3), " %02x", user[i]); i++; } debug[i*3] = '\0'; diff --git a/channels/misdn_config.c b/channels/misdn_config.c index 38b77fddd..d65250895 100644 --- a/channels/misdn_config.c +++ b/channels/misdn_config.c @@ -885,12 +885,14 @@ static int _parse (union misdn_cfg_pt *dest, const char *value, enum misdn_cfg_t break; case MISDN_CTYPE_INT: { - char *pat; - if (strchr(value,'x')) - pat="%x"; - else - pat="%d"; - if (sscanf(value, pat, &tmp)) { + int res; + + if (strchr(value,'x')) { + res = sscanf(value, "%x", &tmp); + } else { + res = sscanf(value, "%d", &tmp); + } + if (res) { dest->num = ast_malloc(sizeof(int)); memcpy(dest->num, &tmp, sizeof(int)); } else @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 153745 . +# From configure.ac Revision: 157601 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for asterisk 1.6. # @@ -954,6 +954,7 @@ PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP GC_CFLAGS GC_LDFLAGS AST_DECLARATION_AFTER_STATEMENT +AST_FORTIFY_SOURCE AST_NO_STRICT_OVERFLOW PBX_RTLD_NOLOAD PBX_IP_MTU_DISCOVER @@ -12883,11 +12884,13 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include <stdio.h> +#include <sys/types.h> /* for off_t */ + #include <stdio.h> int main () { -return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } @@ -12927,11 +12930,13 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 -#include <stdio.h> +#include <sys/types.h> /* for off_t */ + #include <stdio.h> int main () { -return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } @@ -17184,6 +17189,19 @@ echo "${ECHO_T}no" >&6; } fi +{ echo "$as_me:$LINENO: checking for _FORTIFY_SOURCE support" >&5 +echo $ECHO_N "checking for _FORTIFY_SOURCE support... $ECHO_C" >&6; } +if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2 +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + AST_FORTIFY_SOURCE= +fi + + { echo "$as_me:$LINENO: checking for -fno-strict-overflow" >&5 echo $ECHO_N "checking for -fno-strict-overflow... $ECHO_C" >&6; } if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then @@ -50367,6 +50385,7 @@ PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP!$PBX_PTHREAD_RECURSIVE_MUTEX_INITIALI GC_CFLAGS!$GC_CFLAGS$ac_delim GC_LDFLAGS!$GC_LDFLAGS$ac_delim AST_DECLARATION_AFTER_STATEMENT!$AST_DECLARATION_AFTER_STATEMENT$ac_delim +AST_FORTIFY_SOURCE!$AST_FORTIFY_SOURCE$ac_delim AST_NO_STRICT_OVERFLOW!$AST_NO_STRICT_OVERFLOW$ac_delim PBX_RTLD_NOLOAD!$PBX_RTLD_NOLOAD$ac_delim PBX_IP_MTU_DISCOVER!$PBX_IP_MTU_DISCOVER$ac_delim @@ -50397,7 +50416,7 @@ CURL_CONFIG!$CURL_CONFIG$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 72; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 73; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.ac b/configure.ac index b882d9440..a6d722f72 100644 --- a/configure.ac +++ b/configure.ac @@ -492,6 +492,16 @@ else fi AC_SUBST(AST_DECLARATION_AFTER_STATEMENT) +AC_MSG_CHECKING(for _FORTIFY_SOURCE support) +if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then + AC_MSG_RESULT(yes) + AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2 +else + AC_MSG_RESULT(no) + AST_FORTIFY_SOURCE= +fi +AC_SUBST(AST_FORTIFY_SOURCE) + AC_MSG_CHECKING(for -fno-strict-overflow) if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) diff --git a/funcs/Makefile b/funcs/Makefile index 9b13b17a0..5795f9837 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -18,3 +18,5 @@ MENUSELECT_DESCRIPTION=Dialplan Functions all: _all include $(ASTTOPDIR)/Makefile.moddir_rules + +func_strings.o: ASTCFLAGS+=-Wno-format-nonliteral diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h index 5d0d47ff5..553587942 100644 --- a/include/asterisk/astmm.h +++ b/include/asterisk/astmm.h @@ -51,9 +51,9 @@ void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *__ast_strdup(const char *s, const char *file, int lineno, const char *func); char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func); int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) - __attribute__ ((format (printf, 5, 6))); + __attribute__((format(printf, 5, 6))); int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) - __attribute__ ((format (printf, 2, 0))); + __attribute__((format(printf, 2, 0))); void __ast_mm_init(void); diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 324fab996..1b67f0a13 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -727,7 +727,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state); * \note By default, new channels are set to the "s" extension * and "default" context. */ -struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...); +struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...) __attribute__((format(printf, 9, 10))); /*! * \brief Queue an outgoing frame diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index 854c189ff..7e50e3392 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -30,7 +30,7 @@ extern "C" { #include "asterisk/linkedlists.h" void ast_cli(int fd, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); #define RESULT_SUCCESS 0 #define RESULT_SHOWUSAGE 1 diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h index e481fbec4..41e5a6b8f 100644 --- a/include/asterisk/compat.h +++ b/include/asterisk/compat.h @@ -74,7 +74,7 @@ #endif #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) -int __attribute__ ((format (printf, 2, 3))) asprintf(char **str, const char *fmt, ...); +int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...); #endif #ifndef HAVE_GETLOADAVG @@ -110,7 +110,7 @@ int unsetenv(const char *name); #endif #if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) -int __attribute__ ((format (printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap); +int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap); #endif #ifndef HAVE_STRLCAT diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h index d52430301..1b7cdd4c8 100644 --- a/include/asterisk/devicestate.h +++ b/include/asterisk/devicestate.h @@ -127,7 +127,7 @@ enum ast_device_state ast_device_state(const char *device); * \retval -1 on failure */ int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format(printf, 2, 3))); /*! * \brief Tells Asterisk the State for Device is changed @@ -158,7 +158,7 @@ int ast_devstate_changed_literal(enum ast_device_state state, const char *device * \note This is deprecated in favor of ast_devstate_changed() */ int ast_device_state_changed(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); + __attribute__((format(printf, 1, 2))); /*! * \brief Tells Asterisk the State for Device is changed diff --git a/include/asterisk/dundi.h b/include/asterisk/dundi.h index e588338ae..2e9f822fd 100644 --- a/include/asterisk/dundi.h +++ b/include/asterisk/dundi.h @@ -43,13 +43,13 @@ struct dundi_hdr { unsigned char cmdresp; /*!< Command / Response */ unsigned char cmdflags; /*!< Command / Response specific flags*/ unsigned char ies[0]; -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); struct dundi_ie_hdr { unsigned char ie; unsigned char len; unsigned char iedata[0]; -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); #define DUNDI_FLAG_RETRANS (1 << 16) /*!< Applies to dtrans */ #define DUNDI_FLAG_RESERVED (1 << 16) /*!< Applies to strans */ @@ -78,7 +78,7 @@ struct dundi_ie_hdr { struct dundi_encblock { /*!< AES-128 encrypted block */ unsigned char iv[16]; /*!< Initialization vector of random data */ unsigned char encdata[0]; /*!< Encrypted / compressed data */ -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); struct dundi_answer { dundi_eid eid; /*!< Original source of answer */ @@ -86,12 +86,12 @@ struct dundi_answer { unsigned short flags; /*!< Flags relating to answer */ unsigned short weight; /*!< Weight of answers */ unsigned char data[0]; /*!< Protocol specific URI */ -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); struct dundi_hint { unsigned short flags; /*!< Flags relating to answer */ unsigned char data[0]; /*!< For data for hint */ -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); #define DUNDI_CAUSE_SUCCESS 0 /*!< Success */ #define DUNDI_CAUSE_GENERAL 1 /*!< General unspecified failure */ @@ -105,14 +105,14 @@ struct dundi_hint { struct dundi_cause { unsigned char causecode; /*!< Numerical cause (DUNDI_CAUSE_*) */ char desc[0]; /*!< Textual description */ -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); struct dundi_peer_status { unsigned int flags; unsigned short netlag; unsigned short querylag; dundi_eid peereid; -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); #define DUNDI_PEER_PRIMARY (1 << 0) #define DUNDI_PEER_SECONDARY (1 << 1) diff --git a/include/asterisk/enum.h b/include/asterisk/enum.h index d6bbea294..84e8797d5 100644 --- a/include/asterisk/enum.h +++ b/include/asterisk/enum.h @@ -28,7 +28,7 @@ struct naptr { unsigned short order; unsigned short pref; -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); struct enum_naptr_rr { struct naptr naptr; /*!< order and preference of RR */ diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 1f3285dfa..ff23e8f1b 100644 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -248,11 +248,11 @@ struct name { \ struct type *last; \ ast_mutex_t lock; \ } name; \ -static void __attribute__ ((constructor)) __init_##name(void) \ +static void __attribute__((constructor)) __init_##name(void) \ { \ AST_LIST_HEAD_INIT(&name); \ } \ -static void __attribute__ ((destructor)) __fini_##name(void) \ +static void __attribute__((destructor)) __fini_##name(void) \ { \ AST_LIST_HEAD_DESTROY(&name); \ } \ @@ -290,11 +290,11 @@ struct name { \ struct type *last; \ ast_rwlock_t lock; \ } name; \ -static void __attribute__ ((constructor)) __init_##name(void) \ +static void __attribute__((constructor)) __init_##name(void) \ { \ AST_RWLIST_HEAD_INIT(&name); \ } \ -static void __attribute__ ((destructor)) __fini_##name(void) \ +static void __attribute__((destructor)) __fini_##name(void) \ { \ AST_RWLIST_HEAD_DESTROY(&name); \ } \ diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index d76aa932f..cab62f4dd 100644 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -58,15 +58,14 @@ extern "C" { */ void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) - __attribute__ ((format (printf, 5, 6))); + __attribute__((format(printf, 5, 6))); void ast_backtrace(void); /*! \brief Reload logger without rotating log files */ int logger_reload(void); -void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...) - __attribute__ ((format (printf, 5, 6))); +void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...); /*! Send a verbose message (based on verbose level) \brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set. diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index ecc047829..4bd071f4d 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -179,7 +179,7 @@ int astman_verify_session_writepermissions(uint32_t ident, int perm); #define manager_event(category, event, contents , ...) \ __manager_event(category, event, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) -int __attribute__ ((format(printf, 6, 7))) __manager_event(int category, const char *event, +int __attribute__((format(printf, 6, 7))) __manager_event(int category, const char *event, const char *file, int line, const char *func, const char *contents, ...); @@ -201,7 +201,7 @@ void astman_send_ack(struct mansession *s, const struct message *m, char *msg); /*! \brief Send ack in manager list transaction */ void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag); -void __attribute__ ((format (printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...); +void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...); /*! \brief Determinie if a manager session ident is authenticated */ int astman_is_authed(uint32_t ident); diff --git a/include/asterisk/module.h b/include/asterisk/module.h index bb58cb268..c30325294 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -250,11 +250,11 @@ void ast_module_unref(struct ast_module *); flags_to_set, \ AST_BUILDOPT_SUM, \ }; \ - static void __attribute__ ((constructor)) __reg_module(void) \ + static void __attribute__((constructor)) __reg_module(void) \ { \ ast_module_register(&__mod_info); \ } \ - static void __attribute__ ((destructor)) __unreg_module(void) \ + static void __attribute__((destructor)) __unreg_module(void) \ { \ ast_module_unregister(&__mod_info); \ } \ @@ -344,11 +344,11 @@ static void __restore_globals(void) .buildopt_sum = AST_BUILDOPT_SUM, \ fields \ }; \ - static void __attribute__ ((constructor)) __reg_module(void) \ + static void __attribute__((constructor)) __reg_module(void) \ { \ ast_module_register(&__mod_info); \ } \ - static void __attribute__ ((destructor)) __unreg_module(void) \ + static void __attribute__((destructor)) __unreg_module(void) \ { \ ast_module_unregister(&__mod_info); \ } \ diff --git a/include/asterisk/res_odbc.h b/include/asterisk/res_odbc.h index 1defc816b..6a2bc7000 100644 --- a/include/asterisk/res_odbc.h +++ b/include/asterisk/res_odbc.h @@ -64,7 +64,7 @@ struct odbc_obj { * This function really only ever worked with MySQL, where the statement handle is * not prepared on the server. If you are not using MySQL, you should avoid it. */ -int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) __attribute__ ((deprecated)); +int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) __attribute__((deprecated)); /*! * \brief Retrieves a connected ODBC object diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h index b0cda6902..4b1847415 100644 --- a/include/asterisk/stringfields.h +++ b/include/asterisk/stringfields.h @@ -183,7 +183,7 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr */ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, - const ast_string_field *ptr, const char *format, ...); + const ast_string_field *ptr, const char *format, ...) __attribute((format(printf, 4, 5))); /*! \internal @@ -198,7 +198,7 @@ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, */ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, - const ast_string_field *ptr, const char *format, va_list a1, va_list a2); + const ast_string_field *ptr, const char *format, va_list a1, va_list a2) __attribute((format(printf, 4, 0))); /*! \brief Declare a string field diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 4f5e326cf..8de2695ba 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -221,7 +221,7 @@ void ast_copy_string(char *dst, const char *src, size_t size), \retval 0 on success \retval non-zero on failure. */ -int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); +int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attribute__((format(printf, 3, 4))); /*! \brief Build a string in a buffer, designed to be called repeatedly @@ -235,7 +235,7 @@ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attri \param fmt printf-style format string \param ap varargs list of arguments for format */ -int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap) __attribute__((format (printf, 3, 0))); +int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap) __attribute__((format(printf, 3, 0))); /*! * \brief Make sure something is true. @@ -630,8 +630,8 @@ enum { * through calling one of the other functions or macros defined in this * file. */ -int __ast_str_helper(struct ast_str **buf, size_t max_len, - int append, const char *fmt, va_list ap); +int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len, + int append, const char *fmt, va_list ap); /*! * \brief Set a dynamic string using variable arguments @@ -651,7 +651,7 @@ int __ast_str_helper(struct ast_str **buf, size_t max_len, * All the rest is the same as ast_str_set_va() */ AST_INLINE_API( -int __attribute__ ((format (printf, 3, 4))) ast_str_set( +int __attribute__((format(printf, 3, 4))) ast_str_set( struct ast_str **buf, size_t max_len, const char *fmt, ...), { int res; @@ -672,7 +672,7 @@ int __attribute__ ((format (printf, 3, 4))) ast_str_set( * ast_str_set(), but the new data is appended to the current value. */ AST_INLINE_API( -int __attribute__ ((format (printf, 3, 4))) ast_str_append( +int __attribute__((format(printf, 3, 4))) ast_str_append( struct ast_str **buf, size_t max_len, const char *fmt, ...), { int res; diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index b038711f3..d6b00b347 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -554,7 +554,7 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi #define ast_asprintf(ret, fmt, ...) \ _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) -int __attribute__((format (printf, 5, 6))) +int __attribute__((format(printf, 5, 6))) _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...); /*! @@ -569,7 +569,7 @@ int __attribute__((format (printf, 5, 6))) _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) AST_INLINE_API( -__attribute__((format (printf, 5, 0))) +__attribute__((format(printf, 5, 0))) int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap), { int res; diff --git a/include/jitterbuf.h b/include/jitterbuf.h index 00f26e21c..6da11a65b 100644 --- a/include/jitterbuf.h +++ b/include/jitterbuf.h @@ -163,7 +163,7 @@ enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats); /*! \brief set jitterbuf conf */ enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf); -typedef void __attribute__((format (printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...); +typedef void __attribute__((format(printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...); void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg); #ifdef __cplusplus diff --git a/main/Makefile b/main/Makefile index fe9caa967..14fa19ae6 100644 --- a/main/Makefile +++ b/main/Makefile @@ -140,7 +140,7 @@ ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),) http.o: ASTCFLAGS+=$(GMIME_INCLUDE) endif -stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) +stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS)) AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep))) diff --git a/main/ast_expr2.c b/main/ast_expr2.c index 2534938b2..147604380 100644 --- a/main/ast_expr2.c +++ b/main/ast_expr2.c @@ -360,7 +360,7 @@ enum valtype { } ; #ifdef STANDALONE -void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6))); +void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf,5,6))); #endif struct val { diff --git a/main/dns.c b/main/dns.c index ad1673830..66c21b367 100644 --- a/main/dns.c +++ b/main/dns.c @@ -156,7 +156,7 @@ struct dn_answer { unsigned short class; unsigned int ttl; unsigned short size; -} __attribute__ ((__packed__)); +} __attribute__((__packed__)); static int skip_name(unsigned char *s, int len) { diff --git a/main/event.c b/main/event.c index 0d139c51a..17a25d25f 100644 --- a/main/event.c +++ b/main/event.c @@ -50,7 +50,7 @@ struct ast_event_ie { /*! Total length of the IE payload */ uint16_t ie_payload_len; unsigned char ie_payload[0]; -} __attribute__ ((packed)); +} __attribute__((packed)); /*! * \brief An event @@ -70,7 +70,7 @@ struct ast_event { uint16_t event_len:16; /*! The data payload of the event, made up of information elements */ unsigned char payload[0]; -} __attribute__ ((packed)); +} __attribute__((packed)); struct ast_event_ref { struct ast_event *event; diff --git a/main/features.c b/main/features.c index 493cf569d..21dbcb09b 100644 --- a/main/features.c +++ b/main/features.c @@ -231,7 +231,7 @@ static void check_goto_on_transfer(struct ast_channel *chan) goto_on_transfer = ast_strdupa(val); - if (!(xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, chan->name))) + if (!(xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "%s", chan->name))) return; for (x = goto_on_transfer; x && *x; x++) { diff --git a/main/srv.c b/main/srv.c index 1899e8b8f..664062b64 100644 --- a/main/srv.c +++ b/main/srv.c @@ -73,7 +73,7 @@ static int parse_srv(unsigned char *answer, int len, unsigned char *msg, struct unsigned short priority; unsigned short weight; unsigned short port; - } __attribute__ ((__packed__)) *srv = (struct srv *) answer; + } __attribute__((__packed__)) *srv = (struct srv *) answer; int res = 0; char repl[256] = ""; diff --git a/main/utils.c b/main/utils.c index f99ff8545..cb68cdc47 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1430,7 +1430,6 @@ int __ast_string_field_ptr_grow(struct ast_string_field_mgr *mgr, size_t needed, return 0; } -__attribute((format (printf, 4, 0))) void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, const ast_string_field *ptr, const char *format, va_list ap1, va_list ap2) @@ -1462,7 +1461,6 @@ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, mgr->used += needed; } -__attribute((format (printf, 4, 5))) void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, const ast_string_field *ptr, const char *format, ...) @@ -1554,7 +1552,6 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed) * ast_str_append_va(...) */ -__attribute__((format (printf, 4, 0))) int __ast_str_helper(struct ast_str **buf, size_t max_len, int append, const char *fmt, va_list ap) { diff --git a/makeopts.in b/makeopts.in index 7606f9410..018bc6cbd 100644 --- a/makeopts.in +++ b/makeopts.in @@ -66,6 +66,7 @@ AST_DEVMODE=@AST_DEVMODE@ AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@ AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@ +AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@ ASOUND_INCLUDE=@ALSA_INCLUDE@ ASOUND_LIB=@ALSA_LIB@ diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c index f0ec4f92a..1825218aa 100644 --- a/res/res_config_sqlite.c +++ b/res/res_config_sqlite.c @@ -77,7 +77,6 @@ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - #include <sqlite.h> #include "asterisk/logger.h" @@ -524,46 +523,46 @@ static char *sql_create_cdr_table = ");"; /*! SQL query format to insert a CDR entry. */ -static char *sql_add_cdr_entry = -"INSERT INTO '%q' (" -" clid," -" src," -" dst," -" dcontext," -" channel," -" dstchannel," -" lastapp," -" lastdata," -" start," -" answer," -" end," -" duration," -" billsec," -" disposition," -" amaflags," -" accountcode," -" uniqueid," -" userfield" -") VALUES (" -" '%q'," -" '%q'," -" '%q'," -" '%q'," -" '%q'," -" '%q'," -" '%q'," -" '%q'," -" datetime(%d,'unixepoch','localtime')," -" datetime(%d,'unixepoch','localtime')," -" datetime(%d,'unixepoch','localtime')," -" '%ld'," -" '%ld'," -" '%ld'," -" '%ld'," -" '%q'," -" '%q'," -" '%q'" -");"; +#define sql_add_cdr_entry \ + "INSERT INTO '%q' (" \ + " clid," \ + " src," \ + " dst," \ + " dcontext," \ + " channel," \ + " dstchannel," \ + " lastapp," \ + " lastdata," \ + " start," \ + " answer," \ + " end," \ + " duration," \ + " billsec," \ + " disposition," \ + " amaflags," \ + " accountcode," \ + " uniqueid," \ + " userfield" \ + ") VALUES (" \ + " '%q'," \ + " '%q'," \ + " '%q'," \ + " '%q'," \ + " '%q'," \ + " '%q'," \ + " '%q'," \ + " '%q'," \ + " datetime(%d,'unixepoch','localtime')," \ + " datetime(%d,'unixepoch','localtime')," \ + " datetime(%d,'unixepoch','localtime')," \ + " '%ld'," \ + " '%ld'," \ + " '%ld'," \ + " '%ld'," \ + " '%q'," \ + " '%q'," \ + " '%q'" \ + ");" /*! * SQL query format to fetch the static configuration of a file. @@ -571,11 +570,11 @@ static char *sql_add_cdr_entry = * * \see add_cfg_entry() */ -static char *sql_get_config_table = -"SELECT *" -" FROM '%q'" -" WHERE filename = '%q' AND commented = 0" -" ORDER BY cat_metric ASC, var_metric ASC;"; +#define sql_get_config_table \ + "SELECT *" \ + " FROM '%q'" \ + " WHERE filename = '%q' AND commented = 0" \ + " ORDER BY cat_metric ASC, var_metric ASC;" static int set_var(char **var, const char *name, const char *value) { diff --git a/utils/astman.c b/utils/astman.c index 9c659cd86..71956410b 100644 --- a/utils/astman.c +++ b/utils/astman.c @@ -147,7 +147,7 @@ static void del_chan(char *name) } -static void __attribute__((format (printf, 2, 3))) fdprintf(int fd, char *fmt, ...) +static void __attribute__((format(printf, 2, 3))) fdprintf(int fd, char *fmt, ...) { char stuff[4096]; va_list ap; @@ -417,7 +417,7 @@ static struct message *wait_for_response(int timeout) } -static int __attribute__((format (printf, 2, 3))) manager_action(char *action, char *fmt, ...) +static int __attribute__((format(printf, 2, 3))) manager_action(char *action, char *fmt, ...) { struct ast_mansession *s; char tmp[4096]; diff --git a/utils/check_expr.c b/utils/check_expr.c index 7b013f163..7dab4f23a 100644 --- a/utils/check_expr.c +++ b/utils/check_expr.c @@ -40,7 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") * ast_str_set_va(...) * ast_str_append_va(...) */ -int __attribute__((format (printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len, +int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len, int append, const char *fmt, va_list ap) { int res, need; @@ -125,7 +125,7 @@ struct varz *global_varlist; /* Our own version of ast_log, since the expr parser uses it. */ -void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6))); +void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf,5,6))); void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) { diff --git a/utils/conf2ael.c b/utils/conf2ael.c index 03d7105d6..9957078d0 100644 --- a/utils/conf2ael.c +++ b/utils/conf2ael.c @@ -92,7 +92,7 @@ void ast_unregister_file_version(const char *file) int ast_add_profile(const char *x, uint64_t scale) { return 0;} #endif /* Our own version of ast_log, since the expr parser uses it. -- stolen from utils/check_expr.c */ -void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6))); +void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf,5,6))); void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) { diff --git a/utils/extconf.c b/utils/extconf.c index 5003a5c6a..d595c2c7b 100644 --- a/utils/extconf.c +++ b/utils/extconf.c @@ -89,10 +89,10 @@ struct ast_channel void ast_backtrace(void); void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...) - __attribute__ ((format (printf, 5, 6))); + __attribute__((format(printf, 5, 6))); /* IN CONFLICT: void ast_verbose(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); */ + __attribute__((format(printf, 1, 2))); */ int ast_register_verbose(void (*verboser)(const char *string)); int ast_unregister_verbose(void (*verboser)(const char *string)); @@ -666,11 +666,11 @@ static inline int ast_cond_timedwait(ast_cond_t *cond, ast_mutex_t *t, const str constructors/destructors to create/destroy mutexes. */ #define __AST_MUTEX_DEFINE(scope, mutex) \ scope ast_mutex_t mutex = AST_MUTEX_INIT_VALUE; \ -static void __attribute__ ((constructor)) init_##mutex(void) \ +static void __attribute__((constructor)) init_##mutex(void) \ { \ ast_mutex_init(&mutex); \ } \ -static void __attribute__ ((destructor)) fini_##mutex(void) \ +static void __attribute__((destructor)) fini_##mutex(void) \ { \ ast_mutex_destroy(&mutex); \ } @@ -754,11 +754,11 @@ static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock) #ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER #define __AST_RWLOCK_DEFINE(scope, rwlock) \ scope ast_rwlock_t rwlock; \ -static void __attribute__ ((constructor)) init_##rwlock(void) \ +static void __attribute__((constructor)) init_##rwlock(void) \ { \ ast_rwlock_init(&rwlock); \ } \ -static void __attribute__ ((destructor)) fini_##rwlock(void) \ +static void __attribute__((destructor)) fini_##rwlock(void) \ { \ ast_rwlock_destroy(&rwlock); \ } @@ -1074,7 +1074,7 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) AST_INLINE_API( -__attribute__((format (printf, 5, 6))) +__attribute__((format(printf, 5, 6))) int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...), { int res; @@ -1101,7 +1101,7 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) AST_INLINE_API( -__attribute__((format (printf, 5, 0))) +__attribute__((format(printf, 5, 0))) int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap), { int res; @@ -2014,11 +2014,11 @@ struct name { \ struct type *last; \ ast_mutex_t lock; \ } name; \ -static void __attribute__ ((constructor)) init_##name(void) \ +static void __attribute__((constructor)) init_##name(void) \ { \ AST_LIST_HEAD_INIT(&name); \ } \ -static void __attribute__ ((destructor)) fini_##name(void) \ +static void __attribute__((destructor)) fini_##name(void) \ { \ AST_LIST_HEAD_DESTROY(&name); \ } \ @@ -2056,11 +2056,11 @@ struct name { \ struct type *last; \ ast_rwlock_t lock; \ } name; \ -static void __attribute__ ((constructor)) init_##name(void) \ +static void __attribute__((constructor)) init_##name(void) \ { \ AST_RWLIST_HEAD_INIT(&name); \ } \ -static void __attribute__ ((destructor)) fini_##name(void) \ +static void __attribute__((destructor)) fini_##name(void) \ { \ AST_RWLIST_HEAD_DESTROY(&name); \ } \ @@ -2671,7 +2671,7 @@ static void ast_log(int level, const char *file, int line, const char *function, va_end(vars); } -void __attribute__((format (printf, 1, 2))) ast_verbose(const char *fmt, ...) +void __attribute__((format(printf, 1, 2))) ast_verbose(const char *fmt, ...) { va_list vars; va_start(vars,fmt); diff --git a/utils/frame.c b/utils/frame.c index c598f57cb..67fa8483e 100644 --- a/utils/frame.c +++ b/utils/frame.c @@ -968,7 +968,7 @@ int workloop( FILE *theinfile, FILE *theoutfile, return TRUE; /* Input file done with, no errors. */ } -int __attribute__((format (printf,1,2))) chat( const char *format, ...) +int __attribute__((format(printf,1,2))) chat( const char *format, ...) { va_list ap; int result = 0; @@ -982,7 +982,7 @@ int __attribute__((format (printf,1,2))) chat( const char *format, ...) return result; } -int __attribute__((format (printf,1,2))) inform( const char *format, ...) +int __attribute__((format(printf,1,2))) inform( const char *format, ...) { va_list ap; int result = 0; @@ -996,7 +996,7 @@ int __attribute__((format (printf,1,2))) inform( const char *format, ...) return result; } -int __attribute__((format (printf,1,2))) error( const char *format, ...) +int __attribute__((format(printf,1,2))) error( const char *format, ...) { va_list ap; int result; @@ -1007,7 +1007,7 @@ int __attribute__((format (printf,1,2))) error( const char *format, ...) return result; } -void __attribute__((format (printf,1,2))) fatalerror( const char *format, ...) +void __attribute__((format(printf,1,2))) fatalerror( const char *format, ...) { va_list ap; @@ -1023,7 +1023,7 @@ void fatalperror( const char *string) myexit( 1); } -int __attribute__((format (printf,1,2))) say( const char *format, ...) +int __attribute__((format(printf,1,2))) say( const char *format, ...) { va_list ap; int result; |