summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-01 13:47:27 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-01-01 13:47:27 +0100
commitfa1d60ad91e7cdc007d19011bb79ea666b83b5e6 (patch)
tree4784cd4db7bc330a2f2120084f561f233882b55e /utils.c
parentadc5d408b5d28e8c91d81d885ef1da2a9016f1cf (diff)
minor cleanup
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/utils.c b/utils.c
index aabb430..847ff34 100644
--- a/utils.c
+++ b/utils.c
@@ -149,12 +149,10 @@ int uh_urlencode(char *buf, int blen, const char *src, int slen)
int uh_b64decode(char *buf, int blen, const unsigned char *src, int slen)
{
- int i = 0;
- int len = 0;
-
- unsigned int cin = 0;
unsigned int cout = 0;
-
+ unsigned int cin = 0;
+ int len = 0;
+ int i = 0;
for (i = 0; (i <= slen) && (src[i] != 0); i++)
{
@@ -177,19 +175,15 @@ int uh_b64decode(char *buf, int blen, const unsigned char *src, int slen)
cout = (cout << 6) | cin;
- if ((i % 4) == 3)
- {
- if ((len + 3) < blen)
- {
- buf[len++] = (char)(cout >> 16);
- buf[len++] = (char)(cout >> 8);
- buf[len++] = (char)(cout);
- }
- else
- {
- break;
- }
- }
+ if ((i % 4) != 3)
+ continue;
+
+ if ((len + 3) >= blen)
+ break;
+
+ buf[len++] = (char)(cout >> 16);
+ buf[len++] = (char)(cout >> 8);
+ buf[len++] = (char)(cout);
}
buf[len++] = 0;