Coverage Report

Created: 2021-03-26 11:35

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