Coverage Report

Created: 2020-09-01 07:05

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