diff options
author | nicoo <nicoo@debian.org> | 2020-02-12 13:43:18 +0100 |
---|---|---|
committer | Nicolas Braud-Santoni <nicolas@braud-santoni.eu> | 2020-02-12 13:43:18 +0100 |
commit | 88a8bdd35ca7fb0c1ce70abdd8262d958fedafc1 (patch) | |
tree | ce42d9d46d371c05eed82d8bb1e8aa7b2522a769 /src/buf.c | |
parent | 4e06e4554b69e678110563b1cf00a258a202dd7b (diff) | |
parent | c79050aa44b8836d836c5dd22a383a073c28b74b (diff) |
Merge upstream release 1.3.0 into debian/sid
Diffstat (limited to 'src/buf.c')
-rw-r--r-- | src/buf.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/buf.c b/src/buf.c new file mode 100644 index 0000000..4646476 --- /dev/null +++ b/src/buf.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018 Yubico AB. All rights reserved. | ||
3 | * Use of this source code is governed by a BSD-style | ||
4 | * license that can be found in the LICENSE file. | ||
5 | */ | ||
6 | |||
7 | #include <string.h> | ||
8 | #include "fido.h" | ||
9 | |||
10 | int | ||
11 | fido_buf_read(const unsigned char **buf, size_t *len, void *dst, size_t count) | ||
12 | { | ||
13 | if (count > *len) | ||
14 | return (-1); | ||
15 | |||
16 | memcpy(dst, *buf, count); | ||
17 | *buf += count; | ||
18 | *len -= count; | ||
19 | |||
20 | return (0); | ||
21 | } | ||
22 | |||
23 | int | ||
24 | fido_buf_write(unsigned char **buf, size_t *len, const void *src, size_t count) | ||
25 | { | ||
26 | if (count > *len) | ||
27 | return (-1); | ||
28 | |||
29 | memcpy(*buf, src, count); | ||
30 | *buf += count; | ||
31 | *len -= count; | ||
32 | |||
33 | return (0); | ||
34 | } | ||