From 939551ec97073ec1a63da461b904c903671108b4 Mon Sep 17 00:00:00 2001 From: Thomas Ries Date: Wed, 10 Feb 2021 21:21:50 +0100 Subject: [PATCH] eliminated more compiler warnings --- src/accessctl.c | 2 -- src/auth.c | 2 -- src/custom_fw_module.c | 2 -- src/dejitter.c | 2 -- src/fwapi.c | 2 -- src/log.c | 2 -- src/plugin_blacklist.c | 4 +--- src/plugin_codecfilter.c | 2 -- src/plugin_defaulttarget.c | 2 -- src/plugin_demo.c | 3 --- src/plugin_fix_DTAG.c | 2 -- src/plugin_fix_bogus_via.c | 2 -- src/plugin_fix_fbox_anoncall.c | 2 -- src/plugin_logcall.c | 2 -- src/plugin_prefix.c | 2 -- src/plugin_regex.c | 2 -- src/plugin_shortdial.c | 2 -- src/plugin_siptrunk.c | 2 -- src/plugin_stats.c | 3 --- src/plugin_stripheader.c | 2 -- src/plugin_stun.c | 2 -- src/plugins.c | 2 -- src/proxy.c | 2 -- src/readconf.c | 2 -- src/redirect_cache.c | 2 -- src/register.c | 26 ++++++++++++-------------- src/resolve.c | 3 --- src/route_processing.c | 2 -- src/rtpproxy.c | 2 -- src/rtpproxy_relay.c | 30 ++++++++++++++++++++++++------ src/security.c | 2 -- src/sip_layer.c | 2 -- src/sip_utils.c | 8 +++----- src/siproxd.c | 2 -- src/siproxd.h | 2 +- src/sock.c | 18 +++++++++++++----- src/utils.c | 2 -- 37 files changed, 54 insertions(+), 99 deletions(-) diff --git a/src/accessctl.c b/src/accessctl.c index 1075679..bfc484e 100644 --- a/src/accessctl.c +++ b/src/accessctl.c @@ -31,8 +31,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; diff --git a/src/auth.c b/src/auth.c index 08696f4..33ff0ee 100644 --- a/src/auth.c +++ b/src/auth.c @@ -37,8 +37,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; diff --git a/src/custom_fw_module.c b/src/custom_fw_module.c index 87562a2..c16aaa1 100644 --- a/src/custom_fw_module.c +++ b/src/custom_fw_module.c @@ -55,8 +55,6 @@ #include "fwapi.h" #include "log.h" -static char const ident[]="$Id$"; - /* * some prototypes of util.c - so I don't have to suck in the * whole bunch of include files. You probably will not use this diff --git a/src/dejitter.c b/src/dejitter.c index d430008..67120df 100644 --- a/src/dejitter.c +++ b/src/dejitter.c @@ -40,8 +40,6 @@ #include "dejitter.h" -static char const ident[]="$Id$"; - #ifdef GPL /* diff --git a/src/fwapi.c b/src/fwapi.c index be6ecb6..4f75870 100644 --- a/src/fwapi.c +++ b/src/fwapi.c @@ -25,8 +25,6 @@ #include "fwapi.h" #include "log.h" -static char const ident[]="$Id$"; - int fwapi_start_rtp(int rtp_direction, struct in_addr local_ipaddr, int local_port, struct in_addr remote_ipaddr, int remote_port) { diff --git a/src/log.c b/src/log.c index 4bfa578..37cf70e 100644 --- a/src/log.c +++ b/src/log.c @@ -40,8 +40,6 @@ #include -static char const ident[]="$Id$"; - /* static functions */ static void output_to_stderr(const char *label, va_list ap, char *file, int line, const char *format); diff --git a/src/plugin_blacklist.c b/src/plugin_blacklist.c index 26110f8..69ef361 100644 --- a/src/plugin_blacklist.c +++ b/src/plugin_blacklist.c @@ -40,8 +40,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /*&&&+++ Workaround sqlite3 3.3.6 (header/symbol errors)*/ #define sqlite3_clear_bindings UNDEFINED_SYMBOL #define sqlite3_prepare_v2 UNDEFINED_SYMBOL @@ -604,7 +602,7 @@ static int sqlite_begin(void){ /* create prepared statements */ DEBUGC(DBCLASS_BABBLE, "PLUGIN_INIT: preparing %li statements", - sizeof(sql_statement) / sizeof(sql_statement[0])); + (long int)(sizeof(sql_statement) / sizeof(sql_statement[0]))); for (i=0; i < sizeof(sql_statement) / sizeof(sql_statement[0]); i++) { if (sql_statement[i].sql_query == NULL) { DEBUGC(DBCLASS_BABBLE, "PLUGIN_INIT: skiping empty SQL statement"); diff --git a/src/plugin_codecfilter.c b/src/plugin_codecfilter.c index 2d2a6f9..dac8b2f 100644 --- a/src/plugin_codecfilter.c +++ b/src/plugin_codecfilter.c @@ -37,8 +37,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_codecfilter"; static char desc[]="Allows filtering the codec list in SDP"; diff --git a/src/plugin_defaulttarget.c b/src/plugin_defaulttarget.c index 44cf071..9335e51 100644 --- a/src/plugin_defaulttarget.c +++ b/src/plugin_defaulttarget.c @@ -35,8 +35,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_defaulttarget"; static char desc[]="Forwards all unknown calls to a default internal location"; diff --git a/src/plugin_demo.c b/src/plugin_demo.c index c0b72ee..866fbab 100644 --- a/src/plugin_demo.c +++ b/src/plugin_demo.c @@ -35,9 +35,6 @@ #include "plugins.h" #include "log.h" - -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_demo"; static char desc[]="This is just a demo plugin without any purpose"; diff --git a/src/plugin_fix_DTAG.c b/src/plugin_fix_DTAG.c index 712f58c..6c29fbf 100644 --- a/src/plugin_fix_DTAG.c +++ b/src/plugin_fix_DTAG.c @@ -35,8 +35,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_fix_DTAG"; static char desc[]="Fixes issues with DTAG (t-online.de) broken SIP headers"; diff --git a/src/plugin_fix_bogus_via.c b/src/plugin_fix_bogus_via.c index 8e3964e..f712814 100644 --- a/src/plugin_fix_bogus_via.c +++ b/src/plugin_fix_bogus_via.c @@ -36,8 +36,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_fix_bogus_via"; static char desc[]="Fixes broken VIA headers on incoming calls"; diff --git a/src/plugin_fix_fbox_anoncall.c b/src/plugin_fix_fbox_anoncall.c index d36b773..f896974 100644 --- a/src/plugin_fix_fbox_anoncall.c +++ b/src/plugin_fix_fbox_anoncall.c @@ -36,8 +36,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_fix_fbox_anoncall"; static char desc[]="Fixes issues with incoming anonymous calls on Fritzbox UAs"; diff --git a/src/plugin_logcall.c b/src/plugin_logcall.c index ac11766..88c4fcc 100644 --- a/src/plugin_logcall.c +++ b/src/plugin_logcall.c @@ -35,8 +35,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_logcall"; static char desc[]="Logs calls to syslog"; diff --git a/src/plugin_prefix.c b/src/plugin_prefix.c index d53161f..97e8280 100644 --- a/src/plugin_prefix.c +++ b/src/plugin_prefix.c @@ -48,8 +48,6 @@ #include "redirect_cache.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_prefix"; static char desc[]="Adds a dial-prefix as defined in config file"; diff --git a/src/plugin_regex.c b/src/plugin_regex.c index 3459ebb..68cabfb 100644 --- a/src/plugin_regex.c +++ b/src/plugin_regex.c @@ -45,8 +45,6 @@ #include "redirect_cache.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_regex"; static char desc[]="Use regular expressions to rewrite SIP targets"; diff --git a/src/plugin_shortdial.c b/src/plugin_shortdial.c index 4b68e09..a942478 100644 --- a/src/plugin_shortdial.c +++ b/src/plugin_shortdial.c @@ -37,8 +37,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_shortdial"; static char desc[]="Handles Dial shortcuts as defined in config file"; diff --git a/src/plugin_siptrunk.c b/src/plugin_siptrunk.c index 71ab97a..6948717 100644 --- a/src/plugin_siptrunk.c +++ b/src/plugin_siptrunk.c @@ -37,8 +37,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_siptrunk"; static char desc[]="Handles SIP trunks with multiple numbers on same SIP account"; diff --git a/src/plugin_stats.c b/src/plugin_stats.c index 8275c28..08aac84 100644 --- a/src/plugin_stats.c +++ b/src/plugin_stats.c @@ -41,9 +41,6 @@ #include "plugins.h" #include "log.h" - -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_stats"; static char desc[]="Upon receiving SIGUSR1, dump some call statistics"; diff --git a/src/plugin_stripheader.c b/src/plugin_stripheader.c index 78da55c..470b92c 100644 --- a/src/plugin_stripheader.c +++ b/src/plugin_stripheader.c @@ -37,8 +37,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_stripheader"; static char desc[]="Allows removing SIP headers"; diff --git a/src/plugin_stun.c b/src/plugin_stun.c index 929c63c..9cc1040 100644 --- a/src/plugin_stun.c +++ b/src/plugin_stun.c @@ -39,8 +39,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* Plug-in identification */ static char name[]="plugin_stun"; static char desc[]="Use an external STUN server to determine my public IP"; diff --git a/src/plugins.c b/src/plugins.c index 8755638..2ed7790 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -35,8 +35,6 @@ #include "log.h" #include "plugins.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; diff --git a/src/proxy.c b/src/proxy.c index 84434f4..fc1d1ca 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -37,8 +37,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; /* defined in siproxd.c */ diff --git a/src/readconf.c b/src/readconf.c index ed666cb..07e7202 100644 --- a/src/readconf.c +++ b/src/readconf.c @@ -32,8 +32,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; diff --git a/src/redirect_cache.c b/src/redirect_cache.c index 537af9e..fe9b239 100644 --- a/src/redirect_cache.c +++ b/src/redirect_cache.c @@ -35,8 +35,6 @@ #include "redirect_cache.h" #include "log.h" -static char const ident[]="$Id$"; - #define CACHE_TIMEOUT 20 /* diff --git a/src/register.c b/src/register.c index 6ca4983..70dc159 100644 --- a/src/register.c +++ b/src/register.c @@ -35,8 +35,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; @@ -56,7 +54,7 @@ void register_init(void) { FILE *stream; int sts, i; char buff[128]; -// char *c; + char *t; memset(urlmap, 0, sizeof(urlmap)); @@ -74,14 +72,15 @@ void register_init(void) { /* read the url table from file */ DEBUGC(DBCLASS_REG,"loading registration table, size=%i",URLMAP_SIZE); for (i=0;i < URLMAP_SIZE; i++) { - fgets(buff, sizeof(buff), stream); + t=fgets(buff, sizeof(buff), stream); + if (t==NULL) { break;} sts=sscanf(buff, "****:%i:%i", &urlmap[i].active, &urlmap[i].expires); if (sts == 0) break; /* format error */ if (urlmap[i].active) { #define R(X) {\ sts=osip_uri_init(&X); \ if (sts == 0) { \ - fgets(buff, sizeof(buff), stream);\ + t=fgets(buff, sizeof(buff), stream);\ buff[sizeof(buff)-1]='\0';\ if (strchr(buff, 10)) *strchr(buff, 10)='\0';\ if (strchr(buff, 13)) *strchr(buff, 13)='\0';\ @@ -403,11 +402,10 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) { configuration.masked_host.string[j]); if (strcmp(urlmap[i].masq_url->host, configuration.masked_host.string[j]) != 0) { + int len=strlen(configuration.masked_host.string[j])+1; /* new/different host, update urlmap (+1 includes terminating \0) */ - urlmap[i].masq_url->host=realloc(urlmap[i].masq_url->host, - strlen(configuration.masked_host.string[j])+1); - strncpy(urlmap[i].masq_url->host, configuration.masked_host.string[j], - strlen(configuration.masked_host.string[j])+1); + urlmap[i].masq_url->host=realloc(urlmap[i].masq_url->host, len); + strncpy(urlmap[i].masq_url->host, configuration.masked_host.string[j], len); urlmap[i].masq_url->host[strlen(configuration.masked_host.string[j])]='\0'; } } @@ -454,17 +452,17 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) { addrstr); if (strcmp(urlmap[i].masq_url->host, addrstr) != 0) { + int len=strlen(addrstr)+1; /* new address, update urlmap (+1 includes terminating \0) */ - urlmap[i].masq_url->host=realloc(urlmap[i].masq_url->host, - strlen(addrstr)+1); - strncpy(urlmap[i].masq_url->host, addrstr, strlen(addrstr)+1); + urlmap[i].masq_url->host=realloc(urlmap[i].masq_url->host, len); + strncpy(urlmap[i].masq_url->host, addrstr, len); urlmap[i].masq_url->host[strlen(addrstr)]='\0'; } /* port number if required */ if (configuration.sip_listen_port != SIP_PORT) { - urlmap[i].masq_url->port=realloc(urlmap[i].masq_url->port, 16); - snprintf(urlmap[i].masq_url->port, 16, "%i", + urlmap[i].masq_url->port=realloc(urlmap[i].masq_url->port, PORTSTRING_SIZE); + snprintf(urlmap[i].masq_url->port, PORTSTRING_SIZE, "%i", configuration.sip_listen_port); } diff --git a/src/resolve.c b/src/resolve.c index 31e9ab0..71fce51 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -37,9 +37,6 @@ #define USE_NAPTR 0 -static char const ident[]="$Id$"; - - /* local functions */ static int _resolve(char *name, int class, int type, char *dname, int dnamelen, int *port); diff --git a/src/route_processing.c b/src/route_processing.c index ef63782..f738c70 100644 --- a/src/route_processing.c +++ b/src/route_processing.c @@ -35,8 +35,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; /* defined in siproxd.c */ diff --git a/src/rtpproxy.c b/src/rtpproxy.c index c1945e6..77db591 100644 --- a/src/rtpproxy.c +++ b/src/rtpproxy.c @@ -30,8 +30,6 @@ #include "rtpproxy.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; diff --git a/src/rtpproxy_relay.c b/src/rtpproxy_relay.c index c48de26..16c7b43 100644 --- a/src/rtpproxy_relay.c +++ b/src/rtpproxy_relay.c @@ -46,8 +46,6 @@ #include "dejitter.h" #endif -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration; @@ -149,7 +147,12 @@ int rtp_relay_init( void ) { uid=getuid(); euid=geteuid(); DEBUGC(DBCLASS_RTP,"uid=%i, euid=%i", uid, euid); - if (uid != euid) seteuid(0); + if (uid != euid) { + if (seteuid(0) != 0) { + ERROR("rtp_relay_init: seteuid() failed while " + "setting DSCP value: %s", strerror(errno)); + } + } if (geteuid()==0) { #endif @@ -176,7 +179,12 @@ int rtp_relay_init( void ) { INFO("Unable to use realtime scheduling for RTP proxy"); INFO("You may want to start siproxd as root and switch UID afterwards"); } - if (uid != euid) seteuid(euid); + if (uid != euid) { + if (seteuid(euid) != 0) { + ERROR("rtp_relay_init: seteuid() failed while " + "setting DSCP value: %s", strerror(errno)); + } + } #endif } #endif @@ -725,7 +733,12 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, client_id_t client_id, uid=getuid(); euid=geteuid(); DEBUGC(DBCLASS_RTP,"uid=%i, euid=%i", uid, euid); - if (uid != euid) seteuid(0); + if (uid != euid) { + if (seteuid(0) != 0) { + ERROR("rtp_relay_start_fwd: seteuid() failed while " + "setting DSCP value: %s", strerror(errno)); + } + } if (geteuid()==0) { /* now I'm root */ if (!(configuration.rtp_dscp & ~0x3f)) { @@ -745,7 +758,12 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, client_id_t client_id, configuration.rtp_dscp = 0; /* inhibit further attempts */ } /* drop privileges */ - if (uid != euid) seteuid(euid); + if (uid != euid) { + if (seteuid(euid) != 0) { + ERROR("rtp_relay_start_fwd: seteuid() failed while " + "setting DSCP value: %s", strerror(errno)); + } + } } /* write entry into rtp_proxytable slot (freeidx) */ diff --git a/src/security.c b/src/security.c index b2346f6..0e6e92d 100644 --- a/src/security.c +++ b/src/security.c @@ -33,8 +33,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* * do security and integrity checks on the received packet * (raw buffer, \0 terminated) diff --git a/src/sip_layer.c b/src/sip_layer.c index 0d090ac..4b2b4f9 100644 --- a/src/sip_layer.c +++ b/src/sip_layer.c @@ -21,8 +21,6 @@ #include #include -static char const ident[]="$Id$"; - /* * This file contains wrapper functions to call the osip2_ library. * depending on the used version of libosip2, the calling arguments diff --git a/src/sip_utils.c b/src/sip_utils.c index cd58540..e0ef3da 100644 --- a/src/sip_utils.c +++ b/src/sip_utils.c @@ -42,9 +42,6 @@ #include "digcalc.h" #include "log.h" -static char const ident[]="$Id$"; - - /* configuration storage */ extern struct siproxd_config configuration; @@ -590,16 +587,17 @@ int sip_add_myvia (sip_ticket_t *ticket, int interface) { myaddr=utils_inet_ntoa(addr); if (ticket->protocol == PROTO_UDP) { - sprintf(tmp, "SIP/2.0/UDP %s:%i;branch=%s%s", + snprintf(tmp, URL_STRING_SIZE, "SIP/2.0/UDP %s:%i;branch=%s%s", myaddr, configuration.sip_listen_port, branch_id, (add_rport)? ";rport":""); } else { - sprintf(tmp, "SIP/2.0/TCP %s:%i;branch=%s%s", + snprintf(tmp, URL_STRING_SIZE, "SIP/2.0/TCP %s:%i;branch=%s%s", myaddr, configuration.sip_listen_port, branch_id, (add_rport)? ";rport":""); } + tmp[URL_STRING_SIZE-1]='\0'; DEBUGC(DBCLASS_BABBLE,"adding VIA:%s",tmp); diff --git a/src/siproxd.c b/src/siproxd.c index 5a6fd95..9b15ef1 100644 --- a/src/siproxd.c +++ b/src/siproxd.c @@ -41,8 +41,6 @@ #include "plugins.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ struct siproxd_config configuration; /* instructions for config parser */ diff --git a/src/siproxd.h b/src/siproxd.h index 61c48ee..5fdf601 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -311,7 +311,7 @@ int unload_plugins(void); #define PASSWORD_SIZE 128 /* max string length of a password (auth) */ #define IPSTRING_SIZE 16 /* stringsize of IP address xxx.xxx.xxx.xxx\0 */ #define PORTSTRING_SIZE 6 /* stringsize of port number xxxxx\0 */ -#define VIA_BRANCH_SIZE 128 /* max string length for via branch param */ +#define VIA_BRANCH_SIZE 64 /* max string length for via branch param */ /* scratch buffer for gethostbyname_r() */ #if defined(PR_NETDB_BUF_SIZE) diff --git a/src/sock.c b/src/sock.c index ca55d55..8fa6232 100644 --- a/src/sock.c +++ b/src/sock.c @@ -39,9 +39,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - - /* configuration storage */ extern struct siproxd_config configuration; @@ -95,7 +92,12 @@ int sipsock_listen (void) { uid=getuid(); euid=geteuid(); DEBUGC(DBCLASS_SIP,"uid=%i, euid=%i", uid, euid); - if (uid != euid) seteuid(0); + if (uid != euid) { + if (seteuid(0) != 0) { + ERROR("sipsock_listen: seteuid() failed while " + "setting DSCP value: %s", strerror(errno)); + } + } if (geteuid()==0) { /* now I'm root */ if (!(configuration.sip_dscp & ~0x3f)) { @@ -115,7 +117,13 @@ int sipsock_listen (void) { configuration.rtp_dscp = 0; /* inhibit further attempts */ } /* drop privileges */ - if (uid != euid) seteuid(euid); + if (uid != euid) { + if (seteuid(euid) != 0) { + ERROR("sipsock_listen: seteuid() failed while " + "setting DSCP value: %s", strerror(errno)); + } + } + } /* listen on TCP port */ diff --git a/src/utils.c b/src/utils.c index bed3d12..831b655 100644 --- a/src/utils.c +++ b/src/utils.c @@ -50,8 +50,6 @@ #include "siproxd.h" #include "log.h" -static char const ident[]="$Id$"; - /* configuration storage */ extern struct siproxd_config configuration;