Commit 450d3ff2 authored by 's avatar
Browse files

fixed two bugs : marshalling of function parameters, str2anonid returns -1 on...

fixed two bugs : marshalling of function parameters, str2anonid returns -1 on not found , anonymize.c was changed accordingly


git-svn-id: file:///home/svn/mapi/trunk@907 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent f5481a42
......@@ -133,7 +133,8 @@ int unmarshalBuffer(int function,char *buffer,struct unmarshal_data *data) {
char *regexp=NULL,*tmpbuf;
int num_of_matches = 0,i = 0;
char **replaceVector=NULL;
char tmp1[1024],tmp2[1024],tmp3[1024];
if(buffer==NULL)
return 0;
......@@ -154,7 +155,11 @@ int unmarshalBuffer(int function,char *buffer,struct unmarshal_data *data) {
return 0;
if((pos=strchr(buffer,','))==NULL || *(pos+1)=='\0')
return 0;
sscanf(buffer,"%d,%d",&hash_algorithm,&padding_behavior);
//sscanf(buffer,"%d,%d",&hash_algorithm,&padding_behavior);
sscanf(buffer,"%s,%s",&tmp1[0],&tmp2[0]);
hash_algorithm=str2anonid(tmp1);
padding_behavior=str2anonid(tmp2);
if(hash_algorithm<ANON_SHA || hash_algorithm>ANON_DES)
return 0;
if(padding_behavior!=PAD_WITH_ZERO && padding_behavior!=STRIP_REST && padding_behavior!=UNCHANGED)
......@@ -165,7 +170,10 @@ int unmarshalBuffer(int function,char *buffer,struct unmarshal_data *data) {
return 0;
if((pos=strchr(buffer,','))==NULL || *(pos+1)=='\0')
return 0;
sscanf(buffer,"%d,%d,%d",&distribution_type,&median,&standard_deviation);
//sscanf(buffer,"%d,%d,%d",&distribution_type,&median,&standard_deviation);
sscanf(buffer,"%s,%d,%d",&tmp1[0],&median,&standard_deviation);
distribution_type=str2anonid(tmp1);
if(distribution_type!=UNIFORM && distribution_type!=GAUSSIAN)
return 0;
break;
......@@ -174,7 +182,9 @@ int unmarshalBuffer(int function,char *buffer,struct unmarshal_data *data) {
return 0;
if((pos=strchr(buffer,','))==NULL || *(pos+1)=='\0')
return 0;
sscanf(buffer,"%d,%s",&pattern_type,pattern);
//sscanf(buffer,"%d,%s",&pattern_type,pattern);
sscanf(buffer,"%s,%s",&tmp1[0],pattern);
pattern_type=str2anonid(tmp1);
if(pattern_type!=0 && pattern_type!=1)
return 0;
break;
......@@ -307,7 +317,7 @@ static int anonymize_instance(mapidflib_function_instance_t *instance,
}
*ptr='\0';
if((protocol=str2anonid(marshalledBuffer))==0)
if((protocol=str2anonid(marshalledBuffer))==-1)
return MFUNCT_INVALID_ARGUMENT_1;
/************ field *********/
......@@ -318,7 +328,7 @@ static int anonymize_instance(mapidflib_function_instance_t *instance,
}
*ptr='\0';
if((field_description=str2anonid(marshalledBuffer))==0)
if((field_description=str2anonid(marshalledBuffer))==-1)
return MFUNCT_INVALID_ARGUMENT_2;
/********** function ******/
......@@ -326,12 +336,12 @@ static int anonymize_instance(mapidflib_function_instance_t *instance,
ptr=strchr(marshalledBuffer,',');
if(ptr!=NULL) {
*ptr='\0';
if((anonymization_function=str2anonid(marshalledBuffer))==0)
if((anonymization_function=str2anonid(marshalledBuffer))==-1)
return MFUNCT_INVALID_ARGUMENT_3;
marshalledBuffer=ptr+1;
}
else {
if((anonymization_function=str2anonid(marshalledBuffer))==0)
if((anonymization_function=str2anonid(marshalledBuffer))==-1)
return MFUNCT_INVALID_ARGUMENT_3;
marshalledBuffer=NULL;
}
......
......@@ -168,10 +168,17 @@ NULL
int str2anonid(char *name) {
int i=0;
//pattern types are not in the same enumeration
if(strcmp(name,"INTEGER")==0)
return 0;
if(strcmp(name,"STR")==0)
return 1;
for(i=0;anonnames[i]!=NULL;i++) {
if(strcmp(anonnames[i],name)==0) {
return i;
}
}
return 0;
return -1;
}
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