Coverage Report

Created: 2022-04-27 14:33

/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
 */
6
7
#include "fido.h"
8
9
int
10
fido_buf_read(const unsigned char **buf, size_t *len, void *dst, size_t count)
11
15.7k
{
12
15.7k
        if (count > *len)
13
509
                return (-1);
14
15
15.2k
        memcpy(dst, *buf, count);
16
15.2k
        *buf += count;
17
15.2k
        *len -= count;
18
19
15.2k
        return (0);
20
15.7k
}
21
22
int
23
fido_buf_write(unsigned char **buf, size_t *len, const void *src, size_t count)
24
3.83M
{
25
3.83M
        if (count > *len)
26
0
                return (-1);
27
28
3.83M
        memcpy(*buf, src, count);
29
3.83M
        *buf += count;
30
3.83M
        *len -= count;
31
32
3.83M
        return (0);
33
3.83M
}