Sfoglia il codice sorgente

adding unsigned char flags as discussed in #86

Stasik0 10 anni fa
parent
commit
93d47f5a9a
2 ha cambiato i file con 4 aggiunte e 5 eliminazioni
  1. 1 1
      Makefile.am
  2. 3 4
      src/util/ua_base64.c

+ 1 - 1
Makefile.am

@@ -1,5 +1,5 @@
 #AM_CFLAGS  = -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror
-AM_CFLAGS  = -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror
+AM_CFLAGS  = -std=c99 -pedantic -pipe -fPIC -funsigned-char -fno-exceptions -fstack-protector -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror
 AM_LDFLAGS =
 AM_LDADD =
 

+ 3 - 4
src/util/ua_base64.c

@@ -57,8 +57,7 @@ UA_Int32 UA_base64_decode(UA_String* const base64EncodedData, UA_Byte* target){
 	}
 	base64_decodestate state;
 	base64_init_decodestate(&state);
-	//FIXME: The (void*)(char*) was was perfomed to get rid of "differ in signedness" warnings. Can be a potential problem since the library code expects 'char' but we have 'unsigned char' in UA_String
-	base64_decode_block((void*)(char*)(base64EncodedData->data), base64EncodedData->length, (void*)(char*)target, &state);
+	base64_decode_block((char*)(base64EncodedData->data), base64EncodedData->length, (char*)target, &state);
 	return UA_NO_ERROR;
 }
 
@@ -78,7 +77,7 @@ int base64_decode_value(char value_in)
 	static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
 	static const char decoding_size = sizeof(decoding);
 	value_in -= 43;
-	if (value_in < 0 || value_in > decoding_size) return -1;
+	if (value_in > decoding_size) return -1;
 	return decoding[(int)value_in];
 }
 
@@ -92,7 +91,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
 {
 	const char* codechar = code_in;
 	char* plainchar = plaintext_out;
-	char fragment;
+	signed char fragment;
 	
 	*plainchar = state_in->plainchar;