X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt_common.c;h=fb6e1ef4174931a9201ea571b7ea33ecd09bf54c;hp=6c71d7e3716829d90485894bc261ee867589d7bf;hb=093dda1824631372587d107d64601389027c6187;hpb=5cb5db1fbf8f9b96c3b5a1e0cc7de9e710757540 diff --git a/crypt_common.c b/crypt_common.c index 6c71d7e3..fb6e1ef4 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Andre Noll + * Copyright (C) 2005-2014 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -90,41 +90,31 @@ int base64_decode(char const *src, unsigned char *target, size_t targsize) switch (state) { case 0: - if (target) { - if (tarindex >= targsize) - return -E_BASE64; - target[tarindex] = (pos - Base64) << 2; - } + if (tarindex >= targsize) + return -E_BASE64; + target[tarindex] = (pos - Base64) << 2; state = 1; break; case 1: - if (target) { - if (tarindex + 1 >= targsize) - return -E_BASE64; - target[tarindex] |= (pos - Base64) >> 4; - target[tarindex+1] = ((pos - Base64) & 0x0f) - << 4 ; - } + if (tarindex + 1 >= targsize) + return -E_BASE64; + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex + 1] = ((pos - Base64) & 0x0f) << 4; tarindex++; state = 2; break; case 2: - if (target) { - if (tarindex + 1 >= targsize) - return -E_BASE64; - target[tarindex] |= (pos - Base64) >> 2; - target[tarindex+1] = ((pos - Base64) & 0x03) - << 6; - } + if (tarindex + 1 >= targsize) + return -E_BASE64; + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex + 1] = ((pos - Base64) & 0x03) << 6; tarindex++; state = 3; break; case 3: - if (target) { - if (tarindex >= targsize) - return -E_BASE64; - target[tarindex] |= (pos - Base64); - } + if (tarindex >= targsize) + return -E_BASE64; + target[tarindex] |= pos - Base64; tarindex++; state = 0; break; @@ -170,7 +160,7 @@ int base64_decode(char const *src, unsigned char *target, size_t targsize) * zeros. If we don't check them, they become a * subliminal channel. */ - if (target && target[tarindex] != 0) + if (target[tarindex] != 0) return -E_BASE64; } } else {