Skip to content

Commit

Permalink
fix: apply quick workaround for Android NDK
Browse files Browse the repository at this point in the history
to avoid an issue due to some lossy casting

as needed for armeabi-v7a (32-bit) & arm64-v8a

(not needed for x86 32-bit or 64-bit)

as proposed for libb64 in:

- gorb314/libb64#4
  • Loading branch information
Christopher J. Brody committed Jul 14, 2021
1 parent c5c5fbb commit fb3ef5c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
{
const char* codechar = code_in;
char* plainchar = plaintext_out;
int value;
char fragment;

*plainchar = state_in->plainchar;
Expand All @@ -42,8 +43,9 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
} while (fragment < 0);
value = base64_decode_value(*codechar++);
fragment = (char)value;
} while (value < 0);
*plainchar = (fragment & 0x03f) << 2;
case step_b:
do {
Expand All @@ -53,8 +55,9 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
} while (fragment < 0);
value = base64_decode_value(*codechar++);
fragment = (char)value;
} while (value < 0);
*plainchar++ |= (fragment & 0x030) >> 4;
*plainchar = (fragment & 0x00f) << 4;
case step_c:
Expand All @@ -65,8 +68,9 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
} while (fragment < 0);
value = base64_decode_value(*codechar++);
fragment = (char)value;
} while (value < 0);
*plainchar++ |= (fragment & 0x03c) >> 2;
*plainchar = (fragment & 0x003) << 6;
case step_d:
Expand All @@ -77,8 +81,9 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
} while (fragment < 0);
value = base64_decode_value(*codechar++);
fragment = (char)value;
} while (value < 0);
*plainchar++ |= (fragment & 0x03f);
}
}
Expand Down

0 comments on commit fb3ef5c

Please sign in to comment.