PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2 of the License,
+ by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
static const char base64_chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-static int pos(char c)
-{
+static int pos(char c) {
if (c >= 'A' && c <= 'Z') return c - 'A' + 0;
if (c >= 'a' && c <= 'z') return c - 'a' + 26;
if (c >= '0' && c <= '9') return c - '0' + 52;
if (c == '+') return 62;
if (c == '/') return 63;
+ return -1;
}
-int pa_base64_encode(const void *data, int size, char **str)
-{
+int pa_base64_encode(const void *data, int size, char **str) {
char *s, *p;
int i;
int c;
p = s = pa_xnew(char, size * 4 / 3 + 4);
q = (const unsigned char *) data;
- i = 0;
for (i = 0; i < size;) {
c = q[i++];
c *= 256;
#define DECODE_ERROR 0xffffffff
-static unsigned int token_decode(const char *token)
-{
+static unsigned int token_decode(const char *token) {
int i;
unsigned int val = 0;
int marker = 0;
marker++;
else if (marker > 0)
return DECODE_ERROR;
- else
- val += pos(token[i]);
+ else {
+ int lpos = pos(token[i]);
+ if (lpos < 0)
+ return DECODE_ERROR;
+ val += lpos;
+ }
}
if (marker > 2)
return DECODE_ERROR;
return (marker << 24) | val;
}
-int pa_base64_decode(const char *str, void *data)
-{
+int pa_base64_decode(const char *str, void *data) {
const char *p;
unsigned char *q;