5c0faaf4f5
Help detecting Valgrind OOB reads and other issues. Conditional jump or move depends on uninitialised value(s) at 0x5452886: blobmsg_parse (blobmsg.c:203) by 0x400A8E: test_blobmsg (tests/test-blobmsg-parse.c:66) by 0x400A8E: main (tests/test-blobmsg-parse.c:82) Conditional jump or move depends on uninitialised value(s) at 0x545247F: blobmsg_check_name (blobmsg.c:39) by 0x545247F: blobmsg_check_attr_len (blobmsg.c:79) by 0x5452710: blobmsg_parse_array (blobmsg.c:159) by 0x400AB8: test_blobmsg (tests/test-blobmsg-parse.c:69) by 0x400AB8: main (tests/test-blobmsg-parse.c:82) Conditional jump or move depends on uninitialised value(s) at 0x54524A0: blobmsg_check_name (blobmsg.c:42) by 0x54524A0: blobmsg_check_attr_len (blobmsg.c:79) by 0x5452710: blobmsg_parse_array (blobmsg.c:159) by 0x400AB8: test_blobmsg (tests/test-blobmsg-parse.c:69) by 0x400AB8: main (tests/test-blobmsg-parse.c:82) Ref: http://lists.infradead.org/pipermail/openwrt-devel/2020-January/021204.html Signed-off-by: Petr Štetiar <ynezz@true.cz>
44 lines
849 B
C
44 lines
849 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "utils.h"
|
|
|
|
#define BUF_LEN 255
|
|
|
|
static void test_b64_encode(const char *src)
|
|
{
|
|
char *dst = malloc(BUF_LEN+1);
|
|
int r = b64_encode(src, strlen(src), dst, BUF_LEN);
|
|
fprintf(stdout, "%d %s\n", r, dst);
|
|
free(dst);
|
|
}
|
|
|
|
static void test_b64_decode(const char *src)
|
|
{
|
|
char *dst = malloc(BUF_LEN+1);
|
|
int r = b64_decode(src, dst, BUF_LEN);
|
|
fprintf(stdout, "%d %s\n", r, dst);
|
|
free(dst);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
test_b64_encode("");
|
|
test_b64_encode("f");
|
|
test_b64_encode("fo");
|
|
test_b64_encode("foo");
|
|
test_b64_encode("foob");
|
|
test_b64_encode("fooba");
|
|
test_b64_encode("foobar");
|
|
|
|
test_b64_decode("");
|
|
test_b64_decode("Zg==");
|
|
test_b64_decode("Zm8=");
|
|
test_b64_decode("Zm9v");
|
|
test_b64_decode("Zm9vYg==");
|
|
test_b64_decode("Zm9vYmE=");
|
|
test_b64_decode("Zm9vYmFy");
|
|
|
|
return 0;
|
|
}
|