Commit f931682f authored by Ghislain MARY's avatar Ghislain MARY

Some more improvements on object marshalling.

 - Use size_t instead of unsigned int for offset.
 - Add function to enable marshal check at runtime.
 - Enable marshal check in unit tests.
parent 12152171
......@@ -76,7 +76,7 @@ typedef struct _belle_sip_header belle_sip_header_t;
BELLESIP_EXPORT belle_sip_header_t* belle_sip_header_create (const char* name,const char* value);
BELLESIP_EXPORT const char* belle_sip_header_get_name (const belle_sip_header_t* obj);
BELLESIP_EXPORT void belle_sip_header_set_name (belle_sip_header_t* obj,const char* value);
BELLESIP_EXPORT belle_sip_error_code belle_sip_header_marshal(belle_sip_header_t* header, char* buff, size_t buff_size, unsigned int *offset);
BELLESIP_EXPORT belle_sip_error_code belle_sip_header_marshal(belle_sip_header_t* header, char* buff, size_t buff_size, size_t *offset);
BELLESIP_EXPORT const char *belle_sip_header_get_unparsed_value(belle_sip_header_t* obj);
#define BELLE_SIP_HEADER(t) BELLE_SIP_CAST(t,belle_sip_header_t)
......
......@@ -114,7 +114,7 @@ typedef struct _belle_sip_object belle_sip_object_t;
typedef void (*belle_sip_object_destroy_t)(belle_sip_object_t*);
typedef void (*belle_sip_object_clone_t)(belle_sip_object_t* obj, const belle_sip_object_t *orig);
typedef int (*belle_sip_object_marshal_t)(belle_sip_object_t* obj, char* buff, size_t buff_size, unsigned int *offset);
typedef int (*belle_sip_object_marshal_t)(belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset);
struct _belle_sip_object_vptr{
belle_sip_type_id_t id;
......@@ -151,6 +151,13 @@ BELLESIP_EXPORT belle_sip_object_t * _belle_sip_object_new(size_t objsize, belle
#define belle_sip_object_new(_type) (_type*)_belle_sip_object_new(sizeof(_type),(belle_sip_object_vptr_t*)&BELLE_SIP_OBJECT_VPTR_NAME(_type))
/**
* Activates checks on object marshalling.
* Useful for debug purposes.
* @param enable TRUE to enable, FALSE to disable.
**/
BELLESIP_EXPORT void belle_sip_object_enable_marshal_check(int enable);
int belle_sip_object_is_unowed(const belle_sip_object_t *obj);
/**
......@@ -231,7 +238,7 @@ BELLESIP_EXPORT char* belle_sip_object_to_string(void* obj);
* Writes a string representation of the object into the supplied buffer.
* Same as belle_sip_object_to_string(), but without allocating space for the output string.
**/
BELLESIP_EXPORT belle_sip_error_code belle_sip_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, unsigned int *offset);
BELLESIP_EXPORT belle_sip_error_code belle_sip_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset);
BELLESIP_EXPORT int belle_sip_object_is_instance_of(belle_sip_object_t * obj,belle_sip_type_id_t id);
......
......@@ -52,7 +52,7 @@ BELLESIP_EXPORT const belle_sip_list_t * belle_sip_parameters_get_parameters(con
BELLESIP_EXPORT void belle_sip_parameters_remove_parameter(belle_sip_parameters_t* obj,const char* name);
BELLESIP_EXPORT belle_sip_error_code belle_sip_parameters_marshal(const belle_sip_parameters_t* obj, char* buff, size_t buff_size, unsigned int *offset);
BELLESIP_EXPORT belle_sip_error_code belle_sip_parameters_marshal(const belle_sip_parameters_t* obj, char* buff, size_t buff_size, size_t *offset);
#define BELLE_SIP_PARAMETERS(obj) BELLE_SIP_CAST(obj,belle_sip_parameters_t)
......
......@@ -185,7 +185,7 @@ BELLESIP_EXPORT void belle_sip_uri_fix(belle_sip_uri_t *uri);
*/
BELLESIP_EXPORT char* belle_sip_uri_to_string(belle_sip_uri_t* uri) ;
belle_sip_error_code belle_sip_uri_marshal(const belle_sip_uri_t* uri, char* buff, size_t buff_size, unsigned int *offset);
belle_sip_error_code belle_sip_uri_marshal(const belle_sip_uri_t* uri, char* buff, size_t buff_size, size_t *offset);
#define BELLE_SIP_URI(obj) BELLE_SIP_CAST(obj,belle_sip_uri_t)
......
......@@ -145,7 +145,7 @@ BELLESIP_EXPORT void belle_sip_set_log_handler(belle_sip_log_function_t func);
BELLESIP_EXPORT char * BELLE_SIP_CHECK_FORMAT_ARGS(1,2) belle_sip_strdup_printf(const char *fmt,...);
BELLESIP_EXPORT belle_sip_error_code belle_sip_snprintf(char *buff, unsigned int buff_size, unsigned int *offset, const char *fmt, ...);
BELLESIP_EXPORT belle_sip_error_code belle_sip_snprintf(char *buff, size_t buff_size, size_t *offset, const char *fmt, ...);
BELLESIP_EXPORT void belle_sip_set_log_level(int level);
......
......@@ -38,7 +38,7 @@ void belle_sdp_attribute_clone(belle_sdp_attribute_t *attribute, const belle_sdp
CLONE_STRING(belle_sdp_attribute,value,attribute,orig)
}
belle_sip_error_code belle_sdp_attribute_marshal(belle_sdp_attribute_t* attribute, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_attribute_marshal(belle_sdp_attribute_t* attribute, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=belle_sip_snprintf(buff,buff_size,offset,"a=%s",attribute->name);
if (error!=BELLE_SIP_OK) return error;
if (attribute->value) {
......@@ -79,7 +79,7 @@ void belle_sdp_bandwidth_clone(belle_sdp_bandwidth_t *bandwidth, const belle_sdp
bandwidth->value=orig->value;
}
belle_sip_error_code belle_sdp_bandwidth_marshal(belle_sdp_bandwidth_t* bandwidth, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_bandwidth_marshal(belle_sdp_bandwidth_t* bandwidth, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"b=%s:%i",bandwidth->type,bandwidth->value);
}
......@@ -111,7 +111,7 @@ void belle_sdp_connection_clone(belle_sdp_connection_t *connection, const belle_
}
belle_sip_error_code belle_sdp_connection_marshal(belle_sdp_connection_t* connection, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_connection_marshal(belle_sdp_connection_t* connection, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"c=%s %s %s",connection->network_type,connection->address_type,connection->address);
}
......@@ -143,7 +143,7 @@ void belle_sdp_email_clone(belle_sdp_email_t *email, const belle_sdp_email_t *or
CLONE_STRING(belle_sdp_email,value,email,orig)
}
belle_sip_error_code belle_sdp_email_marshal(belle_sdp_email_t* email, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_email_marshal(belle_sdp_email_t* email, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"e=%s",email->value);
}
......@@ -166,7 +166,7 @@ void belle_sdp_info_clone(belle_sdp_info_t *info, const belle_sdp_info_t *orig){
CLONE_STRING(belle_sdp_info,value,info,orig)
}
belle_sip_error_code belle_sdp_info_marshal(belle_sdp_info_t* info, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_info_marshal(belle_sdp_info_t* info, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"i=%s",info->value);
}
......@@ -208,7 +208,7 @@ void belle_sdp_media_clone(belle_sdp_media_t *media, const belle_sdp_media_t *or
CLONE_STRING(belle_sdp_media,protocol,media,orig)
}
belle_sip_error_code belle_sdp_media_marshal(belle_sdp_media_t* media, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_media_marshal(belle_sdp_media_t* media, char* buff, size_t buff_size, size_t *offset) {
belle_sip_list_t* list=media->media_formats;
belle_sip_error_code error=belle_sip_snprintf(buff,buff_size,offset,"m=%s %i",media->media_type,media->media_port);
if (error!=BELLE_SIP_OK) return error;
......@@ -279,7 +279,7 @@ static void belle_sdp_base_description_clone(belle_sdp_base_description_t *base_
}
belle_sip_error_code belle_sdp_base_description_marshal(belle_sdp_base_description_t* base_description, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_base_description_marshal(belle_sdp_base_description_t* base_description, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=BELLE_SIP_OK;
belle_sip_list_t* bandwidths;
// belle_sip_list_t* attributes;
......@@ -302,8 +302,8 @@ belle_sip_error_code belle_sdp_base_description_marshal(belle_sdp_base_descripti
if (error!=BELLE_SIP_OK) return error;
}
// for(attributes=base_description->attributes;attributes!=NULL;attributes=attributes->next){
// current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(attributes->data),buff,current_offset,buff_size);
// current_offset+=snprintf(buff+current_offset, buff_size-current_offset, "\r\n");
// error=belle_sip_object_marshal(BELLE_SIP_OBJECT(attributes->data),buff,buff_size,offset);
// error=belle_sip_snprintf(buff, buff_size, offset, "\r\n");
// }
return error;
}
......@@ -424,7 +424,7 @@ void belle_sdp_media_description_clone(belle_sdp_media_description_t *media_desc
if (orig->media) media_description->media = BELLE_SDP_MEDIA(belle_sip_object_clone_and_ref(BELLE_SIP_OBJECT((orig->media))));
}
belle_sip_error_code belle_sdp_media_description_marshal(belle_sdp_media_description_t* media_description, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_media_description_marshal(belle_sdp_media_description_t* media_description, char* buff, size_t buff_size, size_t *offset) {
belle_sip_list_t* attributes;
belle_sip_error_code error=belle_sip_object_marshal(BELLE_SIP_OBJECT(media_description->media),buff,buff_size,offset);
if (error!=BELLE_SIP_OK) return error;
......@@ -819,7 +819,7 @@ void belle_sdp_origin_clone(belle_sdp_origin_t *origin, const belle_sdp_origin_t
origin->session_version = orig->session_version;
}
belle_sip_error_code belle_sdp_origin_marshal(belle_sdp_origin_t* origin, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_origin_marshal(belle_sdp_origin_t* origin, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf( buff
,buff_size
,offset
......@@ -871,7 +871,7 @@ void belle_sdp_session_name_clone(belle_sdp_session_name_t *session_name, const
CLONE_STRING(belle_sdp_session_name,value,session_name,orig);
}
belle_sip_error_code belle_sdp_session_name_marshal(belle_sdp_session_name_t* session_name, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_session_name_marshal(belle_sdp_session_name_t* session_name, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"s=%s",session_name->value);
}
......@@ -925,7 +925,7 @@ void belle_sdp_session_description_clone(belle_sdp_session_description_t *sessio
session_description->media_descriptions = belle_sip_list_copy_with_data(orig->media_descriptions,belle_sip_object_copyfunc);
}
belle_sip_error_code belle_sdp_session_description_marshal(belle_sdp_session_description_t* session_description, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_session_description_marshal(belle_sdp_session_description_t* session_description, char* buff, size_t buff_size, size_t *offset) {
/*session_description: proto_version CR LF
origin_field
session_name_field
......@@ -1130,7 +1130,7 @@ void belle_sdp_time_clone(belle_sdp_time_t *time, const belle_sdp_time_t *orig){
time->stop=orig->stop;
}
belle_sip_error_code belle_sdp_time_marshal(belle_sdp_time_t* time, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_time_marshal(belle_sdp_time_t* time, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"%i %i",time->start,time->stop);
}
......@@ -1156,7 +1156,7 @@ void belle_sdp_time_description_clone(belle_sdp_time_description_t *time_descrip
if (orig->time) time_description->time = BELLE_SDP_TIME(belle_sip_object_clone_and_ref(BELLE_SIP_OBJECT(orig->time)));
}
belle_sip_error_code belle_sdp_time_description_marshal(belle_sdp_time_description_t* time_description, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_time_description_marshal(belle_sdp_time_description_t* time_description, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_object_marshal(BELLE_SIP_OBJECT(time_description->time),buff,buff_size,offset);
}
......@@ -1200,7 +1200,7 @@ void belle_sdp_version_clone(belle_sdp_version_t *version, const belle_sdp_versi
version->version = orig->version;
}
belle_sip_error_code belle_sdp_version_marshal(belle_sdp_version_t* version, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sdp_version_marshal(belle_sdp_version_t* version, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"v=%i",version->version);
}
......
This diff is collapsed.
......@@ -20,6 +20,8 @@
static void _belle_sip_object_pool_remove_from_stack(belle_sip_object_pool_t *pool);
static int _belle_sip_object_marshal_check_enabled = FALSE;
static int has_type(belle_sip_object_t *obj, belle_sip_type_id_t id){
belle_sip_object_vptr_t *vptr=obj->vptr;
......@@ -34,6 +36,10 @@ int belle_sip_object_is_instance_of(belle_sip_object_t * obj,belle_sip_type_id_t
return has_type(obj,id);
}
void belle_sip_object_enable_marshal_check(int enable) {
_belle_sip_object_marshal_check_enabled = (enable) ? TRUE : FALSE;
}
belle_sip_object_t * _belle_sip_object_new(size_t objsize, belle_sip_object_vptr_t *vptr){
belle_sip_object_t *obj=(belle_sip_object_t *)belle_sip_malloc0(objsize);
obj->ref=vptr->initially_unowned ? 0 : 1;
......@@ -129,7 +135,7 @@ static void _belle_sip_object_clone(belle_sip_object_t *obj, const belle_sip_obj
if (orig->name!=NULL) obj->name=belle_sip_strdup(obj->name);
}
static belle_sip_error_code _belle_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, unsigned int *offset) {
static belle_sip_error_code _belle_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset) {
return belle_sip_snprintf(buff,buff_size,offset,"{%s::%s %p}",obj->vptr->type_name,obj->name ? obj->name : "(no name)",obj);
}
......@@ -259,42 +265,42 @@ const char* belle_sip_object_get_name(belle_sip_object_t* object) {
return object->name;
}
/*turn this to 1 if you feel a marshal method is buggy.*/
#define CHECKED_MARSHAL 0
#if CHECKED_MARSHAL
static belle_sip_error_code checked_marshal(belle_sip_object_vptr_t *vptr, belle_sip_object_t* obj, char* buff, size_t buff_size, unsigned int *offset){
int tmp_buf_size=buff_size*2;
static belle_sip_error_code checked_marshal(belle_sip_object_vptr_t *vptr, belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset){
size_t tmp_buf_size=buff_size*2;
char *p=(char*)belle_sip_malloc0(tmp_buf_size);
int i;
unsigned int initial_offset=*offset;
size_t i;
size_t initial_offset=*offset;
belle_sip_error_code error=vptr->marshal(obj,p,buff_size,offset);
int written;
size_t written;
for (i=initial_offset;i<buff_size;++i){
if (p[i]=='\0') break;
}
written=i-initial_offset;
if (error==BELLE_SIP_BUFFER_OVERFLOW){
belle_sip_fatal("Object of type %s commited a buffer overflow by marshalling %i bytes",
belle_sip_error("Object of type %s commited a buffer overflow by marshalling %i bytes",
vptr->type_name,*offset-initial_offset);
} else if (error!=BELLE_SIP_OK){
belle_sip_fatal("Object of type %s produced an error during marshalling: %i",
belle_sip_error("Object of type %s produced an error during marshalling: %i",
vptr->type_name,error);
}
memcpy(buff+initial_offset,p,*offset-initial_offset);
if (written!=(*offset-initial_offset) && written!=(buff_size-initial_offset-1)){ /*this is because snprintf won't allow you to write a non null character at the end of the buffer*/
belle_sip_fatal("Object of type %s marshalled %i bytes but said it marshalled %i bytes !",
vptr->type_name,written,*offset-initial_offset);
}
memcpy(buff+initial_offset,p+initial_offset,*offset-initial_offset);
belle_sip_free(p);
return ret;
return error;
}
#endif
belle_sip_error_code belle_sip_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sip_object_marshal(belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset) {
belle_sip_object_vptr_t *vptr=obj->vptr;
while (vptr != NULL) {
if (vptr->marshal != NULL) {
#if CHECKED_MARSHAL
return checked_marshal(vptr,obj,buff,buff_size,offset);
#else
return vptr->marshal(obj,buff,buff_size,offset);
#endif
if (_belle_sip_object_marshal_check_enabled == TRUE)
return checked_marshal(vptr,obj,buff,buff_size,offset);
else
return vptr->marshal(obj,buff,buff_size,offset);
} else {
vptr=vptr->parent;
}
......@@ -305,7 +311,7 @@ belle_sip_error_code belle_sip_object_marshal(belle_sip_object_t* obj, char* buf
static char * belle_sip_object_to_alloc_string(belle_sip_object_t *obj, int size_hint){
char *buf=belle_sip_malloc(size_hint);
unsigned int offset=0;
size_t offset=0;
belle_sip_error_code error = belle_sip_object_marshal(obj,buf,size_hint-1,&offset);
obj->vptr->tostring_bufsize_hint=size_hint;
if (error==BELLE_SIP_BUFFER_OVERFLOW){
......@@ -330,7 +336,7 @@ char* belle_sip_object_to_string(void* _obj) {
return belle_sip_object_to_alloc_string(obj,obj->vptr->tostring_bufsize_hint);
}else{
char buff[BELLE_SIP_MAX_TO_STRING_SIZE];
unsigned int offset=0;
size_t offset=0;
belle_sip_error_code error = belle_sip_object_marshal(obj,buff,sizeof(buff),&offset);
if (error==BELLE_SIP_BUFFER_OVERFLOW){
belle_sip_message("belle_sip_object_to_string(): temporary buffer is too short while doing to_string() for %s, retrying", obj->vptr->type_name);
......
......@@ -41,7 +41,7 @@ static void belle_sip_parameters_clone(belle_sip_parameters_t *params, const bel
}
}
belle_sip_error_code belle_sip_parameters_marshal(const belle_sip_parameters_t* params, char* buff,size_t buff_size,unsigned int *offset) {
belle_sip_error_code belle_sip_parameters_marshal(const belle_sip_parameters_t* params, char* buff, size_t buff_size, size_t *offset) {
belle_sip_list_t* list=params->param_list;
belle_sip_error_code error=BELLE_SIP_OK;
for(;list!=NULL;list=list->next){
......
......@@ -69,7 +69,7 @@ static void belle_sip_uri_clone(belle_sip_uri_t* uri, const belle_sip_uri_t *ori
}
belle_sip_error_code belle_sip_uri_marshal(const belle_sip_uri_t* uri, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sip_uri_marshal(const belle_sip_uri_t* uri, char* buff, size_t buff_size, size_t *offset) {
const belle_sip_list_t* list=belle_sip_parameters_get_parameters(uri->header_list);
belle_sip_error_code error=BELLE_SIP_OK;
......
......@@ -106,7 +106,7 @@ char *belle_sip_strdup_printf(const char *fmt,...){
return ret;
}
belle_sip_error_code belle_sip_snprintf(char *buff, unsigned int buff_size, unsigned int *offset, const char *fmt, ...) {
belle_sip_error_code belle_sip_snprintf(char *buff, size_t buff_size, size_t *offset, const char *fmt, ...) {
int ret;
belle_sip_error_code error = BELLE_SIP_OK;
va_list args;
......
......@@ -76,7 +76,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR(belle_sip_channel_t)=
BELLE_SIP_VPTR_INIT(belle_sip_channel_t,belle_sip_source_t,FALSE),
(belle_sip_object_destroy_t)belle_sip_channel_destroy,
NULL, /*clone*/
NULL, /*marshall*/
NULL, /*marshal*/
}
};
......@@ -458,7 +458,7 @@ void channel_set_state(belle_sip_channel_t *obj, belle_sip_channel_state_t state
static void _send_message(belle_sip_channel_t *obj, belle_sip_message_t *msg){
char buffer[belle_sip_network_buffer_size];
unsigned int len=0;
size_t len=0;
int ret=0;
belle_sip_error_code error=BELLE_SIP_OK;
......
......@@ -197,7 +197,7 @@ void belle_sip_message_remove_header(belle_sip_message_t *msg, const char *heade
/*
belle_sip_error_code belle_sip_message_named_headers_marshal(belle_sip_message_t *message, const char* header_name, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sip_message_named_headers_marshal(belle_sip_message_t *message, const char* header_name, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=BELLE_SIP_OK;
belle_sip_list_t* header_list = belle_sip_message_get_headers(message,header_name);
if (!header_list) {
......@@ -246,7 +246,7 @@ belle_sip_list_t* belle_sip_message_get_all_headers(const belle_sip_message_t *m
return headers;
}
belle_sip_error_code belle_sip_headers_marshal(belle_sip_message_t *message, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sip_headers_marshal(belle_sip_message_t *message, char* buff, size_t buff_size, size_t *offset) {
/*FIXME, replace this code by belle_sip_message_for_each_header*/
belle_sip_list_t* headers_list;
belle_sip_list_t* header_list;
......@@ -286,7 +286,7 @@ static void belle_sip_request_clone(belle_sip_request_t *request, const belle_si
if (orig->uri) request->uri=(belle_sip_uri_t*)belle_sip_object_ref(belle_sip_object_clone((belle_sip_object_t*)orig->uri));
}
belle_sip_error_code belle_sip_request_marshal(belle_sip_request_t* request, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sip_request_marshal(belle_sip_request_t* request, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=belle_sip_snprintf(buff,buff_size,offset,"%s ",belle_sip_request_get_method(request));
if (error!=BELLE_SIP_OK) return error;
error=belle_sip_uri_marshal(belle_sip_request_get_uri(request),buff,buff_size,offset);
......@@ -467,7 +467,7 @@ static void belle_sip_response_clone(belle_sip_response_t *resp, const belle_sip
if (orig->reason_phrase) resp->reason_phrase=belle_sip_strdup(orig->reason_phrase);
}
belle_sip_error_code belle_sip_response_marshal(belle_sip_response_t *resp, char* buff, size_t buff_size, unsigned int *offset) {
belle_sip_error_code belle_sip_response_marshal(belle_sip_response_t *resp, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=belle_sip_snprintf( buff
,buff_size
,offset
......
......@@ -174,7 +174,7 @@ static void compute_hash_from_invariants(belle_sip_message_t *msg, char *branchi
if (initial)
belle_sip_md5_append(&ctx,(uint8_t*)initial,strlen(initial));
if (requri){
unsigned int offset=0;
size_t offset=0;
belle_sip_object_marshal((belle_sip_object_t*)requri,tmp,sizeof(tmp)-1,&offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,strlen(tmp));
}
......@@ -186,13 +186,13 @@ static void compute_hash_from_invariants(belle_sip_message_t *msg, char *branchi
belle_sip_md5_append(&ctx,(uint8_t*)&cseq,sizeof(cseq));
if (is_request){
if (prev_via){
unsigned int offset=0;
size_t offset=0;
belle_sip_object_marshal((belle_sip_object_t*)prev_via,tmp,sizeof(tmp)-1,&offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,strlen(tmp));
}
}else{
if (via){
unsigned int offset=0;
size_t offset=0;
belle_sip_object_marshal((belle_sip_object_t*)via,tmp,sizeof(tmp)-1,&offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,strlen(tmp));
}
......
......@@ -68,7 +68,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR(belle_sip_transaction_t)={
BELLE_SIP_VPTR_INIT(belle_sip_transaction_t,belle_sip_object_t,FALSE),
(belle_sip_object_destroy_t) transaction_destroy,
NULL,/*no clone*/
NULL,/*no marshall*/
NULL,/*no marshal*/
},
NULL /*on_terminate*/
};
......
......@@ -384,10 +384,10 @@ static void test_overflow(void){
belle_sip_list_t *mds;
belle_sdp_media_description_t *vmd;
int i;
const unsigned int orig_buffsize=1024;
unsigned int buffsize=orig_buffsize;
const size_t orig_buffsize=1024;
size_t buffsize=orig_buffsize;
char *buffer=belle_sip_malloc0(buffsize);
unsigned int offset=0;
size_t offset=0;
sdp=belle_sdp_session_description_parse(big_sdp);
CU_ASSERT_PTR_NOT_NULL(sdp);
......
......@@ -100,6 +100,7 @@ const char * belle_sip_tester_test_name(const char *suite_name, int test_index)
}
void belle_sip_tester_init(void) {
belle_sip_object_enable_marshal_check(TRUE);
add_test_suite(&cast_test_suite);
add_test_suite(&uri_test_suite);
add_test_suite(&headers_test_suite);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment