- a number of size_t fixes

- REGISTER response generated from siproxd must include
  a Contact header.

1. tell gcc that the logging functions use printf style
format strings. This gets gcc to tell us about a lot
of the problems.

2. size_t is not an int on AMD64, so don't treat it
like one. I've changed to use "%ld" format code and
cast to a long, which should work well enough.

3. some format strings didn't match the argument lists.
These fixes are pretty clear.

4. log_debug, log_error, log_warn, log_info could all
end up evaluating their varargs list multiple times if
the message was to be logged to multiple places. This
causes the second/third uses to access invalid memory
and potentially segfault. I fixed this by using
va_copy() to copy the varargs list for each use.
This commit is contained in:
Thomas Ries
2006-05-20 11:48:53 +00:00
parent 9e7b2efd15
commit 757f34b748
16 changed files with 121 additions and 93 deletions

View File

@@ -167,9 +167,9 @@ int process_aclist (char *aclist, struct sockaddr_in from) {
mask_int=atoi(mask);
bitmask= (mask_int)? (0xffffffff<<(32-mask_int)) : 0;
DEBUGC(DBCLASS_ACCESS,"[%i] (%p) <-> (%p)", i,
ntohl(inaddr.s_addr) & bitmask,
ntohl(from.sin_addr.s_addr) & bitmask);
DEBUGC(DBCLASS_ACCESS,"check match: entry=%i, filter=%lx, from=%lx", i,
(long)ntohl(inaddr.s_addr) & bitmask,
(long)ntohl(from.sin_addr.s_addr) & bitmask);
if ( (ntohl(inaddr.s_addr) & bitmask) ==
(ntohl(from.sin_addr.s_addr) & bitmask) ) return STS_SUCCESS;

View File

@@ -107,8 +107,8 @@ int auth_include_authrq(osip_message_t *sipmsg) {
sprintf(realm,"\"%s\"",configuration.proxy_auth_realm);
osip_proxy_authenticate_set_realm(p_auth, realm);
} else {
ERROR("unable to malloc() %i bytes for authentication realm",
strlen(configuration.proxy_auth_realm)+3);
ERROR("unable to malloc() %ld bytes for authentication realm",
(long)strlen(configuration.proxy_auth_realm)+3);
return STS_FAILURE;
}

View File

@@ -210,7 +210,7 @@ void log_tcp_connect(void) {
void log_debug(int class, char *file, int line, const char *format, ...) {
va_list ap;
va_list ap, ap_copy;
time_t t;
struct tm *tim;
char string[128];
@@ -229,12 +229,16 @@ void log_debug(int class, char *file, int line, const char *format, ...) {
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i %s:%i ", tim->tm_hour,
tim->tm_min, tim->tm_sec, file, line);
vfprintf(stderr, format, ap);
va_copy(ap_copy, ap);
vfprintf(stderr, format, ap_copy);
va_end(ap_copy);
fprintf(stderr,"\n");
fflush(stderr);
} else if (silence_level < 1) {
/* running as daemon - log via SYSLOG facility */
vsnprintf(string, sizeof(string), format, ap);
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_DEBUG, "%s:%i %s", file, line, string);
}
/*
@@ -247,7 +251,9 @@ void log_debug(int class, char *file, int line, const char *format, ...) {
snprintf(outbuf, sizeof(outbuf) ,"%2.2i:%2.2i:%2.2i %s:%i ",
tim->tm_hour, tim->tm_min, tim->tm_sec, file, line);
write(debug_fd, outbuf, strlen(outbuf));
vsnprintf(outbuf, sizeof(outbuf) , format, ap);
va_copy(ap_copy, ap);
vsnprintf(outbuf, sizeof(outbuf) , format, ap_copy);
va_end(ap_copy);
write(debug_fd, outbuf, strlen(outbuf));
snprintf(outbuf, sizeof(outbuf) ,"\n");
write(debug_fd, outbuf, strlen(outbuf));
@@ -261,7 +267,7 @@ void log_debug(int class, char *file, int line, const char *format, ...) {
void log_error(char *file, int line, const char *format, ...) {
va_list ap;
va_list ap, ap_copy;
time_t t;
struct tm *tim;
char string[128];
@@ -279,13 +285,17 @@ void log_error(char *file, int line, const char *format, ...) {
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i ERROR:%s:%i ",tim->tm_hour,
tim->tm_min, tim->tm_sec, file, line);
vfprintf(stderr, format, ap);
va_copy(ap_copy, ap);
vfprintf(stderr, format, ap_copy);
va_end(ap_copy);
fprintf(stderr,"\n");
fflush(stderr);
}
if (silence_level < 4) {
/* running as daemon - log via SYSLOG facility */
vsnprintf(string, sizeof(string), format, ap);
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_WARNING, "%s:%i ERROR:%s", file, line, string);
}
/*
@@ -298,7 +308,9 @@ void log_error(char *file, int line, const char *format, ...) {
snprintf(outbuf, sizeof(outbuf) ,"%2.2i:%2.2i:%2.2i ERROR:%s:%i ",
tim->tm_hour, tim->tm_min, tim->tm_sec, file, line);
write(debug_fd, outbuf, strlen(outbuf));
vsnprintf(outbuf, sizeof(outbuf) , format, ap);
va_copy(ap_copy, ap);
vsnprintf(outbuf, sizeof(outbuf) , format, ap_copy);
va_end(ap_copy);
write(debug_fd, outbuf, strlen(outbuf));
snprintf(outbuf, sizeof(outbuf) ,"\n");
write(debug_fd, outbuf, strlen(outbuf));
@@ -312,7 +324,7 @@ void log_error(char *file, int line, const char *format, ...) {
void log_warn(char *file, int line, const char *format, ...) {
va_list ap;
va_list ap, ap_copy;
time_t t;
struct tm *tim;
char string[128];
@@ -330,13 +342,17 @@ void log_warn(char *file, int line, const char *format, ...) {
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i WARNING:%s:%i ",tim->tm_hour,
tim->tm_min, tim->tm_sec,file,line);
vfprintf(stderr, format, ap);
va_copy(ap_copy, ap);
vfprintf(stderr, format, ap_copy);
va_end(ap_copy);
fprintf(stderr,"\n");
fflush(stderr);
}
if (silence_level < 3) {
/* running as daemon - log via SYSLOG facility */
vsnprintf(string, sizeof(string), format, ap);
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_NOTICE, "%s:%i WARNING:%s", file, line, string);
}
/*
@@ -349,7 +365,9 @@ void log_warn(char *file, int line, const char *format, ...) {
snprintf(outbuf, sizeof(outbuf) ,"%2.2i:%2.2i:%2.2i WARNING:%s:%i ",
tim->tm_hour, tim->tm_min, tim->tm_sec, file, line);
write(debug_fd, outbuf, strlen(outbuf));
vsnprintf(outbuf, sizeof(outbuf) , format, ap);
va_copy(ap_copy, ap);
vsnprintf(outbuf, sizeof(outbuf) , format, ap_copy);
va_end(ap_copy);
write(debug_fd, outbuf, strlen(outbuf));
snprintf(outbuf, sizeof(outbuf) ,"\n");
write(debug_fd, outbuf, strlen(outbuf));
@@ -363,7 +381,7 @@ void log_warn(char *file, int line, const char *format, ...) {
void log_info(char *file, int line, const char *format, ...) {
va_list ap;
va_list ap, ap_copy;
time_t t;
struct tm *tim;
char string[128];
@@ -381,13 +399,17 @@ void log_info(char *file, int line, const char *format, ...) {
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i INFO:%s:%i ",tim->tm_hour,
tim->tm_min, tim->tm_sec,file,line);
vfprintf(stderr, format, ap);
va_copy(ap_copy, ap);
vfprintf(stderr, format, ap_copy);
va_end(ap_copy);
fprintf(stderr,"\n");
fflush(stderr);
}
if (silence_level < 2) {
/* running as daemon - log via SYSLOG facility */
vsnprintf(string, sizeof(string), format, ap);
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_NOTICE, "%s:%i INFO:%s", file, line, string);
}
/*
@@ -400,7 +422,9 @@ void log_info(char *file, int line, const char *format, ...) {
snprintf(outbuf, sizeof(outbuf) ,"%2.2i:%2.2i:%2.2i INFO:%s:%i ",
tim->tm_hour, tim->tm_min, tim->tm_sec, file, line);
write(debug_fd, outbuf, strlen(outbuf));
vsnprintf(outbuf, sizeof(outbuf) , format, ap);
va_copy(ap_copy, ap);
vsnprintf(outbuf, sizeof(outbuf) , format, ap_copy);
va_end(ap_copy);
write(debug_fd, outbuf, strlen(outbuf));
snprintf(outbuf, sizeof(outbuf) ,"\n");
write(debug_fd, outbuf, strlen(outbuf));

View File

@@ -46,20 +46,27 @@ void log_set_listen_port(int port);
void log_tcp_listen(void);
void log_tcp_connect(void);
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
# define GNUC_PRINTF(format_idx, arg_idx) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
# define GNUC_PRINTF(format_idx, arg_idx)
#endif
#undef DEBUG
#define DEBUG(F...) log_debug(1,__FILE__, __LINE__,F)
#define DEBUGC(C,F...) log_debug(C,__FILE__, __LINE__,F)
void log_debug(int class, char *file, int line, const char *format, ...);
void log_debug(int class, char *file, int line, const char *format, ...) GNUC_PRINTF(4, 5);
#define ERROR(F...) log_error(__FILE__, __LINE__,F)
void log_error(char *file, int line, const char *format, ...);
void log_error(char *file, int line, const char *format, ...) GNUC_PRINTF(3, 4);
#define WARN(F...) log_warn(__FILE__, __LINE__,F)
void log_warn(char *file, int line, const char *format, ...);
void log_warn(char *file, int line, const char *format, ...) GNUC_PRINTF(3, 4);
#define INFO(F...) log_info(__FILE__, __LINE__,F)
void log_info(char *file, int line, const char *format, ...);
void log_info(char *file, int line, const char *format, ...) GNUC_PRINTF(3, 4);
/* tobedone: dump a buffer */
#define DUMP_BUFFER(C,F,L) log_dump_buffer(C,__FILE__, __LINE__,F,L)

View File

@@ -21,18 +21,12 @@
#include "config.h"
#include <stdio.h>
//#include <errno.h>
#include <string.h>
//#include <stdlib.h>
//#include <unistd.h>
//#include <signal.h>
#include <netinet/in.h>
//#include <arpa/inet.h>
#include <osipparser2/osip_parser.h>
#include "siproxd.h"
//#include "plugins.h"
#include "log.h"
static char const ident[]="$Id$";
@@ -79,7 +73,7 @@ int plugin_shortdial(sip_ticket_t *ticket) {
/* requested number is not defined (out of range) */
if (shortcut_no > configuration.pi_shortdial_entry.used) {
DEBUGC(DBCLASS_PLUGIN, "shortdial: shortcut %i > available shortcuts",
DEBUGC(DBCLASS_PLUGIN, "shortdial: shortcut %i > available shortcuts (%i)",
shortcut_no, configuration.pi_shortdial_entry.used);
return STS_SUCCESS;
}
@@ -115,7 +109,8 @@ static int plugin_shortdial_redirect(sip_ticket_t *ticket, int shortcut_no) {
osip_uri_t *to_url=ticket->sipmsg->to->url;
char *to_user=to_url->username;
char *new_to_user=NULL;
int i, len;
int i;
size_t len;
osip_contact_t *contact = NULL;
new_to_user=configuration.pi_shortdial_entry.string[shortcut_no-1];

View File

@@ -81,7 +81,7 @@ int proxy_request (sip_ticket_t *ticket) {
osip_uri_t *url;
int port;
char *buffer;
int buflen;
size_t buflen;
osip_message_t *request;
DEBUGC(DBCLASS_PROXY,"proxy_request");
@@ -513,7 +513,7 @@ int proxy_response (sip_ticket_t *ticket) {
osip_via_t *via;
int port;
char *buffer;
int buflen;
size_t buflen;
osip_message_t *response;
DEBUGC(DBCLASS_PROXY,"proxy_response");
@@ -782,8 +782,8 @@ int proxy_rewrite_invitation_body(sip_ticket_t *ticket, int direction){
sdp_message_t *sdp;
struct in_addr map_addr, addr_sess, addr_media, outside_addr, inside_addr;
int sts;
char *bodybuff;
int bodybuflen;
char *buff;
size_t buflen;
char clen[8]; /* content length: probably never more than 7 digits !*/
int map_port, msg_port;
int media_stream_no;
@@ -818,35 +818,35 @@ int proxy_rewrite_invitation_body(sip_ticket_t *ticket, int direction){
#endif
}
sts = sip_body_to_str(body, &bodybuff, &bodybuflen);
sts = sip_body_to_str(body, &buff, &buflen);
if (sts != 0) {
ERROR("rewrite_invitation_body: unable to sip_body_to_str");
}
DEBUGC(-1, "rewrite_invitation_body: payload %i bytes", bodybuflen);
DUMP_BUFFER(-1, bodybuff, bodybuflen);
DEBUGC(-1, "rewrite_invitation_body: payload %ld bytes", (long)buflen);
DUMP_BUFFER(-1, buff, buflen);
sts = sdp_message_init(&sdp);
sts = sdp_message_parse (sdp, bodybuff);
sts = sdp_message_parse (sdp, buff);
if (sts != 0) {
ERROR("rewrite_invitation_body: unable to sdp_message_parse body");
DUMP_BUFFER(-1, bodybuff, bodybuflen);
osip_free(bodybuff);
DUMP_BUFFER(-1, buff, buflen);
osip_free(buff);
sdp_message_free(sdp);
return STS_FAILURE;
}
osip_free(bodybuff);
osip_free(buff);
if (configuration.debuglevel)
{ /* just dump the buffer */
char *tmp, *tmp2;
int tmplen;
size_t tmplen;
sts = osip_message_get_body(mymsg, 0, &body);
sts = sip_body_to_str(body, &tmp, &tmplen);
osip_content_length_to_str(mymsg->content_length, &tmp2);
DEBUG("Body before rewrite (clen=%s, strlen=%i):\n%s\n----",
tmp2, tmplen, tmp);
DEBUG("Body before rewrite (clen=%s, strlen=%ld):\n%s\n----",
tmp2, (long)tmplen, tmp);
osip_free(tmp);
osip_free(tmp2);
}
@@ -1080,14 +1080,14 @@ if (configuration.debuglevel)
osip_body_free(body);
/* dump new body */
sdp_message_to_str(sdp, &bodybuff);
bodybuflen=strlen(bodybuff);
sdp_message_to_str(sdp, &buff);
buflen=strlen(buff);
/* free sdp structure */
sdp_message_free(sdp);
/* include new body */
sip_message_set_body(mymsg, bodybuff, bodybuflen);
sip_message_set_body(mymsg, buff, buflen);
if (sts != 0) {
ERROR("rewrite_invitation_body: unable to sip_message_set_body body");
}
@@ -1095,21 +1095,21 @@ if (configuration.debuglevel)
/* free content length resource and include new one*/
osip_content_length_free(mymsg->content_length);
mymsg->content_length=NULL;
sprintf(clen,"%i",bodybuflen);
sprintf(clen,"%ld",(long)buflen);
sts = osip_message_set_content_length(mymsg, clen);
/* free old body */
osip_free(bodybuff);
osip_free(buff);
if (configuration.debuglevel)
{ /* just dump the buffer */
char *tmp, *tmp2;
int tmplen;
size_t tmplen;
sts = osip_message_get_body(mymsg, 0, &body);
sts = sip_body_to_str(body, &tmp, &tmplen);
osip_content_length_to_str(mymsg->content_length, &tmp2);
DEBUG("Body after rewrite (clen=%s, strlen=%i):\n%s\n----",
tmp2, tmplen, tmp);
DEBUG("Body after rewrite (clen=%s, strlen=%ld):\n%s\n----",
tmp2, (long)tmplen, tmp);
osip_free(tmp);
osip_free(tmp2);
}

View File

@@ -136,6 +136,7 @@ static int parse_config (FILE *configfile) {
int i;
int k;
int num;
size_t len;
char *tmpptr;
struct cfgopts {
@@ -251,8 +252,8 @@ static int parse_config (FILE *configfile) {
*/
/* figure out the amount of space we need */
num=strlen(ptr)+1; /* include terminating zero!*/
tmpptr=(char*)malloc(num);
len=strlen(ptr)+1; /* include terminating zero!*/
tmpptr=(char*)malloc(len);
memcpy(configoptions[k].dest, &tmpptr, sizeof(tmpptr));
num=sscanf(ptr,"%s",tmpptr);
DEBUGC(DBCLASS_BABBLE,"STRING=%s",
@@ -269,8 +270,8 @@ static int parse_config (FILE *configfile) {
int used=((stringa_t*)(configoptions[k].dest))->used;
// do I hace space left?
if (used<=CFG_STRARR_SIZE){
num=strlen(ptr)+1; /* include terminating zero!*/
tmpptr=(char*)malloc(num);
len=strlen(ptr)+1; /* include terminating zero!*/
tmpptr=(char*)malloc(len);
dst=&((stringa_t*)(configoptions[k].dest))->
string[used];
memcpy(dst, &tmpptr, sizeof(tmpptr));

View File

@@ -54,7 +54,8 @@ extern int errno;
*/
void register_init(void) {
FILE *stream;
int sts, size, i;
int sts, i;
size_t len;
char buff[128];
memset(urlmap, 0, sizeof(urlmap));
@@ -85,8 +86,8 @@ void register_init(void) {
if (strchr(buff, 10)) *strchr(buff, 10)='\0';\
if (strchr(buff, 13)) *strchr(buff, 13)='\0';\
if (strlen(buff) > 0) {\
size = strlen(buff);\
X =(char*)malloc(size+1);\
len = strlen(buff);\
X =(char*)malloc(len+1);\
sts=sscanf(buff,"%s",X);\
} else {\
X = NULL;\
@@ -529,7 +530,7 @@ int register_response(sip_ticket_t *ticket, int flag) {
osip_via_t *via;
int port;
char *buffer;
int buflen;
size_t buflen;
struct in_addr addr;
osip_header_t *expires_hdr;

View File

@@ -48,7 +48,7 @@ int rtpproxy_init( void ) {
} else if (configuration.rtp_proxy_enable == 1) { // Relay
sts = rtp_relay_init ();
} else {
ERROR("CONFIG: rtp_proxy_enable has invalid value",
ERROR("CONFIG: rtp_proxy_enable has invalid value: %d",
configuration.rtp_proxy_enable);
}
@@ -76,7 +76,7 @@ int rtp_start_fwd (osip_call_id_t *callid, char *client_id,
local_ipaddr, local_port,
remote_ipaddr, remote_port);
} else {
ERROR("CONFIG: rtp_proxy_enable has invalid value",
ERROR("CONFIG: rtp_proxy_enable has invalid value: %d",
configuration.rtp_proxy_enable);
}
@@ -99,7 +99,7 @@ int rtp_stop_fwd (osip_call_id_t *callid, int direction) {
} else if (configuration.rtp_proxy_enable == 1) { // Relay
sts = rtp_relay_stop_fwd(callid, direction, -1, 0);
} else {
ERROR("CONFIG: rtp_proxy_enable has invalid value",
ERROR("CONFIG: rtp_proxy_enable has invalid value: %d",
configuration.rtp_proxy_enable);
}

View File

@@ -428,20 +428,20 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
*/
if (callid->number && (strlen(callid->number) >= CALLIDNUM_SIZE)) {
ERROR("rtp_relay_start_fwd: received callid number [%s] "
"has too many characters (%i, max=%i)",
callid->number, strlen(callid->number),CALLIDNUM_SIZE);
"has too many characters (%ld, max=%i)",
callid->number, (long)strlen(callid->number),CALLIDNUM_SIZE);
return STS_FAILURE;
}
if (callid->host && (strlen(callid->host) >= CALLIDHOST_SIZE)) {
ERROR("rtp_relay_start_fwd: received callid host [%s] "
"has too many characters (%i, max=%i)",
callid->host, strlen(callid->host),CALLIDHOST_SIZE);
"has too many characters (%ld, max=%i)",
callid->host, (long)strlen(callid->host),CALLIDHOST_SIZE);
return STS_FAILURE;
}
if (client_id && (strlen(client_id) >= CLIENT_ID_SIZE)) {
ERROR("rtp_relay_start_fwd: client ID [%s] has too many characters "
"(%i, max=%i)",
client_id, strlen(client_id),CLIENT_ID_SIZE);
"(%ld, max=%i)",
client_id, (long)strlen(client_id),CLIENT_ID_SIZE);
return STS_FAILURE;
}
@@ -595,7 +595,7 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
tos = (configuration.rtp_dscp << 2) & 0xff;
if(setsockopt(sock, SOL_IP, IP_TOS, &tos, sizeof(tos))) {
ERROR("rtp_relay_start_fwd: setsockopt() failed while "
"setting DSCP value: ", strerror(errno));
"setting DSCP value: %s", strerror(errno));
}
} else {
ERROR("rtp_relay_start_fwd: Invalid DSCP value %d",

View File

@@ -42,10 +42,10 @@ static char const ident[]="$Id$";
* STS_SUCCESS if ok
* STS_FAILURE if the packed did not pass the checks
*/
int security_check_raw(char *sip_buffer, int size) {
int security_check_raw(char *sip_buffer, size_t size) {
char *p1=NULL, *p2=NULL;
DEBUGC(DBCLASS_BABBLE,"security_check_raw: size=%i", size);
DEBUGC(DBCLASS_BABBLE,"security_check_raw: size=%ld", (long)size);
/*
* empiric: size must be >= 16 bytes
* 2 byte <CR><LF> packets have been seen in the wild

View File

@@ -30,7 +30,7 @@ static char const ident[]="$Id$";
* argument for a number of functions used by siproxd.
*/
int sip_message_parse(osip_message_t * sip, const char *buf, int len) {
int sip_message_parse(osip_message_t * sip, const char *buf, size_t len) {
#ifdef HAVE_FUNC_OSIP_MESSAGE_PARSE_3
return osip_message_parse(sip, buf, len);
#else
@@ -38,7 +38,7 @@ int sip_message_parse(osip_message_t * sip, const char *buf, int len) {
#endif
}
int sip_message_to_str(osip_message_t * sip, char **dest, int *len) {
int sip_message_to_str(osip_message_t * sip, char **dest, size_t *len) {
#ifdef HAVE_FUNC_OSIP_MESSAGE_TO_STR_3
int sts;
sts = osip_message_to_str(sip, dest, len);
@@ -56,7 +56,7 @@ int sip_message_to_str(osip_message_t * sip, char **dest, int *len) {
#endif
}
int sip_body_to_str(const osip_body_t * body, char **dest, int *len) {
int sip_body_to_str(const osip_body_t * body, char **dest, size_t *len) {
#ifdef HAVE_FUNC_OSIP_BODY_TO_STR_3
int sts;
sts = osip_body_to_str(body, dest, len);
@@ -74,7 +74,7 @@ int sip_body_to_str(const osip_body_t * body, char **dest, int *len) {
#endif
}
int sip_message_set_body(osip_message_t * sip, const char *buf, int len) {
int sip_message_set_body(osip_message_t * sip, const char *buf, size_t len) {
#ifdef HAVE_FUNC_OSIP_MESSAGE_SET_BODY_3
return osip_message_set_body(sip, buf, len);
#else

View File

@@ -85,12 +85,12 @@ osip_message_t *msg_make_template_reply (sip_ticket_t *ticket, int code) {
osip_from_clone (request->from, &response->from);
/* if 3xx, also include 1st contact header */
if ((code>=300) && (code<400)) {
if ((code==200) || ((code>=300) && (code<400))) {
osip_contact_t *req_contact = NULL;
osip_contact_t *res_contact = NULL;
osip_message_get_contact(request, 0, &req_contact);
osip_contact_clone (req_contact, &res_contact);
osip_list_add(response->contacts,res_contact,0);
if (req_contact) osip_contact_clone (req_contact, &res_contact);
if (res_contact) osip_list_add(response->contacts,res_contact,0);
}
/* via headers */
@@ -525,7 +525,7 @@ int sip_gen_response(sip_ticket_t *ticket, int code) {
osip_via_t *via;
int port;
char *buffer;
int buflen;
size_t buflen;
struct in_addr addr;
/* create the response template */

View File

@@ -83,7 +83,7 @@ int main (int argc, char *argv[])
{
int sts;
int i;
int buflen;
size_t buflen;
int access;
char buff [BUFFER_SIZE];
sip_ticket_t ticket;

View File

@@ -125,7 +125,7 @@ int sipsock_wait(void);
int sipsock_read(void *buf, size_t bufsize,
struct sockaddr_in *from, int *protocol);
int sipsock_send(struct in_addr addr, int port, int protocol, /*X*/
char *buffer, int size);
char *buffer, size_t size);
int sockbind(struct in_addr ipaddr, int localport, int errflg);
/* register.c */
@@ -192,7 +192,7 @@ void rtpproxy_kill( void ); /*X*/
int accesslist_check(struct sockaddr_in from);
/* security.c */
int security_check_raw(char *sip_buffer, int size); /*X*/
int security_check_raw(char *sip_buffer, size_t size); /*X*/
int security_check_sip(sip_ticket_t *ticket); /*X*/
/* auth.c */
@@ -209,10 +209,10 @@ int fwapi_stop_rtp(int rtp_direction,
struct in_addr remote_ipaddr, int remote_port);
/* sip_layer.c */
int sip_message_parse(osip_message_t * sip, const char *buf, int len);
int sip_message_to_str(osip_message_t * sip, char **dest, int *len);
int sip_body_to_str(const osip_body_t * body, char **dest, int *len);
int sip_message_set_body(osip_message_t * sip, const char *buf, int len);
int sip_message_parse(osip_message_t * sip, const char *buf, size_t len);
int sip_message_to_str(osip_message_t * sip, char **dest, size_t *len);
int sip_body_to_str(const osip_body_t * body, char **dest, size_t *len);
int sip_message_set_body(osip_message_t * sip, const char *buf, size_t len);
/*

View File

@@ -137,7 +137,7 @@ int sipsock_read(void *buf, size_t bufsize,
* STS_FAILURE on error
*/
int sipsock_send(struct in_addr addr, int port, int protocol,
char *buffer, int size) {
char *buffer, size_t size) {
struct sockaddr_in dst_addr;
int sts;
@@ -170,9 +170,9 @@ int sipsock_send(struct in_addr addr, int port, int protocol,
if (sts == -1) {
if (errno != ECONNREFUSED) {
ERROR("sendto() [%s:%i size=%i] call failed: %s",
ERROR("sendto() [%s:%i size=%ld] call failed: %s",
utils_inet_ntoa(addr),
port, size, strerror(errno));
port, (long)size, strerror(errno));
return STS_FAILURE;
}
DEBUGC(DBCLASS_BABBLE,"sendto() [%s:%i] call failed: %s",