summaryrefslogtreecommitdiffstats
path: root/util/base64.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 22:38:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 22:38:48 +0000
commit01c4d3d32c5044d3d17055c2d94d40fee9d130e1 (patch)
tree2c213cd5436bff644fa7023b94674a9c12d2e1af /util/base64.c
parentAdding upstream version 2.4+really2.4. (diff)
downloadnvme-cli-01c4d3d32c5044d3d17055c2d94d40fee9d130e1.tar.xz
nvme-cli-01c4d3d32c5044d3d17055c2d94d40fee9d130e1.zip
Adding upstream version 2.5.upstream/2.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'util/base64.c')
-rw-r--r--util/base64.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/util/base64.c b/util/base64.c
index 07f975c..7f47cda 100644
--- a/util/base64.c
+++ b/util/base64.c
@@ -81,24 +81,24 @@ int base64_decode(const char *src, int srclen, unsigned char *dst)
int i, bits = 0;
unsigned char *bp = dst;
- for (i = 0; i < srclen; i++) {
- const char *p = strchr(base64_table, src[i]);
+ for (i = 0; i < srclen; i++) {
+ const char *p = strchr(base64_table, src[i]);
- if (src[i] == '=') {
- ac = (ac << 6);
+ if (src[i] == '=') {
+ ac = (ac << 6);
bits += 6;
if (bits >= 8)
bits -= 8;
- continue;
- }
- if (p == NULL || src[i] == 0)
- return -EINVAL;
- ac = (ac << 6) | (p - base64_table);
- bits += 6;
- if (bits >= 8) {
- bits -= 8;
- *bp++ = (unsigned char)(ac >> bits);
- }
+ continue;
+ }
+ if (!p || !src[i])
+ return -EINVAL;
+ ac = (ac << 6) | (p - base64_table);
+ bits += 6;
+ if (bits >= 8) {
+ bits -= 8;
+ *bp++ = (unsigned char)(ac >> bits);
+ }
}
if (ac && ((1 << bits) - 1))
return -EAGAIN;