tests: jshn: add more test cases
[project/libubox.git] / base64.c
index 4759ede01e7c638b86cc6a6e2f25d129c16e14ac..1bf21772fbed448f75e9b5c299c2db5ddf48fcd6 100644 (file)
--- a/base64.c
+++ b/base64.c
@@ -65,6 +65,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include "assert.h"
 #include "utils.h"
 
 static const char Base64[] =
@@ -144,6 +146,8 @@ int b64_encode(const void *_src, size_t srclength,
        u_char output[4];
        size_t i;
 
+       assert(dest && targsize > 0);
+
        while (2 < srclength) {
                input[0] = *src++;
                input[1] = *src++;
@@ -208,6 +212,8 @@ int b64_decode(const void *_src, void *dest, size_t targsize)
        state = 0;
        tarindex = 0;
 
+       assert(dest && targsize > 0);
+
        while ((ch = (unsigned char)*src++) != '\0') {
                if (isspace(ch))        /* Skip whitespace anywhere. */
                        continue;