36,6 → 36,7 |
|
#include <errno.h> |
#include <malloc.h> |
#include <stdio.h> |
#include <string.h> |
#include <unistd.h> |
#include <ipc/ipc.h> |
69,17 → 70,14 |
char * next; |
ipc_callid_t callid; |
|
if(( ! strings ) || ( !( * data )) || ( count <= 0 )){ |
if(( ! strings ) || ( ! data ) || ( count <= 0 )){ |
return EINVAL; |
} |
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 )); |
if( ! lengths ) return ENOMEM; |
if( ERROR_OCCURED( ipc_data_write_receive( & callid, & length ))){ |
if(( ! ipc_data_write_receive( & callid, & length )) |
|| ( length != sizeof( size_t ) * ( count + 1 ))){ |
free( lengths ); |
return ERROR_CODE; |
} |
if( length < sizeof( size_t ) * ( count + 1 )){ |
free( lengths ); |
return EINVAL; |
} |
if( ERROR_OCCURED( ipc_data_write_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){ |
88,6 → 86,7 |
} |
* data = malloc( lengths[ count ] ); |
if( !( * data )) return ENOMEM; |
( * data )[ lengths[ count ] - 1 ] = '\0'; |
* strings = ( measured_string_ref ) malloc( sizeof( measured_string_t ) * count ); |
if( !( * strings )){ |
free( lengths ); |
98,8 → 97,8 |
for( index = 0; index < count; ++ index ){ |
( * strings)[ index ].length = lengths[ index ]; |
if( lengths[ index ] > 0 ){ |
ERROR_PROPAGATE( ipc_data_write_receive( & callid, & length )); |
if( length < lengths[ index ] + 1 ){ |
if(( ! ipc_data_write_receive( & callid, & length )) |
|| ( length != lengths[ index ] )){ |
free( * data ); |
free( * strings ); |
free( lengths ); |
106,6 → 105,7 |
return EINVAL; |
} |
ERROR_PROPAGATE( ipc_data_write_finalize( callid, next, lengths[ index ] )); |
( * strings)[ index ].value = next; |
next += lengths[ index ]; |
* next = '\0'; |
++ next; |
130,12 → 130,9 |
} |
lengths = prepare_lengths( strings, count ); |
if( ! lengths ) return ENOMEM; |
if( ERROR_OCCURED( ipc_data_read_receive( & callid, & length ))){ |
if(( ! ipc_data_read_receive( & callid, & length )) |
|| ( length != sizeof( size_t ) * ( count + 1 ))){ |
free( lengths ); |
return ERROR_CODE; |
} |
if( length < strings[ index ].length + 1 ){ |
free( lengths ); |
return EINVAL; |
} |
if( ERROR_OCCURED( ipc_data_read_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){ |
145,8 → 142,8 |
free( lengths ); |
for( index = 0; index < count; ++ index ){ |
if( strings[ index ].length > 0 ){ |
ERROR_PROPAGATE( ipc_data_read_receive( & callid, & length )); |
if( length < strings[ index ].length + 1 ){ |
if(( ! ipc_data_read_receive( & callid, & length )) |
|| ( length != strings[ index ].length )){ |
return EINVAL; |
} |
ERROR_PROPAGATE( ipc_data_read_finalize( callid, strings[ index ].value, strings[ index ].length )); |
162,7 → 159,7 |
int index; |
char * next; |
|
if(( phone <= 0 ) || ( ! strings ) || ( !( * data )) || ( count <= 0 )){ |
if(( phone <= 0 ) || ( ! strings ) || ( ! data ) || ( count <= 0 )){ |
return EINVAL; |
} |
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 )); |
183,8 → 180,8 |
for( index = 0; index < count; ++ index ){ |
( * strings )[ index ].length = lengths[ index ]; |
if( lengths[ index ] > 0 ){ |
ERROR_PROPAGATE( ipc_data_read_start( phone, next, lengths[ index ] )); |
( * strings )[ index ].value = next; |
ERROR_PROPAGATE( ipc_data_read_start( phone, next, lengths[ index ] )); |
next += lengths[ index ]; |
* next = '\0'; |
++ next; |
214,7 → 211,7 |
free( lengths ); |
for( index = 0; index < count; ++ index ){ |
if( strings[ index ].length > 0 ){ |
ERROR_PROPAGATE( ipc_data_write_start( phone, strings[ index ].value, strings[ index ].length + 1 )); |
ERROR_PROPAGATE( ipc_data_write_start( phone, strings[ index ].value, strings[ index ].length )); |
} |
} |
return EOK; |