Lines 55-61
VERSION HISTORY:
Link Here
|
55 |
\******************************************************************* */ |
55 |
\******************************************************************* */ |
56 |
|
56 |
|
57 |
/* system headers */ |
57 |
/* system headers */ |
58 |
#include <stdlib.h> |
58 |
#include <stdio.h> |
59 |
#include <string.h> |
59 |
#include <string.h> |
60 |
|
60 |
|
61 |
/* libotr headers */ |
61 |
/* libotr headers */ |
Lines 147-154
static size_t decode(unsigned char *out, const char *in, size_t b64len)
Link Here
|
147 |
* base64 decode data. Skip non-base64 chars, and terminate at the |
147 |
* base64 decode data. Skip non-base64 chars, and terminate at the |
148 |
* first '=', or the end of the buffer. |
148 |
* first '=', or the end of the buffer. |
149 |
* |
149 |
* |
150 |
* The buffer data must contain at least (base64len / 4) * 3 bytes of |
150 |
* The buffer data must contain at least ((base64len+3) / 4) * 3 bytes |
151 |
* space. This function will return the number of bytes actually used. |
151 |
* of space. This function will return the number of bytes actually |
|
|
152 |
* used. |
152 |
*/ |
153 |
*/ |
153 |
size_t otrl_base64_decode(unsigned char *data, const char *base64data, |
154 |
size_t otrl_base64_decode(unsigned char *data, const char *base64data, |
154 |
size_t base64len) |
155 |
size_t base64len) |
Lines 234-246
int otrl_base64_otr_decode(const char *msg, unsigned char **bufp,
Link Here
|
234 |
return -2; |
235 |
return -2; |
235 |
} |
236 |
} |
236 |
|
237 |
|
|
|
238 |
/* Skip over the "?OTR:" */ |
239 |
otrtag += 5; |
240 |
msglen -= 5; |
241 |
|
237 |
/* Base64-decode the message */ |
242 |
/* Base64-decode the message */ |
238 |
rawlen = ((msglen-5+3) / 4) * 3; /* maximum possible */ |
243 |
rawlen = OTRL_B64_MAX_DECODED_SIZE(msglen); /* maximum possible */ |
239 |
rawmsg = malloc(rawlen); |
244 |
rawmsg = malloc(rawlen); |
240 |
if (!rawmsg && rawlen > 0) { |
245 |
if (!rawmsg && rawlen > 0) { |
241 |
return -1; |
246 |
return -1; |
242 |
} |
247 |
} |
243 |
rawlen = otrl_base64_decode(rawmsg, otrtag+5, msglen-5); /* actual size */ |
248 |
|
|
|
249 |
rawlen = otrl_base64_decode(rawmsg, otrtag, msglen); /* actual size */ |
244 |
|
250 |
|
245 |
*bufp = rawmsg; |
251 |
*bufp = rawmsg; |
246 |
*lenp = rawlen; |
252 |
*lenp = rawlen; |