summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-02-18 18:09:34 +0100
committerGravatar Nikias Bassen2017-02-18 18:09:34 +0100
commite37ca0090343e0dae97e967d467bab56d502c37a (patch)
tree583595b3cbfa4f915924c7fdf4b7e8bbc36c70ae
parent8ad21e6b59e5e5a3104660f17ad2b0e9122edecf (diff)
downloadlibplist-e37ca0090343e0dae97e967d467bab56d502c37a.tar.gz
libplist-e37ca0090343e0dae97e967d467bab56d502c37a.tar.bz2
base64: Prevent undefined shift when parsing invalid base64 encoded data
Credit to OSS-Fuzz
-rw-r--r--src/base64.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/base64.c b/src/base64.c
index ba8acca..ee02356 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -101,13 +101,13 @@ unsigned char *base64decode(const char *buf, size_t *size)
w3 = tmpval[2];
w4 = tmpval[3];
- if (w2 >= 0) {
+ if (w1 >= 0 && w2 >= 0) {
outbuf[p++] = (unsigned char)(((w1 << 2) + (w2 >> 4)) & 0xFF);
}
- if (w3 >= 0) {
+ if (w2 >= 0 && w3 >= 0) {
outbuf[p++] = (unsigned char)(((w2 << 4) + (w3 >> 2)) & 0xFF);
}
- if (w4 >= 0) {
+ if (w3 >= 0 && w4 >= 0) {
outbuf[p++] = (unsigned char)(((w3 << 6) + w4) & 0xFF);
}
}