Updated to cbase64-1.1

This commit is contained in:
Jordan Cristiano 2015-07-12 22:50:55 -04:00
parent e959fb0334
commit 04b79ff3f8
5 changed files with 11 additions and 12 deletions

View File

@ -163,8 +163,7 @@ unsigned int cbase64_decode_block(const char* code_in, unsigned int length_in,
const char* const codeend = code_in + length_in; const char* const codeend = code_in + length_in;
unsigned char* datachar = data_out; unsigned char* datachar = data_out;
char fragment; char fragment;
char overwrite = state_in->result;
*datachar = state_in->result;
switch (state_in->step) switch (state_in->step)
{ {
@ -175,7 +174,7 @@ unsigned int cbase64_decode_block(const char* code_in, unsigned int length_in,
if (codechar == codeend) if (codechar == codeend)
{ {
state_in->step = step_A; state_in->step = step_A;
state_in->result = *datachar; state_in->result = overwrite;
return datachar - data_out; return datachar - data_out;
} }
fragment = cbase64__decode_value(*codechar++); fragment = cbase64__decode_value(*codechar++);
@ -186,36 +185,36 @@ unsigned int cbase64_decode_block(const char* code_in, unsigned int length_in,
if (codechar == codeend) if (codechar == codeend)
{ {
state_in->step = step_B; state_in->step = step_B;
state_in->result = *datachar; state_in->result = overwrite;
return datachar - data_out; return datachar - data_out;
} }
fragment = cbase64__decode_value(*codechar++); fragment = cbase64__decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
*datachar++ |= (fragment & 0x030) >> 4; *datachar++ |= (fragment & 0x030) >> 4;
*datachar = (fragment & 0x00f) << 4; overwrite = (fragment & 0x00f) << 4;
case step_C: case step_C:
do { do {
if (codechar == codeend) if (codechar == codeend)
{ {
state_in->step = step_C; state_in->step = step_C;
state_in->result = *datachar; state_in->result = overwrite;
return datachar - data_out; return datachar - data_out;
} }
fragment = cbase64__decode_value(*codechar++); fragment = cbase64__decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
*datachar++ |= (fragment & 0x03c) >> 2; *datachar++ = overwrite | (fragment & 0x03c) >> 2;
*datachar = (fragment & 0x003) << 6; overwrite = (fragment & 0x003) << 6;
case step_D: case step_D:
do { do {
if (codechar == codeend) if (codechar == codeend)
{ {
state_in->step = step_D; state_in->step = step_D;
state_in->result = *datachar; state_in->result = overwrite;
return datachar - data_out; return datachar - data_out;
} }
fragment = cbase64__decode_value(*codechar++); fragment = cbase64__decode_value(*codechar++);
} while (fragment < 0); } while (fragment < 0);
*datachar++ |= (fragment & 0x03f); *datachar++ = overwrite | (fragment & 0x03f);
} }
} }
// control should not reach here // control should not reach here

View File

@ -29,7 +29,7 @@ solution "demboyz"
includedirs includedirs
{ {
"../external/json_checker/include", "../external/json_checker/include",
"../external/cbase64-1.0/include", "../external/cbase64-1.1/include",
"../external/sourcesdk/include", "../external/sourcesdk/include",
"../external/rapidjson-1.0.2/include", "../external/rapidjson-1.0.2/include",
"../demboyz" "../demboyz"