| 339 | } |
| 340 | |
| 341 | struct rune *rune_from_base64n(const tal_t *ctx, const char *str, size_t len) |
| 342 | { |
| 343 | size_t blen; |
| 344 | u8 *data; |
| 345 | struct rune *rune; |
| 346 | |
| 347 | data = tal_arr(NULL, u8, base64_decoded_length(len) + 1); |
| 348 | |
| 349 | blen = base64_decode_using_maps(&base64_maps_urlsafe, |
| 350 | (char *)data, tal_bytelen(data), |
| 351 | str, len); |
| 352 | if (blen == -1) |
| 353 | goto fail; |
| 354 | |
| 355 | if (blen < 32) |
| 356 | goto fail; |
| 357 | |
| 358 | data[blen] = '\0'; |
| 359 | /* Sanity check that it's a valid string! */ |
| 360 | if (strlen((char *)data + 32) != blen - 32) |
| 361 | goto fail; |
| 362 | |
| 363 | rune = from_string(ctx, (const char *)data + 32, data); |
| 364 | tal_free(data); |
| 365 | return rune; |
| 366 | |
| 367 | fail: |
| 368 | tal_free(data); |
| 369 | return NULL; |
| 370 | } |
| 371 | |
| 372 | struct rune *rune_from_base64(const tal_t *ctx, const char *str) |
| 373 | { |
no test coverage detected