Coverage Report

Created: 2021-07-20 18:14

/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
12.7k
{
12
12.7k
        if (count > *len)
13
290
                return (-1);
14
12.4k
15
12.4k
        memcpy(dst, *buf, count);
16
12.4k
        *buf += count;
17
12.4k
        *len -= count;
18
12.4k
19
12.4k
        return (0);
20
12.4k
}
21
22
int
23
fido_buf_write(unsigned char **buf, size_t *len, const void *src, size_t count)
24
11.3k
{
25
11.3k
        if (count > *len)
26
0
                return (-1);
27
11.3k
28
11.3k
        memcpy(*buf, src, count);
29
11.3k
        *buf += count;
30
11.3k
        *len -= count;
31
11.3k
32
11.3k
        return (0);
33
11.3k
}