Coverage Report

Created: 2023-09-23 17:42

/libfido2/src/buf.c
Line
Count
Source (jump to first uncovered line)
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
 * SPDX-License-Identifier: BSD-2-Clause
6
 */
7
8
#include "fido.h"
9
10
int
11
fido_buf_read(const unsigned char **buf, size_t *len, void *dst, size_t count)
12
17.2k
{
13
17.2k
        if (count > *len)
14
453
                return (-1);
15
16
16.8k
        memcpy(dst, *buf, count);
17
16.8k
        *buf += count;
18
16.8k
        *len -= count;
19
20
16.8k
        return (0);
21
17.2k
}
22
23
int
24
fido_buf_write(unsigned char **buf, size_t *len, const void *src, size_t count)
25
3.78M
{
26
3.78M
        if (count > *len)
27
0
                return (-1);
28
29
3.78M
        memcpy(*buf, src, count);
30
3.78M
        *buf += count;
31
3.78M
        *len -= count;
32
33
3.78M
        return (0);
34
3.78M
}