FreeTDM: Add gcc printf()-style format string checks to ftdm_log(), also add FTDM_(U)INT64_FMT and FTDM_TIME_FMT constants.

The format string checks already caught a couple crash-worthy bugs and this
commit fixes a couple more.

Also includes __ftdm_check_scanf(), for completeness (currently unused).

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
Stefan Knoblich committed 2012-07-11 22:44:08 +02:00
1 parent 1e7d214ae6
commit f384e247fc
7 files changed
+48 -7

No files matched your search

@@ -1221,7 +1221,7 @@ static int on_info(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event
ftdm_caller_data_t *caller_data = NULL;
if (!chan) {
ftdm_log(FTDM_LOG_CRIT, "-- Info on channel %d:%d %s but it's not in use?\n", ftdm_span_get_id(span), pevent->ring.channel);
ftdm_log(FTDM_LOG_CRIT, "-- Info on channel %d:%d but it's not in use?\n", ftdm_span_get_id(span), pevent->ring.channel);
return 0;
}
@@ -1284,7 +1284,7 @@ static int on_hangup(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_even
ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->hangup.channel);
if (!chan) {
ftdm_log(FTDM_LOG_CRIT, "-- Hangup on channel %d:%d %s but it's not in use?\n", ftdm_span_get_id(spri->span), pevent->hangup.channel);
ftdm_log(FTDM_LOG_CRIT, "-- Hangup on channel %d:%d but it's not in use?\n", ftdm_span_get_id(spri->span), pevent->hangup.channel);
return 0;
}
@@ -1143,7 +1143,7 @@ static ftdm_status_t misdn_handle_incoming(ftdm_channel_t *ftdmchan, const char
assert(priv);
if (msg_len < sizeof(*hh)) {
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN message to small (%d < %d bytes)\n",
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "mISDN message to small (%d < %"FTDM_SIZE_FMT" bytes)\n",
msg_len, sizeof(*hh));
return FTDM_FAIL;
}