Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-11-19 19:16:40 +0300
committerPetr Štetiar <ynezz@true.cz>2019-11-24 15:26:58 +0300
commit0003ea9c45cc8d2f57af760a92a35f371649714f (patch)
tree00c4341dec1ab48796be9283df31295a3232aa28 /tests/test-b64_encode.c
parent8baeeea1f52d7081aac81d80fdb55b8749d9392e (diff)
base64: fix possible null pointer dereference
clang-10 analyzer reports following: base64.c:325:20: warning: Array access (from variable 'target') results in a null pointer dereference target[tarindex] = 0; ~~~~~~ ^ and prepared test case confirms it: Invalid write of size 1 at 0x4E4463F: b64_decode (base64.c:325) by 0x40088C: test_invalid_inputs (tests/test-base64.c:26) by 0x40088C: main (tests/test-base64.c:32) Address 0x1 is not stack'd, malloc'd or (recently) free'd Process terminating with default action of signal 11 (SIGSEGV) Access not within mapped region at address 0x1 at 0x4E4463F: b64_decode (base64.c:325) by 0x40088C: test_invalid_inputs (tests/test-base64.c:26) by 0x40088C: main (tests/test-base64.c:32) Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'tests/test-b64_encode.c')
-rw-r--r--tests/test-b64_encode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test-b64_encode.c b/tests/test-b64_encode.c
new file mode 100644
index 0000000..5f011e5
--- /dev/null
+++ b/tests/test-b64_encode.c
@@ -0,0 +1,7 @@
+#include "utils.h"
+
+int main()
+{
+ b64_encode("foo", 3, NULL, 2);
+ return 0;
+}