X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=base64.c;h=1bf21772fbed448f75e9b5c299c2db5ddf48fcd6;hb=b77f2a4ce9034d4341668bb61ca55fc177ee7729;hp=4186ce848c7125190f90da583bf6aa4f735cf0bc;hpb=d66a89f010247f20a9803f2bef1c3dc1d7d706b9;p=project%2Flibubox.git diff --git a/base64.c b/base64.c index 4186ce8..1bf2177 100644 --- a/base64.c +++ b/base64.c @@ -65,6 +65,8 @@ #include #include #include + +#include "assert.h" #include "utils.h" static const char Base64[] = @@ -142,7 +144,9 @@ int b64_encode(const void *_src, size_t srclength, size_t datalength = 0; u_char input[3] = {0}; u_char output[4]; - int i; + size_t i; + + assert(dest && targsize > 0); while (2 < srclength) { input[0] = *src++; @@ -200,13 +204,16 @@ int b64_decode(const void *_src, void *dest, size_t targsize) { const char *src = _src; unsigned char *target = dest; - int tarindex, state, ch; + int state, ch; + size_t tarindex; u_char nextbyte; char *pos; state = 0; tarindex = 0; + assert(dest && targsize > 0); + while ((ch = (unsigned char)*src++) != '\0') { if (isspace(ch)) /* Skip whitespace anywhere. */ continue;